google-api-client 0.8.7 → 0.9.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +63 -0
- data/.travis.yml +21 -0
- data/.yardopts +12 -0
- data/CHANGELOG.md +6 -3
- data/CONTRIBUTING.md +31 -0
- data/Gemfile +28 -2
- data/MIGRATING.md +171 -0
- data/README.md +158 -150
- data/Rakefile +1 -40
- data/api_names.yaml +872 -0
- data/api_names_out.yaml +20843 -0
- data/bin/generate-api +93 -0
- data/generated/google/apis/adexchangebuyer_v1_3.rb +35 -0
- data/generated/google/apis/adexchangebuyer_v1_3/classes.rb +1124 -0
- data/generated/google/apis/adexchangebuyer_v1_3/representations.rb +375 -0
- data/generated/google/apis/adexchangebuyer_v1_3/service.rb +893 -0
- data/generated/google/apis/adexchangeseller_v2_0.rb +38 -0
- data/generated/google/apis/adexchangeseller_v2_0/classes.rb +792 -0
- data/generated/google/apis/adexchangeseller_v2_0/representations.rb +309 -0
- data/generated/google/apis/adexchangeseller_v2_0/service.rb +682 -0
- data/generated/google/apis/admin_directory_v1.rb +89 -0
- data/generated/google/apis/admin_directory_v1/classes.rb +2389 -0
- data/generated/google/apis/admin_directory_v1/representations.rb +780 -0
- data/generated/google/apis/admin_directory_v1/service.rb +2805 -0
- data/generated/google/apis/admin_reports_v1.rb +38 -0
- data/generated/google/apis/admin_reports_v1/classes.rb +582 -0
- data/generated/google/apis/admin_reports_v1/representations.rb +231 -0
- data/generated/google/apis/admin_reports_v1/service.rb +341 -0
- data/generated/google/apis/adsense_v1_4.rb +38 -0
- data/generated/google/apis/adsense_v1_4/classes.rb +1279 -0
- data/generated/google/apis/adsense_v1_4/representations.rb +493 -0
- data/generated/google/apis/adsense_v1_4/service.rb +1752 -0
- data/generated/google/apis/adsensehost_v4_1.rb +35 -0
- data/generated/google/apis/adsensehost_v4_1/classes.rb +834 -0
- data/generated/google/apis/adsensehost_v4_1/representations.rb +327 -0
- data/generated/google/apis/adsensehost_v4_1/service.rb +1190 -0
- data/generated/google/apis/analytics_v3.rb +49 -0
- data/generated/google/apis/analytics_v3/classes.rb +5113 -0
- data/generated/google/apis/analytics_v3/representations.rb +1661 -0
- data/generated/google/apis/analytics_v3/service.rb +3600 -0
- data/generated/google/apis/androidenterprise_v1.rb +34 -0
- data/generated/google/apis/androidenterprise_v1/classes.rb +1162 -0
- data/generated/google/apis/androidenterprise_v1/representations.rb +431 -0
- data/generated/google/apis/androidenterprise_v1/service.rb +1979 -0
- data/generated/google/apis/androidpublisher_v2.rb +34 -0
- data/generated/google/apis/androidpublisher_v2/classes.rb +1374 -0
- data/generated/google/apis/androidpublisher_v2/representations.rb +630 -0
- data/generated/google/apis/androidpublisher_v2/service.rb +2390 -0
- data/generated/google/apis/appsactivity_v1.rb +46 -0
- data/generated/google/apis/appsactivity_v1/classes.rb +392 -0
- data/generated/google/apis/appsactivity_v1/representations.rb +184 -0
- data/generated/google/apis/appsactivity_v1/service.rb +129 -0
- data/generated/google/apis/appstate_v1.rb +34 -0
- data/generated/google/apis/appstate_v1/classes.rb +154 -0
- data/generated/google/apis/appstate_v1/representations.rb +79 -0
- data/generated/google/apis/appstate_v1/service.rb +265 -0
- data/generated/google/apis/autoscaler_v1beta2.rb +38 -0
- data/generated/google/apis/autoscaler_v1beta2/classes.rb +747 -0
- data/generated/google/apis/autoscaler_v1beta2/representations.rb +281 -0
- data/generated/google/apis/autoscaler_v1beta2/service.rb +488 -0
- data/generated/google/apis/bigquery_v2.rb +49 -0
- data/generated/google/apis/bigquery_v2/classes.rb +2255 -0
- data/generated/google/apis/bigquery_v2/representations.rb +754 -0
- data/generated/google/apis/bigquery_v2/service.rb +1003 -0
- data/generated/google/apis/blogger_v3.rb +37 -0
- data/generated/google/apis/blogger_v3/classes.rb +1354 -0
- data/generated/google/apis/blogger_v3/representations.rb +562 -0
- data/generated/google/apis/blogger_v3/service.rb +1620 -0
- data/generated/google/apis/books_v1.rb +34 -0
- data/generated/google/apis/books_v1/classes.rb +3515 -0
- data/generated/google/apis/books_v1/representations.rb +1361 -0
- data/generated/google/apis/books_v1/service.rb +2170 -0
- data/generated/google/apis/calendar_v3.rb +37 -0
- data/generated/google/apis/calendar_v3/classes.rb +1702 -0
- data/generated/google/apis/calendar_v3/representations.rb +566 -0
- data/generated/google/apis/calendar_v3/service.rb +1943 -0
- data/generated/google/apis/civicinfo_v2.rb +31 -0
- data/generated/google/apis/civicinfo_v2/classes.rb +1057 -0
- data/generated/google/apis/civicinfo_v2/representations.rb +374 -0
- data/generated/google/apis/civicinfo_v2/service.rb +284 -0
- data/generated/google/apis/cloudmonitoring_v2beta2.rb +34 -0
- data/generated/google/apis/cloudmonitoring_v2beta2/classes.rb +679 -0
- data/generated/google/apis/cloudmonitoring_v2beta2/representations.rb +311 -0
- data/generated/google/apis/cloudmonitoring_v2beta2/service.rb +458 -0
- data/generated/google/apis/cloudresourcemanager_v1beta1.rb +38 -0
- data/generated/google/apis/cloudresourcemanager_v1beta1/classes.rb +139 -0
- data/generated/google/apis/cloudresourcemanager_v1beta1/representations.rb +65 -0
- data/generated/google/apis/cloudresourcemanager_v1beta1/service.rb +301 -0
- data/generated/google/apis/compute_v1.rb +49 -0
- data/generated/google/apis/compute_v1/classes.rb +6391 -0
- data/generated/google/apis/compute_v1/representations.rb +2209 -0
- data/generated/google/apis/compute_v1/service.rb +6352 -0
- data/generated/google/apis/container_v1beta1.rb +35 -0
- data/generated/google/apis/container_v1beta1/classes.rb +466 -0
- data/generated/google/apis/container_v1beta1/representations.rb +177 -0
- data/generated/google/apis/container_v1beta1/service.rb +394 -0
- data/generated/google/apis/content_v2.rb +35 -0
- data/generated/google/apis/content_v2/classes.rb +3780 -0
- data/generated/google/apis/content_v2/representations.rb +1456 -0
- data/generated/google/apis/content_v2/service.rb +1706 -0
- data/generated/google/apis/coordinate_v1.rb +37 -0
- data/generated/google/apis/coordinate_v1/classes.rb +669 -0
- data/generated/google/apis/coordinate_v1/representations.rb +285 -0
- data/generated/google/apis/coordinate_v1/service.rb +687 -0
- data/{lib/google/api_client/auth/compute_service_account.rb → generated/google/apis/customsearch_v1.rb} +13 -10
- data/generated/google/apis/customsearch_v1/classes.rb +771 -0
- data/generated/google/apis/customsearch_v1/representations.rb +276 -0
- data/generated/google/apis/customsearch_v1/service.rb +208 -0
- data/generated/google/apis/datastore_v1beta2.rb +40 -0
- data/generated/google/apis/datastore_v1beta2/classes.rb +1186 -0
- data/generated/google/apis/datastore_v1beta2/representations.rb +526 -0
- data/generated/google/apis/datastore_v1beta2/service.rb +300 -0
- data/generated/google/apis/deploymentmanager_v2beta2.rb +41 -0
- data/generated/google/apis/deploymentmanager_v2beta2/classes.rb +820 -0
- data/generated/google/apis/deploymentmanager_v2beta2/representations.rb +303 -0
- data/generated/google/apis/deploymentmanager_v2beta2/service.rb +647 -0
- data/generated/google/apis/dfareporting_v2_1.rb +37 -0
- data/generated/google/apis/dfareporting_v2_1/classes.rb +10755 -0
- data/generated/google/apis/dfareporting_v2_1/representations.rb +3438 -0
- data/generated/google/apis/dfareporting_v2_1/service.rb +8775 -0
- data/generated/google/apis/discovery_v1.rb +32 -0
- data/generated/google/apis/discovery_v1/classes.rb +947 -0
- data/generated/google/apis/discovery_v1/representations.rb +355 -0
- data/generated/google/apis/discovery_v1/service.rb +144 -0
- data/generated/google/apis/dns_v1.rb +41 -0
- data/generated/google/apis/dns_v1/classes.rb +406 -0
- data/generated/google/apis/dns_v1/representations.rb +151 -0
- data/generated/google/apis/dns_v1/service.rb +460 -0
- data/{spec/google/api_client/request_spec.rb → generated/google/apis/doubleclickbidmanager_v1.rb} +15 -13
- data/generated/google/apis/doubleclickbidmanager_v1/classes.rb +709 -0
- data/generated/google/apis/doubleclickbidmanager_v1/representations.rb +297 -0
- data/generated/google/apis/doubleclickbidmanager_v1/service.rb +349 -0
- data/generated/google/apis/doubleclicksearch_v2.rb +35 -0
- data/generated/google/apis/doubleclicksearch_v2/classes.rb +947 -0
- data/generated/google/apis/doubleclicksearch_v2/representations.rb +315 -0
- data/generated/google/apis/doubleclicksearch_v2/service.rb +490 -0
- data/generated/google/apis/drive_v2.rb +55 -0
- data/generated/google/apis/drive_v2/classes.rb +2519 -0
- data/generated/google/apis/drive_v2/representations.rb +781 -0
- data/generated/google/apis/drive_v2/service.rb +2685 -0
- data/generated/google/apis/fitness_v1.rb +49 -0
- data/generated/google/apis/fitness_v1/classes.rb +809 -0
- data/generated/google/apis/fitness_v1/representations.rb +295 -0
- data/generated/google/apis/fitness_v1/service.rb +684 -0
- data/generated/google/apis/fusiontables_v2.rb +37 -0
- data/generated/google/apis/fusiontables_v2/classes.rb +1048 -0
- data/generated/google/apis/fusiontables_v2/representations.rb +409 -0
- data/generated/google/apis/fusiontables_v2/service.rb +1496 -0
- data/generated/google/apis/games_configuration_v1configuration.rb +34 -0
- data/generated/google/apis/games_configuration_v1configuration/classes.rb +506 -0
- data/generated/google/apis/games_configuration_v1configuration/representations.rb +206 -0
- data/generated/google/apis/games_configuration_v1configuration/service.rb +578 -0
- data/generated/google/apis/games_v1.rb +40 -0
- data/generated/google/apis/games_v1/classes.rb +4578 -0
- data/generated/google/apis/games_v1/representations.rb +1570 -0
- data/generated/google/apis/games_v1/service.rb +2306 -0
- data/generated/google/apis/gan_v1beta1.rb +31 -0
- data/generated/google/apis/gan_v1beta1/classes.rb +1428 -0
- data/generated/google/apis/gan_v1beta1/representations.rb +428 -0
- data/generated/google/apis/gan_v1beta1/service.rb +692 -0
- data/generated/google/apis/genomics_v1beta2.rb +46 -0
- data/generated/google/apis/genomics_v1beta2/classes.rb +3288 -0
- data/generated/google/apis/genomics_v1beta2/representations.rb +1194 -0
- data/generated/google/apis/genomics_v1beta2/service.rb +2356 -0
- data/generated/google/apis/gmail_v1.rb +49 -0
- data/generated/google/apis/gmail_v1/classes.rb +794 -0
- data/generated/google/apis/gmail_v1/representations.rb +339 -0
- data/generated/google/apis/gmail_v1/service.rb +1502 -0
- data/generated/google/apis/groupsmigration_v1.rb +34 -0
- data/generated/google/apis/groupsmigration_v1/classes.rb +51 -0
- data/generated/google/apis/groupsmigration_v1/representations.rb +38 -0
- data/generated/google/apis/groupsmigration_v1/service.rb +111 -0
- data/generated/google/apis/groupssettings_v1.rb +34 -0
- data/generated/google/apis/groupssettings_v1/classes.rb +221 -0
- data/generated/google/apis/groupssettings_v1/representations.rb +64 -0
- data/generated/google/apis/groupssettings_v1/service.rb +179 -0
- data/generated/google/apis/identitytoolkit_v3.rb +31 -0
- data/generated/google/apis/identitytoolkit_v3/classes.rb +1229 -0
- data/generated/google/apis/identitytoolkit_v3/representations.rb +422 -0
- data/generated/google/apis/identitytoolkit_v3/service.rb +491 -0
- data/generated/google/apis/licensing_v1.rb +34 -0
- data/generated/google/apis/licensing_v1/classes.rb +132 -0
- data/generated/google/apis/licensing_v1/representations.rb +68 -0
- data/generated/google/apis/licensing_v1/service.rb +376 -0
- data/generated/google/apis/logging_v1beta3.rb +35 -0
- data/generated/google/apis/logging_v1beta3/classes.rb +505 -0
- data/generated/google/apis/logging_v1beta3/representations.rb +222 -0
- data/generated/google/apis/logging_v1beta3/service.rb +670 -0
- data/generated/google/apis/manager_v1beta2.rb +50 -0
- data/generated/google/apis/manager_v1beta2/classes.rb +1287 -0
- data/generated/google/apis/manager_v1beta2/representations.rb +536 -0
- data/generated/google/apis/manager_v1beta2/service.rb +380 -0
- data/generated/google/apis/mapsengine_v1.rb +38 -0
- data/generated/google/apis/mapsengine_v1/classes.rb +2873 -0
- data/generated/google/apis/mapsengine_v1/representations.rb +1235 -0
- data/generated/google/apis/mapsengine_v1/service.rb +3465 -0
- data/generated/google/apis/mirror_v1.rb +37 -0
- data/generated/google/apis/mirror_v1/classes.rb +1072 -0
- data/generated/google/apis/mirror_v1/representations.rb +350 -0
- data/generated/google/apis/mirror_v1/service.rb +1001 -0
- data/generated/google/apis/oauth2_v2.rb +43 -0
- data/generated/google/apis/oauth2_v2/classes.rb +245 -0
- data/generated/google/apis/oauth2_v2/representations.rb +94 -0
- data/generated/google/apis/oauth2_v2/service.rb +203 -0
- data/generated/google/apis/pagespeedonline_v2.rb +32 -0
- data/generated/google/apis/pagespeedonline_v2/classes.rb +614 -0
- data/generated/google/apis/pagespeedonline_v2/representations.rb +244 -0
- data/generated/google/apis/pagespeedonline_v2/service.rb +120 -0
- data/generated/google/apis/plus_domains_v1.rb +61 -0
- data/generated/google/apis/plus_domains_v1/classes.rb +2402 -0
- data/generated/google/apis/plus_domains_v1/representations.rb +873 -0
- data/generated/google/apis/plus_domains_v1/service.rb +924 -0
- data/generated/google/apis/plus_v1.rb +43 -0
- data/generated/google/apis/plus_v1/classes.rb +2384 -0
- data/generated/google/apis/plus_v1/representations.rb +812 -0
- data/generated/google/apis/plus_v1/service.rb +616 -0
- data/generated/google/apis/prediction_v1_6.rb +44 -0
- data/generated/google/apis/prediction_v1_6/classes.rb +751 -0
- data/generated/google/apis/prediction_v1_6/representations.rb +327 -0
- data/generated/google/apis/prediction_v1_6/service.rb +388 -0
- data/generated/google/apis/pubsub_v1beta2.rb +37 -0
- data/generated/google/apis/pubsub_v1beta2/classes.rb +824 -0
- data/generated/google/apis/pubsub_v1beta2/representations.rb +366 -0
- data/generated/google/apis/pubsub_v1beta2/service.rb +778 -0
- data/generated/google/apis/qpx_express_v1.rb +31 -0
- data/generated/google/apis/qpx_express_v1/classes.rb +1268 -0
- data/generated/google/apis/qpx_express_v1/representations.rb +424 -0
- data/generated/google/apis/qpx_express_v1/service.rb +101 -0
- data/generated/google/apis/replicapool_v1beta2.rb +41 -0
- data/generated/google/apis/replicapool_v1beta2/classes.rb +621 -0
- data/generated/google/apis/replicapool_v1beta2/representations.rb +235 -0
- data/generated/google/apis/replicapool_v1beta2/service.rb +620 -0
- data/generated/google/apis/replicapoolupdater_v1beta1.rb +41 -0
- data/generated/google/apis/replicapoolupdater_v1beta1/classes.rb +682 -0
- data/generated/google/apis/replicapoolupdater_v1beta1/representations.rb +247 -0
- data/generated/google/apis/replicapoolupdater_v1beta1/service.rb +472 -0
- data/generated/google/apis/reseller_v1.rb +37 -0
- data/generated/google/apis/reseller_v1/classes.rb +502 -0
- data/generated/google/apis/reseller_v1/representations.rb +199 -0
- data/generated/google/apis/reseller_v1/service.rb +637 -0
- data/generated/google/apis/resourceviews_v1beta2.rb +47 -0
- data/generated/google/apis/resourceviews_v1beta2/classes.rb +660 -0
- data/generated/google/apis/resourceviews_v1beta2/representations.rb +269 -0
- data/generated/google/apis/resourceviews_v1beta2/service.rb +574 -0
- data/generated/google/apis/site_verification_v1.rb +37 -0
- data/generated/google/apis/site_verification_v1/classes.rb +185 -0
- data/generated/google/apis/site_verification_v1/representations.rb +101 -0
- data/generated/google/apis/site_verification_v1/service.rb +322 -0
- data/generated/google/apis/sqladmin_v1beta4.rb +37 -0
- data/generated/google/apis/sqladmin_v1beta4/classes.rb +1817 -0
- data/generated/google/apis/sqladmin_v1beta4/representations.rb +688 -0
- data/generated/google/apis/sqladmin_v1beta4/service.rb +1534 -0
- data/generated/google/apis/storage_v1.rb +43 -0
- data/generated/google/apis/storage_v1/classes.rb +1177 -0
- data/generated/google/apis/storage_v1/representations.rb +427 -0
- data/generated/google/apis/storage_v1/service.rb +1920 -0
- data/generated/google/apis/tagmanager_v1.rb +52 -0
- data/generated/google/apis/tagmanager_v1/classes.rb +1226 -0
- data/generated/google/apis/tagmanager_v1/representations.rb +461 -0
- data/generated/google/apis/tagmanager_v1/service.rb +1978 -0
- data/generated/google/apis/taskqueue_v1beta2.rb +37 -0
- data/generated/google/apis/taskqueue_v1beta2/classes.rb +254 -0
- data/generated/google/apis/taskqueue_v1beta2/representations.rb +114 -0
- data/generated/google/apis/taskqueue_v1beta2/service.rb +416 -0
- data/generated/google/apis/tasks_v1.rb +37 -0
- data/generated/google/apis/tasks_v1/classes.rb +296 -0
- data/generated/google/apis/tasks_v1/representations.rb +115 -0
- data/generated/google/apis/tasks_v1/service.rb +657 -0
- data/generated/google/apis/translate_v2.rb +31 -0
- data/generated/google/apis/translate_v2/classes.rb +168 -0
- data/generated/google/apis/translate_v2/representations.rb +109 -0
- data/generated/google/apis/translate_v2/service.rb +185 -0
- data/generated/google/apis/urlshortener_v1.rb +34 -0
- data/generated/google/apis/urlshortener_v1/classes.rb +246 -0
- data/generated/google/apis/urlshortener_v1/representations.rb +111 -0
- data/generated/google/apis/urlshortener_v1/service.rb +179 -0
- data/generated/google/apis/webmasters_v3.rb +37 -0
- data/generated/google/apis/webmasters_v3/classes.rb +563 -0
- data/generated/google/apis/webmasters_v3/representations.rb +250 -0
- data/generated/google/apis/webmasters_v3/service.rb +587 -0
- data/generated/google/apis/youtube_analytics_v1.rb +46 -0
- data/generated/google/apis/youtube_analytics_v1/classes.rb +540 -0
- data/generated/google/apis/youtube_analytics_v1/representations.rb +242 -0
- data/generated/google/apis/youtube_analytics_v1/service.rb +567 -0
- data/generated/google/apis/youtube_v3.rb +49 -0
- data/generated/google/apis/youtube_v3/classes.rb +7225 -0
- data/generated/google/apis/youtube_v3/representations.rb +2529 -0
- data/generated/google/apis/youtube_v3/service.rb +4051 -0
- data/google-api-client.gemspec +27 -39
- data/lib/google/api_client/auth/storage.rb +3 -2
- data/lib/google/api_client/auth/storages/file_store.rb +1 -3
- data/lib/google/api_client/auth/storages/redis_store.rb +6 -2
- data/lib/google/apis.rb +48 -0
- data/lib/google/apis/core/api_command.rb +128 -0
- data/lib/google/apis/core/base_service.rb +314 -0
- data/lib/google/apis/core/batch.rb +222 -0
- data/lib/google/apis/core/download.rb +94 -0
- data/lib/google/apis/core/hashable.rb +44 -0
- data/lib/google/apis/core/http_command.rb +275 -0
- data/lib/google/apis/core/json_representation.rb +122 -0
- data/lib/google/{api_client/version.rb → apis/core/logging.rb} +12 -8
- data/lib/google/apis/core/multipart.rb +173 -0
- data/lib/google/apis/core/upload.rb +275 -0
- data/lib/google/{api_client → apis}/errors.rb +32 -28
- data/lib/google/apis/generator.rb +70 -0
- data/lib/google/apis/generator/annotator.rb +271 -0
- data/lib/google/apis/generator/helpers.rb +74 -0
- data/lib/google/apis/generator/model.rb +130 -0
- data/lib/google/apis/generator/template.rb +124 -0
- data/lib/google/apis/generator/templates/_class.tmpl +40 -0
- data/lib/google/apis/generator/templates/_method.tmpl +90 -0
- data/lib/google/apis/generator/templates/_representation.tmpl +51 -0
- data/lib/google/apis/generator/templates/_representation_stub.tmpl +15 -0
- data/lib/google/apis/generator/templates/_representation_type.tmpl +10 -0
- data/lib/google/{api_client/reference.rb → apis/generator/templates/classes.rb.tmpl} +11 -9
- data/lib/google/apis/generator/templates/module.rb.tmpl +40 -0
- data/lib/google/apis/generator/templates/representations.rb.tmpl +32 -0
- data/lib/google/apis/generator/templates/service.rb.tmpl +60 -0
- data/lib/google/apis/options.rb +79 -0
- data/lib/google/apis/version.rb +39 -0
- data/rakelib/metrics.rake +22 -0
- data/rakelib/rubocop.rake +10 -0
- data/rakelib/spec.rake +11 -0
- data/rakelib/yard.rake +11 -0
- data/samples/calendar/calendar.rb +43 -0
- data/samples/drive/drive.rb +40 -0
- data/samples/pubsub/pubsub.rb +52 -0
- data/{lib/google/api_client/discovery.rb → samples/translate/translate.rb} +14 -5
- data/script/generate +79 -0
- data/script/package +8 -0
- data/script/release +15 -0
- data/spec/fixtures/files/api_names.yaml +3 -0
- data/spec/fixtures/files/auth_stored_credentials.json +8 -0
- data/spec/fixtures/files/client_secrets.json +1 -0
- data/spec/fixtures/files/test.blah +1 -0
- data/spec/fixtures/files/test.txt +1 -0
- data/spec/fixtures/files/test_api.json +440 -0
- data/spec/google/api_client/auth/storage_spec.rb +1 -3
- data/spec/google/api_client/auth/storages/file_store_spec.rb +1 -2
- data/spec/google/api_client/auth/storages/redis_store_spec.rb +1 -3
- data/spec/google/apis/core/api_command_spec.rb +170 -0
- data/spec/google/apis/core/batch_spec.rb +128 -0
- data/spec/google/apis/core/download_spec.rb +90 -0
- data/spec/google/apis/core/hashable_spec.rb +60 -0
- data/spec/google/apis/core/http_command_spec.rb +238 -0
- data/spec/google/apis/core/json_representation_spec.rb +192 -0
- data/spec/google/apis/core/service_spec.rb +247 -0
- data/spec/google/apis/core/upload_spec.rb +238 -0
- data/{lib/google/api_client/service_account.rb → spec/google/apis/generated_spec.rb} +14 -8
- data/spec/google/apis/generator/generator_spec.rb +272 -0
- data/spec/google/apis/logging_spec.rb +45 -0
- data/spec/google/apis/options_spec.rb +40 -0
- data/spec/integration_tests/drive_spec.rb +35 -0
- data/spec/integration_tests/pubsub_spec.rb +48 -0
- data/spec/integration_tests/url_shortener_spec.rb +31 -0
- data/spec/spec_helper.rb +102 -46
- metadata +433 -178
- data/lib/compat/multi_json.rb +0 -19
- data/lib/google/api_client.rb +0 -750
- data/lib/google/api_client/auth/file_storage.rb +0 -59
- data/lib/google/api_client/auth/jwt_asserter.rb +0 -126
- data/lib/google/api_client/auth/key_utils.rb +0 -93
- data/lib/google/api_client/auth/pkcs12.rb +0 -41
- data/lib/google/api_client/batch.rb +0 -326
- data/lib/google/api_client/charset.rb +0 -33
- data/lib/google/api_client/discovery/api.rb +0 -310
- data/lib/google/api_client/discovery/media.rb +0 -77
- data/lib/google/api_client/discovery/method.rb +0 -363
- data/lib/google/api_client/discovery/resource.rb +0 -156
- data/lib/google/api_client/discovery/schema.rb +0 -117
- data/lib/google/api_client/environment.rb +0 -42
- data/lib/google/api_client/gzip.rb +0 -28
- data/lib/google/api_client/logging.rb +0 -32
- data/lib/google/api_client/media.rb +0 -259
- data/lib/google/api_client/railtie.rb +0 -18
- data/lib/google/api_client/request.rb +0 -350
- data/lib/google/api_client/result.rb +0 -255
- data/lib/google/api_client/service.rb +0 -233
- data/lib/google/api_client/service/batch.rb +0 -110
- data/lib/google/api_client/service/request.rb +0 -144
- data/lib/google/api_client/service/resource.rb +0 -40
- data/lib/google/api_client/service/result.rb +0 -162
- data/lib/google/api_client/service/simple_file_store.rb +0 -151
- data/lib/google/api_client/service/stub_generator.rb +0 -61
- data/spec/google/api_client/batch_spec.rb +0 -248
- data/spec/google/api_client/discovery_spec.rb +0 -708
- data/spec/google/api_client/gzip_spec.rb +0 -98
- data/spec/google/api_client/media_spec.rb +0 -178
- data/spec/google/api_client/result_spec.rb +0 -207
- data/spec/google/api_client/service_account_spec.rb +0 -169
- data/spec/google/api_client/service_spec.rb +0 -618
- data/spec/google/api_client/simple_file_store_spec.rb +0 -133
- data/spec/google/api_client_spec.rb +0 -352
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 028a4cc7ea1dd004a24511d10bbc5f57901ab4c6
|
4
|
+
data.tar.gz: 3a2a4c1b22ddf53624736bd96c6be999798bb8b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8195661fd5d8a642b7cee3296228ff82f460ad775e7c1432a7503fb9260f7ee60ecf2229d7a18111b977b3d9df1666f1693ed90842521dfde26a2cb7c4a82134
|
7
|
+
data.tar.gz: cc0a433396c213916086f277f1612c64755d19a0e40d91a669d175a5278e04cd8674730e9e5fb44873b85324965bedbe64fdfd639313a19b080f168eea6982e1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2015-03-25 23:30:36 -0700 using RuboCop version 0.29.1.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
# Offense count: 19
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Max: 79
|
11
|
+
|
12
|
+
# Offense count: 2
|
13
|
+
# Configuration parameters: CountComments.
|
14
|
+
Metrics/ClassLength:
|
15
|
+
Max: 220
|
16
|
+
|
17
|
+
# Offense count: 5
|
18
|
+
Metrics/CyclomaticComplexity:
|
19
|
+
Max: 10
|
20
|
+
|
21
|
+
# Offense count: 99
|
22
|
+
# Configuration parameters: AllowURI, URISchemes.
|
23
|
+
Metrics/LineLength:
|
24
|
+
Max: 127
|
25
|
+
|
26
|
+
# Offense count: 18
|
27
|
+
# Configuration parameters: CountComments.
|
28
|
+
Metrics/MethodLength:
|
29
|
+
Max: 43
|
30
|
+
|
31
|
+
# Offense count: 1
|
32
|
+
# Configuration parameters: CountKeywordArgs.
|
33
|
+
Metrics/ParameterLists:
|
34
|
+
Max: 6
|
35
|
+
|
36
|
+
# Offense count: 4
|
37
|
+
Metrics/PerceivedComplexity:
|
38
|
+
Max: 11
|
39
|
+
|
40
|
+
# Offense count: 14
|
41
|
+
Style/Documentation:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
# Offense count: 1
|
45
|
+
# Cop supports --auto-correct.
|
46
|
+
Style/EmptyLines:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
# Offense count: 3
|
50
|
+
# Cop supports --auto-correct.
|
51
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
52
|
+
Style/EmptyLinesAroundClassBody:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
# Offense count: 2
|
56
|
+
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
|
57
|
+
Style/Next:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
# Offense count: 3
|
61
|
+
# Cop supports --auto-correct.
|
62
|
+
Style/RedundantSelf:
|
63
|
+
Enabled: false
|
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.2
|
4
|
+
- 2.0.0
|
5
|
+
- 2.1
|
6
|
+
- jruby-9000
|
7
|
+
env:
|
8
|
+
- RAILS_VERSION="~>3.2"
|
9
|
+
- RAILS_VERSION="~>4.0.0"
|
10
|
+
- RAILS_VERSION="~>4.1.0"
|
11
|
+
- RAILS_VERSION="~>4.2.0"
|
12
|
+
script: "rake spec:all"
|
13
|
+
before_install:
|
14
|
+
- sudo apt-get update
|
15
|
+
- sudo apt-get install idn
|
16
|
+
notifications:
|
17
|
+
email:
|
18
|
+
recipients:
|
19
|
+
- sbazyl@google.com
|
20
|
+
on_success: change
|
21
|
+
on_failure: change
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
-
# 0.
|
2
|
-
*
|
1
|
+
# 0.9.0.pre1
|
2
|
+
* WARNING: Please see [MIGRATING](MIGRATING.md) for important information.
|
3
|
+
* API classes are now generated ahead of time instead of at runtime.
|
4
|
+
* Drop support for Ruby versions < 2.0
|
5
|
+
* Switch from Faraday to Hurley for HTTP client
|
3
6
|
|
4
7
|
# 0.8.6
|
5
8
|
* Use discovered 'rootUrl' as base URI for services
|
@@ -30,7 +33,7 @@
|
|
30
33
|
* Batch requests with the service interface now inherit the service's connection
|
31
34
|
* `register_discover_document` now returns the API instance
|
32
35
|
* Added `:proxy` option to set Faraday's HTTP proxy setting
|
33
|
-
* Added `:
|
36
|
+
* Added `:faraday_option` option to allow passthrough settings to Faraday connection
|
34
37
|
* Drop 1.8.x support
|
35
38
|
* This will be the last release with 1.9.x support
|
36
39
|
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# How to become a contributor and submit your own code
|
2
|
+
|
3
|
+
## Contributor License Agreements
|
4
|
+
|
5
|
+
We'd love to accept your sample apps and patches! Before we can take them, we
|
6
|
+
have to jump a couple of legal hurdles.
|
7
|
+
|
8
|
+
Please fill out either the individual or corporate Contributor License Agreement
|
9
|
+
(CLA).
|
10
|
+
|
11
|
+
* If you are an individual writing original source code and you're sure you
|
12
|
+
own the intellectual property, then you'll need to sign an [individual CLA]
|
13
|
+
(http://code.google.com/legal/individual-cla-v1.0.html).
|
14
|
+
* If you work for a company that wants to allow you to contribute your work,
|
15
|
+
then you'll need to sign a [corporate CLA]
|
16
|
+
(http://code.google.com/legal/corporate-cla-v1.0.html).
|
17
|
+
|
18
|
+
Follow either of the two links above to access the appropriate CLA and
|
19
|
+
instructions for how to sign and return it. Once we receive it, we'll be able to
|
20
|
+
accept your pull requests.
|
21
|
+
|
22
|
+
## Contributing A Patch
|
23
|
+
|
24
|
+
1. Submit an issue describing your proposed change to the repo in question.
|
25
|
+
1. The repo owner will respond to your issue promptly.
|
26
|
+
1. If your proposed change is accepted, and you haven't already done so, sign a
|
27
|
+
Contributor License Agreement (see details above).
|
28
|
+
1. Fork the desired repo, develop and test your code changes.
|
29
|
+
1. Ensure that your code is clear and comprehensible.
|
30
|
+
1. Ensure that your code has an appropriate set of unit tests which all pass.
|
31
|
+
1. Submit a pull request.
|
data/Gemfile
CHANGED
@@ -1,9 +1,35 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
+
# Specify your gem's dependencies in google-apis.gemspec
|
3
4
|
gemspec
|
4
5
|
|
5
|
-
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'bundler', '~> 1.7'
|
9
|
+
gem 'rake', '~> 10.0'
|
10
|
+
gem 'rspec', '~> 3.1'
|
11
|
+
gem 'json_spec', '~> 1.1'
|
12
|
+
gem 'webmock', '~> 1.21'
|
13
|
+
gem 'simplecov', '~> 0.9'
|
14
|
+
gem 'coveralls', '~> 0.7.11'
|
15
|
+
gem 'rubocop', '~> 0.29'
|
16
|
+
gem 'launchy', '~> 2.4'
|
17
|
+
end
|
18
|
+
|
19
|
+
platforms :jruby do
|
20
|
+
group :development do
|
21
|
+
gem 'jruby-openssl'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
platforms :ruby do
|
26
|
+
group :development do
|
27
|
+
gem 'yard', '~> 0.8'
|
28
|
+
gem 'redcarpet', '~> 3.2'
|
29
|
+
gem 'github-markup', '~> 1.3'
|
30
|
+
end
|
31
|
+
end
|
6
32
|
|
7
33
|
if ENV['RAILS_VERSION']
|
8
34
|
gem 'rails', ENV['RAILS_VERSION']
|
9
|
-
end
|
35
|
+
end
|
data/MIGRATING.md
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
# Migrating from version `0.8.x` to `0.9`
|
2
|
+
|
3
|
+
Many changes and improvements have been made to the `google-api-ruby-client`
|
4
|
+
library to bring it to `0.9`. If you are starting a new project or haven't used
|
5
|
+
this library before version `0.9`, see the [README][readme] to get started
|
6
|
+
as you won't need to migrate anything.
|
7
|
+
|
8
|
+
Code written against the `0.8.x` version of this library will not work with the `0.9`
|
9
|
+
version without modification.
|
10
|
+
|
11
|
+
## Discovery
|
12
|
+
|
13
|
+
In `0.8.x` the library would "discover" APIs on the fly, introducing
|
14
|
+
additional network calls and instability. That has been fixed in `0.9`.
|
15
|
+
|
16
|
+
To get the `drive` client in `0.8.x` required this:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
require 'google/api_client'
|
20
|
+
|
21
|
+
client = Google::APIClient.new
|
22
|
+
drive = client.discovered_api('drive', 'v2')
|
23
|
+
```
|
24
|
+
|
25
|
+
In `0.9` the same thing can be accomplished like this:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'google/apis/drive_v2'
|
29
|
+
|
30
|
+
drive = Google::Apis::DriveV2::DriveService.new
|
31
|
+
```
|
32
|
+
|
33
|
+
All APIs are immediately accessible without requiring additional network calls or runtime code generation.
|
34
|
+
|
35
|
+
## API Methods
|
36
|
+
|
37
|
+
The calling style for API methods has changed. In `0.8.x` all calls were via a generic `execute` method. In `0.9`
|
38
|
+
the generated services have fully defined method signatures for all available methods.
|
39
|
+
|
40
|
+
To get a file using the Google Drive API in `0.8.x` required this:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
file = client.execute(:api_method => drive.file.get, :parameters => { 'id' => 'abc123' })
|
44
|
+
```
|
45
|
+
|
46
|
+
In `0.9` the same thing can be accomplished like this:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
file = drive.get_file('abc123')
|
50
|
+
```
|
51
|
+
|
52
|
+
Full API definitions including available methods, parameters, and data classes can be found in the `generated` directory.
|
53
|
+
|
54
|
+
## Authorization
|
55
|
+
|
56
|
+
In the 0.9 version of this library, the authentication and authorization code was moved
|
57
|
+
to the new [googleauth](https://github.com/google/google-auth-library-ruby) library. While the new library provides
|
58
|
+
significantly simpler APIs for some use cases, not all features have been migrated. Missing features
|
59
|
+
are expected to be added by end of Q2 2015.
|
60
|
+
|
61
|
+
The underlying [Signet](https://github.com/google/signet) is still used for authorization. OAuth 2 credentials obtained
|
62
|
+
previously will continue to work with the `0.9` version. OAuth 1 is no longer supported.
|
63
|
+
|
64
|
+
## Media uploads
|
65
|
+
|
66
|
+
Media uploads are significantly simpler in `0.9`.
|
67
|
+
|
68
|
+
The old `0.8.x` way of uploading media:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
media = Google::APIClient::UploadIO.new('mymovie.m4v', 'video/mp4')
|
72
|
+
metadata = {
|
73
|
+
'title' => 'My movie',
|
74
|
+
'description' => 'The best home movie ever made'
|
75
|
+
}
|
76
|
+
client.execute(:api_method => drive.files.insert,
|
77
|
+
:parameters => { 'uploadType' => 'multipart' },
|
78
|
+
:body_object => metadata,
|
79
|
+
:media => media )
|
80
|
+
```
|
81
|
+
|
82
|
+
The new way in `0.9` using `upload_source` and `content_type` parameters:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
metadata = {
|
86
|
+
title: 'My movie',
|
87
|
+
description: 'The best home movie ever made'
|
88
|
+
}
|
89
|
+
drive.insert_file(metadata, upload_source: 'mymovie.m4v', content_type: 'video/mp4')
|
90
|
+
```
|
91
|
+
|
92
|
+
`upload_source` can be either a path to a file, an `IO` stream, or a `StringIO` instance.
|
93
|
+
|
94
|
+
Uploads are resumable and will be automatically retried if interrupted.
|
95
|
+
|
96
|
+
## Media downloads
|
97
|
+
|
98
|
+
`0.9` introduces support for media downloads (`alt=media`). To download content, use the `download_dest` parameter:
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
drive.get_file('abc123', download_dest: '/tmp/myfile.txt')
|
102
|
+
```
|
103
|
+
|
104
|
+
`download_dest` may be either a path to a file or an `IO` stream.
|
105
|
+
|
106
|
+
## Batch Requests
|
107
|
+
|
108
|
+
The old `0.8.x` way of performing batch requests:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
client = Google::APIClient.new
|
112
|
+
urlshortener = client.discovered_api('urlshortener')
|
113
|
+
|
114
|
+
batch = Google::APIClient::BatchRequest.new do |result|
|
115
|
+
puts result.data
|
116
|
+
end
|
117
|
+
|
118
|
+
batch.add(:api_method => urlshortener.url.insert,
|
119
|
+
:body_object => { 'longUrl' => 'http://example.com/foo' })
|
120
|
+
batch.add(:api_method => urlshortener.url.insert,
|
121
|
+
:body_object => { 'longUrl' => 'http://example.com/bar' })
|
122
|
+
client.execute(batch)
|
123
|
+
```
|
124
|
+
|
125
|
+
In `0.9`, the equivalent code is:
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
require 'google/apis/urlshortner_v1'
|
129
|
+
|
130
|
+
urlshortener = Google::Apis::UrlshortenerV1::UrlshortenerService.new
|
131
|
+
|
132
|
+
urlshortener.batch do |urlshortener|
|
133
|
+
urlshortner.insert_url({long_url: 'http://example.com/foo'}) do |res, err|
|
134
|
+
puts res
|
135
|
+
end
|
136
|
+
urlshortner.insert_url({long_url: 'http://example.com/bar'}) do |res, err|
|
137
|
+
puts res
|
138
|
+
end
|
139
|
+
end
|
140
|
+
```
|
141
|
+
|
142
|
+
Or if sharing the same block:
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
require 'google/apis/urlshortner_v1'
|
146
|
+
|
147
|
+
urlshortener = Google::Apis::UrlshortenerV1::UrlshortenerService.new
|
148
|
+
|
149
|
+
callback = lambda { |res, err| puts res }
|
150
|
+
urlshortener.batch do |urlshortener|
|
151
|
+
urlshortner.insert_url({long_url: 'http://example.com/foo'}, &callback)
|
152
|
+
urlshortner.insert_url({long_url: 'http://example.com/bar'}, &callback)
|
153
|
+
end
|
154
|
+
```
|
155
|
+
|
156
|
+
## JRuby
|
157
|
+
|
158
|
+
Jruby 1.7.4 in 2.0 compatibility mode is supported. To enable for a specific script:
|
159
|
+
|
160
|
+
```
|
161
|
+
jruby --2.0 myscript.rb
|
162
|
+
```
|
163
|
+
|
164
|
+
Or set as the default:
|
165
|
+
|
166
|
+
```
|
167
|
+
export JRUBY_OPTS=--2.0
|
168
|
+
```
|
169
|
+
|
170
|
+
JRuby 9000 will be supported once released.
|
171
|
+
|
data/README.md
CHANGED
@@ -1,218 +1,226 @@
|
|
1
1
|
# Google API Client
|
2
2
|
|
3
|
-
|
4
|
-
<dt>Homepage</dt><dd><a href="http://www.github.com/google/google-api-ruby-client">http://www.github.com/google/google-api-ruby-client</a></dd>
|
5
|
-
<dt>Authors</dt><dd>Bob Aman, <a href="mailto:sbazyl@google.com">Steven Bazyl</a></dd>
|
6
|
-
<dt>Copyright</dt><dd>Copyright © 2011 Google, Inc.</dd>
|
7
|
-
<dt>License</dt><dd>Apache 2.0</dd>
|
8
|
-
</dl>
|
3
|
+
## Alpha
|
9
4
|
|
10
|
-
|
11
|
-
|
5
|
+
This library is in Alpha. We will make an effort to support the library, but we reserve the right to make incompatible
|
6
|
+
changes when necessary.
|
12
7
|
|
13
|
-
##
|
8
|
+
## Migrating from 0.8.x
|
14
9
|
|
15
|
-
|
16
|
-
|
10
|
+
Version 0.9 is not compatible with previous versions. See [MIGRATING](MIGRATING.md) for additional details on how to
|
11
|
+
migrate to the latest version.
|
17
12
|
|
18
|
-
##
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
19
16
|
|
20
|
-
|
17
|
+
```ruby
|
18
|
+
gem 'google-api-client'
|
19
|
+
```
|
21
20
|
|
22
|
-
|
21
|
+
And then execute:
|
23
22
|
|
24
|
-
|
23
|
+
$ bundle
|
25
24
|
|
26
|
-
|
25
|
+
Or install it yourself as:
|
27
26
|
|
28
|
-
|
29
|
-
$ gem install google-api-client
|
30
|
-
```
|
27
|
+
$ gem install google-api-client
|
31
28
|
|
32
|
-
##
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
### Basic usage
|
32
|
+
|
33
|
+
To use an API, include the corresponding generated file and instantiate the service. For example to use the Drive API:
|
33
34
|
|
34
35
|
```ruby
|
35
|
-
require 'google/
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
#
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
#
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
# Run installed application flow. Check the samples for a more
|
54
|
-
# complete example that saves the credentials between runs.
|
55
|
-
flow = Google::APIClient::InstalledAppFlow.new(
|
56
|
-
:client_id => client_secrets.client_id,
|
57
|
-
:client_secret => client_secrets.client_secret,
|
58
|
-
:scope => ['https://www.googleapis.com/auth/plus.me']
|
59
|
-
)
|
60
|
-
client.authorization = flow.authorize
|
61
|
-
|
62
|
-
# Make an API call.
|
63
|
-
result = client.execute(
|
64
|
-
:api_method => plus.activities.list,
|
65
|
-
:parameters => {'collection' => 'public', 'userId' => 'me'}
|
66
|
-
)
|
67
|
-
|
68
|
-
puts result.data
|
36
|
+
require 'google/apis/drive_v2'
|
37
|
+
|
38
|
+
Drive = Google::Apis::DriveV2 # Alias the module
|
39
|
+
drive = Drive::DriveService.new
|
40
|
+
drive.authorization = authorization # See Googleauth or Signet libraries
|
41
|
+
|
42
|
+
# Search for files in Drive (first page only)
|
43
|
+
files = drive.list_files(q: "title contains 'finances'")
|
44
|
+
files.items.each do |file|
|
45
|
+
puts file.title
|
46
|
+
end
|
47
|
+
|
48
|
+
# Upload a file
|
49
|
+
metadata = Drive::File.new(title: 'My document')
|
50
|
+
metadata = drive.insert_file(metadata, upload_source: 'test.txt', content_type: 'text/plain')
|
51
|
+
|
52
|
+
# Download a file
|
53
|
+
drive.get_file(metadata.id, download_dest: '/tmp/myfile.txt')
|
69
54
|
```
|
70
55
|
|
71
|
-
|
56
|
+
### Media
|
57
|
+
|
58
|
+
Methods that allow media operations have additional parameters to specify the upload source or download destination.
|
59
|
+
|
60
|
+
For uploads, the `upload_source` parameter can be specified with either a path to a file, an `IO` stream, or `StringIO`
|
61
|
+
instance.
|
62
|
+
|
63
|
+
For downloads, the `download_dest` parameter can also be either a path to a file, an `IO` stream, or `StringIO` instance.
|
64
|
+
|
65
|
+
Both uploads & downloads are resumable. If an error occurs during transmission the request will be automatically
|
66
|
+
retried from the last received byte.
|
72
67
|
|
73
|
-
###
|
68
|
+
### Errors & Retries
|
74
69
|
|
75
|
-
|
70
|
+
Retries are disabled by default, but enabling retries is strongly encouraged. The number of retries can be configured
|
71
|
+
via `Google::Apis::RequestOptions`. Any number greater than 0 will enable retries.
|
72
|
+
|
73
|
+
To enable retries for all services:
|
76
74
|
|
77
75
|
```ruby
|
78
|
-
|
76
|
+
Google::Apis::RequestOptions.default.retries = 5
|
79
77
|
```
|
80
78
|
|
81
|
-
|
79
|
+
With retries enabled globally, retries can be disabled for specific calls by including a retry value of 0 in the
|
80
|
+
request options:
|
82
81
|
|
83
82
|
```ruby
|
84
|
-
drive
|
83
|
+
drive.insert_file(metadata, upload_source: 'test.txt', content_type: 'text/plain', options: { retries: 0 })
|
85
84
|
```
|
86
85
|
|
87
|
-
|
86
|
+
When retries are enabled, if a server or rate limit error occurs during a request it is automatically retried with
|
87
|
+
an exponentially increasing delay on subsequent retries. If a request can not be retried or if the maximum number
|
88
|
+
of retries is exceeded, an exception is thrown.
|
88
89
|
|
89
|
-
|
90
|
-
|
91
|
-
|
90
|
+
### Callbacks
|
91
|
+
|
92
|
+
A block an be specified when making calls. If present, the block will be called with the result or error, rather than
|
93
|
+
returning the result from the call or raising the error. Example:
|
92
94
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
95
|
+
```ruby
|
96
|
+
# Search for files in Drive (first page only)
|
97
|
+
drive.list_files(q: "title contains 'finances'") do |res, err|
|
98
|
+
if err
|
99
|
+
# Handle error
|
100
|
+
else
|
101
|
+
# Handle response
|
102
|
+
end
|
103
|
+
end
|
97
104
|
```
|
98
105
|
|
99
|
-
|
106
|
+
This calling style is required when making batch requests as responses are not available until the entire batch
|
107
|
+
is complete.
|
100
108
|
|
101
|
-
|
109
|
+
### Batches
|
102
110
|
|
103
|
-
|
111
|
+
Multiple requests can be batched together into a single HTTP request to reduce overhead. Batched calls are executed
|
112
|
+
in parallel and the responses processed once all results are available
|
104
113
|
|
105
|
-
For server-to-server interactions, like those between a web application and Google Cloud Storage, Prediction, or BigQuery APIs, use service accounts.
|
106
114
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
115
|
+
```ruby
|
116
|
+
# Fetch a bunch of files by ID
|
117
|
+
ids = ['file_id_1', 'file_id_2', 'file_id_3', 'file_id_4']
|
118
|
+
drive.batch do |drive|
|
119
|
+
ids.each do |id|
|
120
|
+
drive.get_file(id) do |res, err|
|
121
|
+
# Handle response
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
```
|
126
|
+
|
127
|
+
Media operations -- uploads & downloads -- can not be included in batch with other requests.
|
128
|
+
|
129
|
+
However, some APIs support batch uploads. To upload multiple files in a batch, use the `batch_upload` method instead.
|
130
|
+
Batch uploads should only be used when uploading multiple small files. For large files, upload files individually to
|
131
|
+
take advantage of the libraries built-in reusmable upload support.
|
132
|
+
|
133
|
+
### Hashes
|
134
|
+
|
135
|
+
While the API will always return instances of schema classes, plain hashes are accepted in method calls for
|
136
|
+
convenience. Hash keys must be symbols matching the attribute names on the corresponding object the hash is meant
|
137
|
+
to replace. For example:
|
111
138
|
|
112
139
|
```ruby
|
113
|
-
|
114
|
-
|
115
|
-
client.execute(...)
|
140
|
+
file = {id: '123', title: 'My document', labels: { starred: true }}
|
141
|
+
file = drive.insert_file(file) # Returns a Drive::File instance
|
116
142
|
```
|
117
143
|
|
118
|
-
|
144
|
+
is equivalent to:
|
119
145
|
|
120
146
|
```ruby
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
:audience => 'https://accounts.google.com/o/oauth2/token',
|
125
|
-
:scope => 'https://www.googleapis.com/auth/prediction',
|
126
|
-
:issuer => '123456-abcdef@developer.gserviceaccount.com',
|
127
|
-
:signing_key => key)
|
128
|
-
client.authorization.fetch_access_token!
|
129
|
-
client.execute(...)
|
147
|
+
file = Drive::File.new(id: '123', title: 'My document')
|
148
|
+
file.labels = Drive::File::Labels.new(starred: true)
|
149
|
+
file = drive.update_file(file) # Returns a Drive::File instance
|
130
150
|
```
|
131
151
|
|
132
|
-
|
133
|
-
in the credentials. Detailed instructions on how to enable delegation for your domain can be found at [developers.google.com](https://developers.google.com/drive/delegation).
|
152
|
+
## Authorization
|
134
153
|
|
135
|
-
|
154
|
+
[OAuth 2](https://developers.google.com/accounts/docs/OAuth2) is used to authorize applications. This library uses
|
155
|
+
both [Signet](https://github.com/google/signet) and
|
156
|
+
[Google Auth Library for Ruby](https://github.com/google/google-auth-library-ruby) for OAuth 2 support.
|
136
157
|
|
137
|
-
The
|
138
|
-
|
139
|
-
|
140
|
-
|
158
|
+
The [Google Auth Library for Ruby](https://github.com/google/google-auth-library-ruby) provides an implementation of
|
159
|
+
[application default credentials] for Ruby. It offers a simple way to get authorization credentials for use in
|
160
|
+
calling Google APIs, best suited for cases when the call needs to have the same identity
|
161
|
+
and authorization level for the application independent of the user. This is
|
162
|
+
the recommended approach to authorize calls to Cloud APIs, particularly when
|
163
|
+
you're building an application that uses Google Compute Engine.
|
141
164
|
|
142
|
-
|
165
|
+
For per-user authorization, use [Signet](https://github.com/google/signet) to obtain user authorization.
|
143
166
|
|
144
|
-
###
|
167
|
+
### Passing authorization to requests
|
145
168
|
|
146
|
-
|
147
|
-
to bundle multiple requests together.
|
169
|
+
Authorization can be specified for the entire client, for an individual service instance, or on a per-request basis.
|
148
170
|
|
149
|
-
|
171
|
+
Set authorization for all service:
|
150
172
|
|
151
173
|
```ruby
|
152
|
-
|
153
|
-
|
174
|
+
Google::Apis::RequestOptions.default.authorization = authorization
|
175
|
+
# Services instantiated after this will inherit the authorization
|
176
|
+
```
|
154
177
|
|
155
|
-
|
156
|
-
|
157
|
-
|
178
|
+
On a per-service level:
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
drive = Google::Apis::DriveV2::DriveService.new
|
182
|
+
drive.authorization = authorization
|
158
183
|
|
159
|
-
|
160
|
-
:body_object => { 'longUrl' => 'http://example.com/foo' })
|
161
|
-
batch.add(:api_method => urlshortener.url.insert,
|
162
|
-
:body_object => { 'longUrl' => 'http://example.com/bar' })
|
163
|
-
client.execute(batch)
|
184
|
+
# All requests made with this service will use the same authorization
|
164
185
|
```
|
165
186
|
|
166
|
-
|
187
|
+
Per-request:
|
167
188
|
|
168
189
|
```ruby
|
169
|
-
|
170
|
-
puts result.data
|
171
|
-
end
|
190
|
+
drive.get_file('123', options: { authorization: authorization })
|
172
191
|
```
|
173
192
|
|
174
|
-
|
193
|
+
## Generating APIs
|
175
194
|
|
176
|
-
For
|
177
|
-
|
195
|
+
For [Cloud Endpoints](https://cloud.google.com/endpoints/) or other APIs not included in the gem, ruby code can be
|
196
|
+
generated from the discovery document.
|
178
197
|
|
179
|
-
|
180
|
-
drive = client.discovered_api('drive', 'v2')
|
181
|
-
|
182
|
-
media = Google::APIClient::UploadIO.new('mymovie.m4v', 'video/mp4')
|
183
|
-
metadata = {
|
184
|
-
'title' => 'My movie',
|
185
|
-
'description' => 'The best home movie ever made'
|
186
|
-
}
|
187
|
-
client.execute(:api_method => drive.files.insert,
|
188
|
-
:parameters => { 'uploadType' => 'multipart' },
|
189
|
-
:body_object => metadata,
|
190
|
-
:media => media )
|
191
|
-
```
|
198
|
+
To generate from a local discovery file:
|
192
199
|
|
193
|
-
|
194
|
-
and continue if necessary, check `result.resumable_upload`.
|
200
|
+
$ generate-api gen <outdir> --file=<path>
|
195
201
|
|
196
|
-
|
197
|
-
client.execute(:api_method => drive.files.insert,
|
198
|
-
:parameters => { 'uploadType' => 'resumable' },
|
199
|
-
:body_object => metadata,
|
200
|
-
:media => media )
|
201
|
-
upload = result.resumable_upload
|
202
|
-
|
203
|
-
# Resume if needed
|
204
|
-
if upload.resumable?
|
205
|
-
client.execute(upload)
|
206
|
-
end
|
207
|
-
```
|
202
|
+
A URL can also be specified:
|
208
203
|
|
209
|
-
|
204
|
+
$ generate-api gen <outdir> --url=<url>
|
210
205
|
|
211
|
-
|
206
|
+
## TODO
|
212
207
|
|
208
|
+
* ETag support (if-not-modified)
|
209
|
+
* Auto-paging results (maybe)
|
210
|
+
* Caching
|
211
|
+
* Model validations
|
213
212
|
|
214
|
-
##
|
213
|
+
## License
|
214
|
+
|
215
|
+
This library is licensed under Apache 2.0. Full license text is
|
216
|
+
available in [LICENSE.txt](LICENSE.txt).
|
217
|
+
|
218
|
+
## Contributing
|
215
219
|
|
216
|
-
|
220
|
+
See [CONTRIBUTING](contributing).
|
221
|
+
|
222
|
+
## Support
|
217
223
|
|
218
|
-
[
|
224
|
+
Please [report bugs at the project on Github](https://github.com/google/google-api-ruby-client/issues). Don't
|
225
|
+
hesitate to [ask questions](http://stackoverflow.com/questions/tagged/google-api-ruby-client) about the client or APIs
|
226
|
+
on [StackOverflow](http://stackoverflow.com).
|