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
@@ -0,0 +1,238 @@
|
|
1
|
+
# Copyright 2015 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'spec_helper'
|
16
|
+
require 'google/apis/core/http_command'
|
17
|
+
require 'hurley/test'
|
18
|
+
|
19
|
+
RSpec.describe Google::Apis::Core::HttpCommand do
|
20
|
+
include TestHelpers
|
21
|
+
include_context 'HTTP client'
|
22
|
+
|
23
|
+
context('with credentials') do
|
24
|
+
let(:command) do
|
25
|
+
command = Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
|
26
|
+
command.options.authorization = authorization
|
27
|
+
command
|
28
|
+
end
|
29
|
+
|
30
|
+
context('that are refreshable') do
|
31
|
+
let(:authorization) do
|
32
|
+
calls = 0
|
33
|
+
auth = object_double(Signet::OAuth2::Client.new)
|
34
|
+
allow(auth).to receive(:apply!) do |header|
|
35
|
+
header['Authorization'] = sprintf('Bearer a_token_value_%d', calls)
|
36
|
+
calls += 1
|
37
|
+
end
|
38
|
+
auth
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should send credentials' do
|
42
|
+
stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_return(body: %(Hello world))
|
43
|
+
result = command.execute(client)
|
44
|
+
expect(a_request(:get, 'https://www.googleapis.com/zoo/animals')
|
45
|
+
.with { |req| req.headers['Authorization'] == 'Bearer a_token_value_0' }).to have_been_made
|
46
|
+
end
|
47
|
+
|
48
|
+
context('with authorizaton error') do
|
49
|
+
before(:example) do
|
50
|
+
stub_request(:get, 'https://www.googleapis.com/zoo/animals')
|
51
|
+
.to_return(status: [401, 'Unauthorized'])
|
52
|
+
.to_return(body: %(Hello world))
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should refresh if auth error received' do
|
56
|
+
result = command.execute(client)
|
57
|
+
expect(a_request(:get, 'https://www.googleapis.com/zoo/animals')
|
58
|
+
.with { |req| req.headers['Authorization'] == 'Bearer a_token_value_1' }).to have_been_made
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should ignore retry count' do
|
62
|
+
command.options.retries = 0
|
63
|
+
result = command.execute(client)
|
64
|
+
expect(a_request(:get, 'https://www.googleapis.com/zoo/animals')
|
65
|
+
.with { |req| req.headers['Authorization'] == 'Bearer a_token_value_1' }).to have_been_made
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context('that are bare tokens`') do
|
71
|
+
let(:authorization) { 'a_token_value' }
|
72
|
+
|
73
|
+
it 'should send credentials' do
|
74
|
+
stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_return(body: %(Hello world))
|
75
|
+
result = command.execute(client)
|
76
|
+
expect(a_request(:get, 'https://www.googleapis.com/zoo/animals')
|
77
|
+
.with { |req| expect(req.headers['Authorization']).to eql 'Bearer a_token_value' }).to have_been_made
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should send not refresh' do
|
81
|
+
stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_return(status: [401, 'Unauthorized'])
|
82
|
+
expect { command.execute(client) }.to raise_error(Google::Apis::AuthorizationError)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context('with a successful response') do
|
88
|
+
let(:command) do
|
89
|
+
Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
|
90
|
+
end
|
91
|
+
|
92
|
+
before(:example) do
|
93
|
+
stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_return(body: %(Hello world))
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should return the response body if block not present' do
|
97
|
+
result = command.execute(client)
|
98
|
+
expect(result).to eql 'Hello world'
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should call block if present' do
|
102
|
+
expect { |b| command.execute(client, &b) }.to yield_with_args('Hello world', nil)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context('with server errors') do
|
107
|
+
let(:command) do
|
108
|
+
Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
|
109
|
+
end
|
110
|
+
|
111
|
+
before(:example) do
|
112
|
+
stub_request(:get, 'https://www.googleapis.com/zoo/animals')
|
113
|
+
.to_return(status: [500, 'Server error']).times(2)
|
114
|
+
.to_return(body: %(Hello world))
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should return the response body' do
|
118
|
+
result = command.execute(client)
|
119
|
+
expect(result).to eql 'Hello world'
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should raise error if retries exceeded' do
|
123
|
+
command.options.retries = 1
|
124
|
+
expect { command.execute(client) }.to raise_error(Google::Apis::ServerError)
|
125
|
+
end
|
126
|
+
|
127
|
+
context('with callbacks') do
|
128
|
+
it 'should return the response body after retries' do
|
129
|
+
expect { |b| command.execute(client, &b) }.to yield_successive_args(
|
130
|
+
[nil, an_instance_of(Google::Apis::ServerError)],
|
131
|
+
[nil, an_instance_of(Google::Apis::ServerError)],
|
132
|
+
['Hello world', nil])
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context('with options') do
|
138
|
+
let(:command) do
|
139
|
+
command = Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
|
140
|
+
command.options.header = { 'X-Foo' => 'bar' }
|
141
|
+
command
|
142
|
+
end
|
143
|
+
|
144
|
+
before(:example) do
|
145
|
+
stub_request(:get, 'https://www.googleapis.com/zoo/animals')
|
146
|
+
.to_return(body: %(Hello world))
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should send user headers' do
|
150
|
+
result = command.execute(client)
|
151
|
+
expect(a_request(:get, 'https://www.googleapis.com/zoo/animals')
|
152
|
+
.with { |req| req.headers['X-Foo'] == 'bar' }).to have_been_made
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
context('with redirects') do
|
158
|
+
let(:command) do
|
159
|
+
Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
|
160
|
+
end
|
161
|
+
|
162
|
+
before(:example) do
|
163
|
+
stub_request(:get, 'https://www.googleapis.com/zoo/animals')
|
164
|
+
.to_return(status: [302, 'Redirect'], headers: { 'Location' => 'https://zoo.googleapis.com/animals' })
|
165
|
+
stub_request(:get, 'https://zoo.googleapis.com/animals')
|
166
|
+
.to_return(body: %(Hello world))
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should return the response body' do
|
170
|
+
result = command.execute(client)
|
171
|
+
expect(result).to eql 'Hello world'
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context('with too many redirects') do
|
176
|
+
let(:command) do
|
177
|
+
Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
|
178
|
+
end
|
179
|
+
|
180
|
+
before(:example) do
|
181
|
+
stub_request(:get, 'https://www.googleapis.com/zoo/animals')
|
182
|
+
.to_return(status: [302, 'Redirect'], headers: { 'Location' => 'https://www.googleapis.com/zoo/animals' }).times(6)
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should raise error if retries exceeded' do
|
186
|
+
expect { command.execute(client) }.to raise_error(Google::Apis::RedirectError)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
context('with no server response') do
|
191
|
+
let(:command) do
|
192
|
+
Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
|
193
|
+
end
|
194
|
+
|
195
|
+
before(:example) do
|
196
|
+
stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_timeout
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'should raise transmission error' do
|
200
|
+
expect { command.execute(client) }.to raise_error(Google::Apis::TransmissionError)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
context('with invalid status code') do
|
205
|
+
let(:command) do
|
206
|
+
Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
|
207
|
+
end
|
208
|
+
|
209
|
+
before(:example) do
|
210
|
+
stub_request(:get, 'https://www.googleapis.com/zoo/animals')
|
211
|
+
.to_return(status: [0, 'Wat!?'])
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'should raise transmission error' do
|
215
|
+
expect { command.execute(client) }.to raise_error(Google::Apis::TransmissionError)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
context('with client errors') do
|
220
|
+
let(:command) do
|
221
|
+
Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
|
222
|
+
end
|
223
|
+
|
224
|
+
before(:example) do
|
225
|
+
stub_request(:get, 'https://www.googleapis.com/zoo/animals')
|
226
|
+
.to_return(status: [400, 'Invalid request'])
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'should raise error without retry' do
|
230
|
+
command.options.retries = 1
|
231
|
+
expect { command.execute(client) }.to raise_error(Google::Apis::ClientError)
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'should call block if present' do
|
235
|
+
expect { |b| command.execute(client, &b) }.to yield_with_args(nil, an_instance_of(Google::Apis::ClientError))
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
# Copyright 2015 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'spec_helper'
|
16
|
+
require 'google/apis/core/json_representation'
|
17
|
+
|
18
|
+
RSpec.describe Google::Apis::Core::JsonRepresentation do
|
19
|
+
let(:child_class) do
|
20
|
+
Class.new do
|
21
|
+
attr_accessor :value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:model_class) do
|
26
|
+
Class.new do
|
27
|
+
attr_accessor :unset_value
|
28
|
+
attr_accessor :nil_value
|
29
|
+
attr_accessor :numeric_value
|
30
|
+
attr_accessor :string_value
|
31
|
+
attr_accessor :boolean_value
|
32
|
+
attr_accessor :date_value
|
33
|
+
attr_accessor :bytes_value
|
34
|
+
attr_accessor :items
|
35
|
+
attr_accessor :child
|
36
|
+
attr_accessor :children
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
let(:representer_class) do
|
41
|
+
klass = child_class
|
42
|
+
Class.new(Google::Apis::Core::JsonRepresentation) do
|
43
|
+
property :unset_value, as: 'unsetValue'
|
44
|
+
property :nil_value, as: 'nilValue'
|
45
|
+
property :numeric_value, as: 'numericValue'
|
46
|
+
property :string_value, as: 'stringValue'
|
47
|
+
property :boolean_value, as: 'booleanValue'
|
48
|
+
property :date_value, as: 'dateValue', type: DateTime
|
49
|
+
property :bytes_value, as: 'bytesValue', base64: true
|
50
|
+
property :items
|
51
|
+
property :child, class: klass do
|
52
|
+
property :value
|
53
|
+
end
|
54
|
+
collection :children, class: klass do
|
55
|
+
property :value
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
shared_examples 'it serializes' do
|
61
|
+
it 'does not serialize unset values' do
|
62
|
+
expect(json).not_to have_json_path('unsetValue')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'serializes explicit nil values' do
|
66
|
+
expect(json).to be_json_eql(%(null)).at_path('nilValue')
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'serializes numeric values' do
|
70
|
+
expect(json).to be_json_eql(%(123)).at_path('numericValue')
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'serializes string values' do
|
74
|
+
expect(json).to be_json_eql(%("test")).at_path('stringValue')
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'serializes boolean values' do
|
78
|
+
expect(json).to be_json_eql(%(true)).at_path('booleanValue')
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'serializes date values' do
|
82
|
+
expect(json).to be_json_eql(%("2015-05-01T12:00:00+00:00")).at_path('dateValue')
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'serializes byte values to base64' do
|
86
|
+
expect(json).to be_json_eql(%("SGVsbG8gd29ybGQ=")).at_path('bytesValue')
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'serializes basic collections' do
|
90
|
+
expect(json).to be_json_eql(%([1,2,3])).at_path('items')
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'serializes nested objects' do
|
94
|
+
expect(json).to be_json_eql(%({"value" : "child"})).at_path('child')
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'serializes object collections' do
|
98
|
+
expect(json).to be_json_eql(%([{"value" : "child"}])).at_path('children')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'with model object' do
|
103
|
+
let(:json) { representer_class.new(model).to_json(skip_undefined: true) }
|
104
|
+
let(:model) do
|
105
|
+
model = model_class.new
|
106
|
+
model.nil_value = nil
|
107
|
+
model.numeric_value = 123
|
108
|
+
model.string_value = 'test'
|
109
|
+
model.date_value = DateTime.new(2015, 5, 1, 12)
|
110
|
+
model.boolean_value = true
|
111
|
+
model.bytes_value = 'Hello world'
|
112
|
+
model.items = [1, 2, 3]
|
113
|
+
model.child = child_class.new
|
114
|
+
model.child.value = 'child'
|
115
|
+
model.children = [model.child]
|
116
|
+
model
|
117
|
+
end
|
118
|
+
|
119
|
+
include_examples 'it serializes'
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'with hash' do
|
123
|
+
let(:json) { representer_class.new(model).to_json(skip_undefined: true) }
|
124
|
+
let(:model) do
|
125
|
+
{
|
126
|
+
nil_value: nil,
|
127
|
+
string_value: 'test',
|
128
|
+
numeric_value: 123,
|
129
|
+
date_value: DateTime.new(2015, 5, 1, 12),
|
130
|
+
boolean_value: true,
|
131
|
+
bytes_value: 'Hello world',
|
132
|
+
items: [1, 2, 3],
|
133
|
+
child: {
|
134
|
+
value: 'child'
|
135
|
+
},
|
136
|
+
children: [{ value: 'child' }]
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
include_examples 'it serializes'
|
141
|
+
end
|
142
|
+
|
143
|
+
context 'when de-serializing' do
|
144
|
+
let(:model) { representer_class.new(model_class.new).from_json(json) }
|
145
|
+
let(:json) do
|
146
|
+
json = <<EOF
|
147
|
+
{ "stringValue": "test",
|
148
|
+
"nilValue": null,
|
149
|
+
"booleanValue": true,
|
150
|
+
"numericValue": 123,
|
151
|
+
"dateValue": "2015-05-01T12:00:00+00:00",
|
152
|
+
"bytesValue": "SGVsbG8gd29ybGQ=",
|
153
|
+
"items": [1,2,3],
|
154
|
+
"child": {"value" : "hello"},
|
155
|
+
"children": [{"value" : "hello"}]
|
156
|
+
}
|
157
|
+
EOF
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'deserializes string values' do
|
161
|
+
expect(model.string_value).to eql 'test'
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'deserializes null values' do
|
165
|
+
expect(model.nil_value).to be_nil
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'deserializes numeric values' do
|
169
|
+
expect(model.numeric_value).to eql 123
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'deserializes boolean values' do
|
173
|
+
expect(model.boolean_value).to be_truthy
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'deserializes date values' do
|
177
|
+
expect(model.date_value).to eql DateTime.new(2015, 5, 1, 12)
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'deserializes basic collections' do
|
181
|
+
expect(model.items).to contain_exactly(1, 2, 3)
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'deserializes nested objects' do
|
185
|
+
expect(model.child.value).to eql 'hello'
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'serializes object collections' do
|
189
|
+
expect(model.children[0].value).to eql 'hello'
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,247 @@
|
|
1
|
+
# Copyright 2015 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'spec_helper'
|
16
|
+
require 'google/apis/options'
|
17
|
+
require 'google/apis/core/base_service'
|
18
|
+
require 'google/apis/core/json_representation'
|
19
|
+
require 'hurley/test'
|
20
|
+
|
21
|
+
RSpec.describe Google::Apis::Core::BaseService do
|
22
|
+
include TestHelpers
|
23
|
+
|
24
|
+
let(:service) { Google::Apis::Core::BaseService.new('https://www.googleapis.com/', '') }
|
25
|
+
|
26
|
+
before do
|
27
|
+
Google::Apis::ClientOptions.default.application_name = 'test'
|
28
|
+
Google::Apis::ClientOptions.default.application_version = '1.0'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should inherit default options' do
|
32
|
+
expect(service.client_options.application_name).to eql 'test'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should include application in user agent' do
|
36
|
+
agent = service.send(:user_agent)
|
37
|
+
expect(agent).to match /^test\/1.0/
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should inherit authorization' do
|
41
|
+
Google::Apis::RequestOptions.default.authorization = 'a token'
|
42
|
+
expect(service.authorization).to eql 'a token'
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should allow overiding authorization' do
|
46
|
+
Google::Apis::RequestOptions.default.authorization = 'a token'
|
47
|
+
service.authorization = 'another token'
|
48
|
+
expect(service.authorization).to eql 'another token'
|
49
|
+
end
|
50
|
+
|
51
|
+
shared_examples 'with options' do
|
52
|
+
it 'should inherit service options' do
|
53
|
+
service.request_options.retries = 2
|
54
|
+
expect(command.options.retries).to eql 2
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should include per-request options' do
|
58
|
+
expect(command.options.authorization).to eql 'foo'
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should allow per-request options to override service options' do
|
62
|
+
service.request_options.authorization = 'bar'
|
63
|
+
expect(command.options.authorization).to eql 'foo'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when making raw http requests' do
|
68
|
+
context 'with :get methods' do
|
69
|
+
before(:example) do
|
70
|
+
stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_return(body: 'hello world')
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should return body for get' do
|
74
|
+
response = service.http(:get, 'https://www.googleapis.com/zoo/animals')
|
75
|
+
expect(response).to eq 'hello world'
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should return allow downloads' do
|
79
|
+
response = service.http(:get, 'https://www.googleapis.com/zoo/animals', download_dest: StringIO.new)
|
80
|
+
expect(response.string).to eq 'hello world'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'with :post methods' do
|
85
|
+
before(:example) do
|
86
|
+
stub_request(:post, 'https://www.googleapis.com/zoo/animals').to_return(body: '')
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should post body' do
|
90
|
+
service.http(:post, 'https://www.googleapis.com/zoo/animals', body: 'hello')
|
91
|
+
expect(a_request(:post, 'https://www.googleapis.com/zoo/animals')
|
92
|
+
.with(body: 'hello')).to have_been_made
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'when making simple commands' do
|
98
|
+
let(:command) { service.send(:make_simple_command, :get, 'zoo/animals', authorization: 'foo') }
|
99
|
+
|
100
|
+
it 'should return the correct command type' do
|
101
|
+
expect(command).to be_an_instance_of(Google::Apis::Core::ApiCommand)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should build a correct URL' do
|
105
|
+
url = command.url.expand({}).to_s
|
106
|
+
expect(url).to eql 'https://www.googleapis.com/zoo/animals'
|
107
|
+
end
|
108
|
+
|
109
|
+
include_examples 'with options'
|
110
|
+
end
|
111
|
+
|
112
|
+
context 'when making download commands' do
|
113
|
+
let(:command) { service.send(:make_download_command, :get, 'zoo/animals', authorization: 'foo') }
|
114
|
+
|
115
|
+
it 'should return the correct command type' do
|
116
|
+
expect(command).to be_an_instance_of(Google::Apis::Core::DownloadCommand)
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should build a correct URL' do
|
120
|
+
url = command.url.expand({}).to_s
|
121
|
+
expect(url).to eql 'https://www.googleapis.com/zoo/animals'
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should include alt=media in params' do
|
125
|
+
expect(command.query).to include('alt' => 'media')
|
126
|
+
end
|
127
|
+
|
128
|
+
include_examples 'with options'
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'when making upload commands' do
|
132
|
+
let(:command) { service.send(:make_upload_command, :post, 'zoo/animals', authorization: 'foo') }
|
133
|
+
|
134
|
+
it 'should return the correct command type' do
|
135
|
+
expect(command).to be_an_instance_of(Google::Apis::Core::ResumableUploadCommand)
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should build a correct URL' do
|
139
|
+
url = command.url.expand({}).to_s
|
140
|
+
expect(url).to eql 'https://www.googleapis.com/upload/zoo/animals'
|
141
|
+
end
|
142
|
+
|
143
|
+
include_examples 'with options'
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'with batch' do
|
147
|
+
before(:example) do
|
148
|
+
response = <<EOF.gsub(/\n/, "\r\n")
|
149
|
+
--batch123
|
150
|
+
Content-Type: application/http
|
151
|
+
|
152
|
+
HTTP/1.1 200 OK
|
153
|
+
Content-Type: text/plain; charset=UTF-8
|
154
|
+
|
155
|
+
Hello
|
156
|
+
--batch123--
|
157
|
+
EOF
|
158
|
+
stub_request(:post, 'https://www.googleapis.com/batch')
|
159
|
+
.to_return(headers: { 'Content-Type' => 'multipart/mixed; boundary=batch123' }, body: response)
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'should add commands to a batch' do
|
163
|
+
expect do |b|
|
164
|
+
service.batch do |service|
|
165
|
+
command = service.send(:make_simple_command, :get, 'zoo/animals', {})
|
166
|
+
service.send(:execute_or_queue_command, command, &b)
|
167
|
+
end
|
168
|
+
end.to yield_with_args('Hello', nil)
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'should disallow uploads in batch' do
|
172
|
+
expect do |b|
|
173
|
+
service.batch do |service|
|
174
|
+
command = service.send(:make_upload_command, :post, 'zoo/animals', {})
|
175
|
+
service.send(:execute_or_queue_command, command, &b)
|
176
|
+
end
|
177
|
+
end.to raise_error(Google::Apis::ClientError)
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'should disallow downloads in batch' do
|
181
|
+
expect do |b|
|
182
|
+
service.batch do |service|
|
183
|
+
command = service.send(:make_download_command, :get, 'zoo/animals', {})
|
184
|
+
service.send(:execute_or_queue_command, command, &b)
|
185
|
+
end
|
186
|
+
end.to raise_error(Google::Apis::ClientError)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
context 'with batch uploads' do
|
191
|
+
before(:example) do
|
192
|
+
response = <<EOF.gsub(/\n/, "\r\n")
|
193
|
+
--batch123
|
194
|
+
Content-Type: application/http
|
195
|
+
|
196
|
+
HTTP/1.1 200 OK
|
197
|
+
Content-Type: text/plain; charset=UTF-8
|
198
|
+
|
199
|
+
Hello
|
200
|
+
--batch123--
|
201
|
+
EOF
|
202
|
+
stub_request(:put, 'https://www.googleapis.com/upload/')
|
203
|
+
.to_return(headers: { 'Content-Type' => 'multipart/mixed; boundary=batch123' }, body: response)
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'should add upload to a batch' do
|
207
|
+
expect do |b|
|
208
|
+
service.batch_upload do |service|
|
209
|
+
command = service.send(:make_upload_command, :post, 'zoo/animals', {})
|
210
|
+
command.upload_source = StringIO.new('test')
|
211
|
+
command.upload_content_type = 'text/plain'
|
212
|
+
service.send(:execute_or_queue_command, command, &b)
|
213
|
+
end
|
214
|
+
end.to yield_with_args('Hello', nil)
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'should use multipart upload' do
|
218
|
+
expect do |b|
|
219
|
+
service.batch_upload do |service|
|
220
|
+
command = service.send(:make_upload_command, :post, 'zoo/animals', {})
|
221
|
+
command.upload_source = StringIO.new('test')
|
222
|
+
command.upload_content_type = 'text/plain'
|
223
|
+
expect(command).to be_an_instance_of(Google::Apis::Core::MultipartUploadCommand)
|
224
|
+
service.send(:execute_or_queue_command, command, &b)
|
225
|
+
end
|
226
|
+
end.to yield_with_args('Hello', nil)
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'should disallow downloads in batch' do
|
230
|
+
expect do |b|
|
231
|
+
service.batch_upload do |service|
|
232
|
+
command = service.send(:make_download_command, :get, 'zoo/animals', {})
|
233
|
+
service.send(:execute_or_queue_command, command, &b)
|
234
|
+
end
|
235
|
+
end.to raise_error(Google::Apis::ClientError)
|
236
|
+
end
|
237
|
+
|
238
|
+
it 'should disallow simple commands in batch' do
|
239
|
+
expect do |b|
|
240
|
+
service.batch_upload do |service|
|
241
|
+
command = service.send(:make_simple_command, :get, 'zoo/animals', {})
|
242
|
+
service.send(:execute_or_queue_command, command, &b)
|
243
|
+
end
|
244
|
+
end.to raise_error(Google::Apis::ClientError)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|