google-api-client 0.9.pre3 → 0.9.pre4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (307) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/CHANGELOG.md +14 -2
  4. data/Gemfile +4 -0
  5. data/MIGRATING.md +1 -1
  6. data/README.md +17 -3
  7. data/api_names.yaml +127 -14
  8. data/api_names_out.yaml +5442 -710
  9. data/bin/generate-api +16 -14
  10. data/generated/google/apis/adexchangebuyer_v1_3.rb +1 -1
  11. data/generated/google/apis/adexchangebuyer_v1_3/classes.rb +213 -2
  12. data/generated/google/apis/adexchangebuyer_v1_3/representations.rb +71 -0
  13. data/generated/google/apis/adexchangebuyer_v1_3/service.rb +21 -42
  14. data/generated/google/apis/adexchangeseller_v2_0.rb +1 -1
  15. data/generated/google/apis/adexchangeseller_v2_0/service.rb +15 -29
  16. data/generated/google/apis/admin_datatransfer_v1.rb +37 -0
  17. data/generated/google/apis/admin_datatransfer_v1/classes.rb +267 -0
  18. data/generated/google/apis/admin_datatransfer_v1/representations.rb +118 -0
  19. data/generated/google/apis/admin_datatransfer_v1/service.rb +262 -0
  20. data/generated/google/apis/admin_directory_v1.rb +25 -1
  21. data/generated/google/apis/admin_directory_v1/classes.rb +718 -0
  22. data/generated/google/apis/admin_directory_v1/representations.rb +244 -0
  23. data/generated/google/apis/admin_directory_v1/service.rb +1522 -509
  24. data/generated/google/apis/admin_reports_v1.rb +1 -1
  25. data/generated/google/apis/admin_reports_v1/service.rb +5 -10
  26. data/generated/google/apis/adsense_v1_4.rb +1 -1
  27. data/generated/google/apis/adsense_v1_4/classes.rb +6 -0
  28. data/generated/google/apis/adsense_v1_4/representations.rb +1 -0
  29. data/generated/google/apis/adsense_v1_4/service.rb +40 -78
  30. data/generated/google/apis/adsensehost_v4_1.rb +1 -1
  31. data/generated/google/apis/adsensehost_v4_1/service.rb +26 -52
  32. data/generated/google/apis/analytics_v3.rb +1 -1
  33. data/generated/google/apis/analytics_v3/classes.rb +11 -13
  34. data/generated/google/apis/analytics_v3/service.rb +84 -158
  35. data/generated/google/apis/androidenterprise_v1.rb +2 -2
  36. data/generated/google/apis/androidenterprise_v1/classes.rb +276 -8
  37. data/generated/google/apis/androidenterprise_v1/representations.rb +106 -0
  38. data/generated/google/apis/androidenterprise_v1/service.rb +715 -97
  39. data/generated/google/apis/androidpublisher_v2.rb +1 -1
  40. data/generated/google/apis/androidpublisher_v2/classes.rb +2 -2
  41. data/generated/google/apis/androidpublisher_v2/service.rb +55 -107
  42. data/generated/google/apis/appengine_v1beta4.rb +35 -0
  43. data/generated/google/apis/appengine_v1beta4/classes.rb +1532 -0
  44. data/generated/google/apis/appengine_v1beta4/representations.rb +526 -0
  45. data/generated/google/apis/appengine_v1beta4/service.rb +476 -0
  46. data/generated/google/apis/appsactivity_v1.rb +1 -1
  47. data/generated/google/apis/appsactivity_v1/service.rb +1 -2
  48. data/generated/google/apis/appstate_v1.rb +1 -1
  49. data/generated/google/apis/appstate_v1/service.rb +6 -11
  50. data/generated/google/apis/autoscaler_v1beta2/service.rb +10 -20
  51. data/generated/google/apis/bigquery_v2.rb +4 -1
  52. data/generated/google/apis/bigquery_v2/classes.rb +231 -16
  53. data/generated/google/apis/bigquery_v2/representations.rb +62 -0
  54. data/generated/google/apis/bigquery_v2/service.rb +24 -45
  55. data/generated/google/apis/blogger_v3/service.rb +33 -66
  56. data/generated/google/apis/books_v1.rb +1 -1
  57. data/generated/google/apis/books_v1/classes.rb +441 -0
  58. data/generated/google/apis/books_v1/representations.rb +177 -0
  59. data/generated/google/apis/books_v1/service.rb +210 -90
  60. data/generated/google/apis/calendar_v3.rb +1 -1
  61. data/generated/google/apis/calendar_v3/classes.rb +34 -18
  62. data/generated/google/apis/calendar_v3/service.rb +118 -103
  63. data/generated/google/apis/civicinfo_v2.rb +1 -1
  64. data/generated/google/apis/civicinfo_v2/classes.rb +12 -3
  65. data/generated/google/apis/civicinfo_v2/representations.rb +1 -0
  66. data/generated/google/apis/civicinfo_v2/service.rb +5 -10
  67. data/generated/google/apis/classroom_v1.rb +49 -0
  68. data/generated/google/apis/classroom_v1/classes.rb +512 -0
  69. data/generated/google/apis/classroom_v1/representations.rb +217 -0
  70. data/generated/google/apis/classroom_v1/service.rb +970 -0
  71. data/generated/google/apis/cloudbilling_v1.rb +35 -0
  72. data/generated/google/apis/cloudbilling_v1/classes.rb +169 -0
  73. data/generated/google/apis/cloudbilling_v1/representations.rb +79 -0
  74. data/generated/google/apis/cloudbilling_v1/service.rb +258 -0
  75. data/generated/google/apis/clouddebugger_v2.rb +41 -0
  76. data/generated/google/apis/clouddebugger_v2/classes.rb +1004 -0
  77. data/generated/google/apis/clouddebugger_v2/representations.rb +410 -0
  78. data/generated/google/apis/clouddebugger_v2/service.rb +370 -0
  79. data/generated/google/apis/cloudmonitoring_v2beta2.rb +1 -1
  80. data/generated/google/apis/cloudmonitoring_v2beta2/service.rb +6 -12
  81. data/generated/google/apis/cloudresourcemanager_v1beta1.rb +5 -2
  82. data/generated/google/apis/cloudresourcemanager_v1beta1/classes.rb +173 -249
  83. data/generated/google/apis/cloudresourcemanager_v1beta1/representations.rb +36 -68
  84. data/generated/google/apis/cloudresourcemanager_v1beta1/service.rb +293 -80
  85. data/generated/google/apis/cloudtrace_v1.rb +35 -0
  86. data/generated/google/apis/cloudtrace_v1/classes.rb +188 -0
  87. data/generated/google/apis/cloudtrace_v1/representations.rb +92 -0
  88. data/generated/google/apis/cloudtrace_v1/service.rb +190 -0
  89. data/generated/google/apis/clouduseraccounts_beta.rb +43 -0
  90. data/generated/google/apis/clouduseraccounts_beta/classes.rb +823 -0
  91. data/generated/google/apis/clouduseraccounts_beta/representations.rb +313 -0
  92. data/generated/google/apis/clouduseraccounts_beta/service.rb +854 -0
  93. data/generated/google/apis/compute_beta.rb +49 -0
  94. data/generated/google/apis/compute_beta/classes.rb +9128 -0
  95. data/generated/google/apis/compute_beta/representations.rb +3048 -0
  96. data/generated/google/apis/compute_beta/service.rb +10154 -0
  97. data/generated/google/apis/compute_v1.rb +1 -1
  98. data/generated/google/apis/compute_v1/classes.rb +1305 -520
  99. data/generated/google/apis/compute_v1/representations.rb +122 -15
  100. data/generated/google/apis/compute_v1/service.rb +2202 -1085
  101. data/generated/google/apis/container_v1.rb +1 -1
  102. data/generated/google/apis/container_v1/classes.rb +56 -31
  103. data/generated/google/apis/container_v1/representations.rb +12 -0
  104. data/generated/google/apis/container_v1/service.rb +62 -41
  105. data/generated/google/apis/content_v2.rb +2 -2
  106. data/generated/google/apis/content_v2/classes.rb +2252 -56
  107. data/generated/google/apis/content_v2/representations.rb +917 -87
  108. data/generated/google/apis/content_v2/service.rb +680 -85
  109. data/generated/google/apis/coordinate_v1.rb +1 -1
  110. data/generated/google/apis/coordinate_v1/service.rb +16 -25
  111. data/generated/google/apis/customsearch_v1/service.rb +1 -2
  112. data/generated/google/apis/datastore_v1beta2.rb +1 -1
  113. data/generated/google/apis/datastore_v1beta2/service.rb +12 -18
  114. data/generated/google/apis/deploymentmanager_v2.rb +44 -0
  115. data/generated/google/apis/deploymentmanager_v2/classes.rb +1089 -0
  116. data/generated/google/apis/deploymentmanager_v2/representations.rb +422 -0
  117. data/generated/google/apis/deploymentmanager_v2/service.rb +857 -0
  118. data/generated/google/apis/deploymentmanager_v2beta2.rb +5 -2
  119. data/generated/google/apis/deploymentmanager_v2beta2/classes.rb +22 -3
  120. data/generated/google/apis/deploymentmanager_v2beta2/representations.rb +3 -0
  121. data/generated/google/apis/deploymentmanager_v2beta2/service.rb +14 -27
  122. data/generated/google/apis/dfareporting_v2_1.rb +1 -1
  123. data/generated/google/apis/dfareporting_v2_1/classes.rb +29 -14
  124. data/generated/google/apis/dfareporting_v2_1/service.rb +196 -389
  125. data/generated/google/apis/discovery_v1/classes.rb +7 -0
  126. data/generated/google/apis/discovery_v1/representations.rb +1 -0
  127. data/generated/google/apis/discovery_v1/service.rb +2 -4
  128. data/generated/google/apis/dns_v1.rb +4 -1
  129. data/generated/google/apis/dns_v1/service.rb +9 -18
  130. data/generated/google/apis/doubleclickbidmanager_v1.rb +1 -1
  131. data/generated/google/apis/doubleclickbidmanager_v1/classes.rb +9 -2
  132. data/generated/google/apis/doubleclickbidmanager_v1/representations.rb +1 -0
  133. data/generated/google/apis/doubleclickbidmanager_v1/service.rb +8 -16
  134. data/generated/google/apis/doubleclicksearch_v2.rb +1 -1
  135. data/generated/google/apis/doubleclicksearch_v2/classes.rb +15 -6
  136. data/generated/google/apis/doubleclicksearch_v2/representations.rb +1 -0
  137. data/generated/google/apis/doubleclicksearch_v2/service.rb +13 -23
  138. data/generated/google/apis/drive_v2.rb +1 -1
  139. data/generated/google/apis/drive_v2/classes.rb +73 -30
  140. data/generated/google/apis/drive_v2/representations.rb +14 -0
  141. data/generated/google/apis/drive_v2/service.rb +139 -135
  142. data/generated/google/apis/drive_v3.rb +55 -0
  143. data/generated/google/apis/drive_v3/classes.rb +1534 -0
  144. data/generated/google/apis/drive_v3/representations.rb +497 -0
  145. data/generated/google/apis/drive_v3/service.rb +1541 -0
  146. data/generated/google/apis/fitness_v1.rb +1 -1
  147. data/generated/google/apis/fitness_v1/service.rb +14 -27
  148. data/generated/google/apis/fusiontables_v2/service.rb +40 -73
  149. data/generated/google/apis/games_configuration_v1configuration.rb +1 -1
  150. data/generated/google/apis/games_configuration_v1configuration/service.rb +14 -27
  151. data/generated/google/apis/games_management_v1management.rb +37 -0
  152. data/generated/google/apis/games_management_v1management/classes.rb +524 -0
  153. data/generated/google/apis/games_management_v1management/representations.rb +231 -0
  154. data/generated/google/apis/games_management_v1management/service.rb +994 -0
  155. data/generated/google/apis/games_v1.rb +1 -1
  156. data/generated/google/apis/games_v1/classes.rb +39 -0
  157. data/generated/google/apis/games_v1/representations.rb +14 -0
  158. data/generated/google/apis/games_v1/service.rb +93 -109
  159. data/generated/google/apis/gan_v1beta1/service.rb +10 -20
  160. data/generated/google/apis/genomics_v1.rb +5 -3
  161. data/generated/google/apis/genomics_v1/classes.rb +519 -200
  162. data/generated/google/apis/genomics_v1/representations.rb +126 -13
  163. data/generated/google/apis/genomics_v1/service.rb +392 -236
  164. data/generated/google/apis/gmail_v1.rb +4 -1
  165. data/generated/google/apis/gmail_v1/service.rb +39 -71
  166. data/generated/google/apis/groupsmigration_v1/service.rb +2 -3
  167. data/generated/google/apis/groupssettings_v1/service.rb +3 -6
  168. data/generated/google/apis/identitytoolkit_v3.rb +1 -1
  169. data/generated/google/apis/identitytoolkit_v3/classes.rb +125 -0
  170. data/generated/google/apis/identitytoolkit_v3/representations.rb +37 -0
  171. data/generated/google/apis/identitytoolkit_v3/service.rb +44 -24
  172. data/generated/google/apis/kgsearch_v1.rb +32 -0
  173. data/generated/google/apis/kgsearch_v1/classes.rb +59 -0
  174. data/generated/google/apis/kgsearch_v1/representations.rb +39 -0
  175. data/generated/google/apis/kgsearch_v1/service.rb +111 -0
  176. data/generated/google/apis/licensing_v1.rb +1 -1
  177. data/generated/google/apis/licensing_v1/service.rb +7 -14
  178. data/generated/google/apis/logging_v1beta3.rb +16 -4
  179. data/generated/google/apis/logging_v1beta3/classes.rb +620 -46
  180. data/generated/google/apis/logging_v1beta3/representations.rb +144 -0
  181. data/generated/google/apis/logging_v1beta3/service.rb +435 -104
  182. data/generated/google/apis/manager_v1beta2.rb +3 -0
  183. data/generated/google/apis/manager_v1beta2/service.rb +8 -16
  184. data/generated/google/apis/mapsengine_v1.rb +1 -1
  185. data/generated/google/apis/mapsengine_v1/service.rb +85 -162
  186. data/generated/google/apis/mirror_v1.rb +1 -1
  187. data/generated/google/apis/mirror_v1/service.rb +28 -52
  188. data/generated/google/apis/oauth2_v2.rb +1 -1
  189. data/generated/google/apis/oauth2_v2/service.rb +4 -8
  190. data/generated/google/apis/pagespeedonline_v2/service.rb +1 -2
  191. data/generated/google/apis/partners_v2.rb +32 -0
  192. data/generated/google/apis/partners_v2/classes.rb +942 -0
  193. data/generated/google/apis/partners_v2/representations.rb +402 -0
  194. data/generated/google/apis/partners_v2/service.rb +400 -0
  195. data/generated/google/apis/plus_domains_v1.rb +1 -1
  196. data/generated/google/apis/plus_domains_v1/classes.rb +207 -0
  197. data/generated/google/apis/plus_domains_v1/representations.rb +114 -0
  198. data/generated/google/apis/plus_domains_v1/service.rb +21 -41
  199. data/generated/google/apis/plus_v1.rb +1 -1
  200. data/generated/google/apis/plus_v1/classes.rb +207 -0
  201. data/generated/google/apis/plus_v1/representations.rb +114 -0
  202. data/generated/google/apis/plus_v1/service.rb +11 -56
  203. data/generated/google/apis/prediction_v1_6.rb +1 -1
  204. data/generated/google/apis/prediction_v1_6/service.rb +8 -16
  205. data/generated/google/apis/proximitybeacon_v1beta1.rb +31 -0
  206. data/generated/google/apis/proximitybeacon_v1beta1/classes.rb +639 -0
  207. data/generated/google/apis/proximitybeacon_v1beta1/representations.rb +274 -0
  208. data/generated/google/apis/proximitybeacon_v1beta1/service.rb +591 -0
  209. data/generated/google/apis/pubsub_v1.rb +37 -0
  210. data/generated/google/apis/pubsub_v1/classes.rb +614 -0
  211. data/generated/google/apis/pubsub_v1/representations.rb +281 -0
  212. data/generated/google/apis/pubsub_v1/service.rb +774 -0
  213. data/generated/google/apis/pubsub_v1beta2.rb +1 -1
  214. data/generated/google/apis/pubsub_v1beta2/classes.rb +78 -283
  215. data/generated/google/apis/pubsub_v1beta2/representations.rb +1 -85
  216. data/generated/google/apis/pubsub_v1beta2/service.rb +79 -87
  217. data/generated/google/apis/qpx_express_v1/service.rb +1 -2
  218. data/generated/google/apis/replicapool_v1beta2.rb +3 -0
  219. data/generated/google/apis/replicapool_v1beta2/service.rb +12 -24
  220. data/generated/google/apis/replicapoolupdater_v1beta1.rb +4 -1
  221. data/generated/google/apis/replicapoolupdater_v1beta1/classes.rb +46 -2
  222. data/generated/google/apis/replicapoolupdater_v1beta1/representations.rb +16 -0
  223. data/generated/google/apis/replicapoolupdater_v1beta1/service.rb +58 -18
  224. data/generated/google/apis/reseller_v1.rb +1 -1
  225. data/generated/google/apis/reseller_v1/classes.rb +19 -1
  226. data/generated/google/apis/reseller_v1/representations.rb +1 -0
  227. data/generated/google/apis/reseller_v1/service.rb +16 -30
  228. data/generated/google/apis/resourceviews_v1beta2.rb +3 -0
  229. data/generated/google/apis/resourceviews_v1beta2/service.rb +16 -27
  230. data/generated/google/apis/script_v1.rb +61 -0
  231. data/generated/google/apis/script_v1/classes.rb +259 -0
  232. data/generated/google/apis/script_v1/representations.rb +106 -0
  233. data/generated/google/apis/script_v1/service.rb +98 -0
  234. data/generated/google/apis/site_verification_v1.rb +1 -1
  235. data/generated/google/apis/site_verification_v1/service.rb +8 -15
  236. data/generated/google/apis/sqladmin_v1beta4.rb +1 -1
  237. data/generated/google/apis/sqladmin_v1beta4/classes.rb +186 -2
  238. data/generated/google/apis/sqladmin_v1beta4/representations.rb +70 -0
  239. data/generated/google/apis/sqladmin_v1beta4/service.rb +166 -75
  240. data/generated/google/apis/storage_v1.rb +5 -2
  241. data/generated/google/apis/storage_v1/classes.rb +47 -4
  242. data/generated/google/apis/storage_v1/representations.rb +18 -0
  243. data/generated/google/apis/storage_v1/service.rb +77 -94
  244. data/generated/google/apis/storagetransfer_v1.rb +35 -0
  245. data/generated/google/apis/storagetransfer_v1/classes.rb +1046 -0
  246. data/generated/google/apis/storagetransfer_v1/representations.rb +370 -0
  247. data/generated/google/apis/storagetransfer_v1/service.rb +473 -0
  248. data/generated/google/apis/tagmanager_v1.rb +1 -1
  249. data/generated/google/apis/tagmanager_v1/classes.rb +189 -31
  250. data/generated/google/apis/tagmanager_v1/representations.rb +69 -15
  251. data/generated/google/apis/tagmanager_v1/service.rb +114 -275
  252. data/generated/google/apis/taskqueue_v1beta2/service.rb +8 -16
  253. data/generated/google/apis/tasks_v1/service.rb +14 -28
  254. data/generated/google/apis/translate_v2/service.rb +3 -6
  255. data/generated/google/apis/urlshortener_v1/service.rb +3 -6
  256. data/generated/google/apis/webmasters_v3.rb +3 -3
  257. data/generated/google/apis/webmasters_v3/classes.rb +4 -4
  258. data/generated/google/apis/webmasters_v3/service.rb +16 -30
  259. data/generated/google/apis/youtube_analytics_v1.rb +1 -1
  260. data/generated/google/apis/youtube_analytics_v1/classes.rb +6 -0
  261. data/generated/google/apis/youtube_analytics_v1/representations.rb +1 -0
  262. data/generated/google/apis/youtube_analytics_v1/service.rb +16 -21
  263. data/generated/google/apis/youtube_v3.rb +1 -1
  264. data/generated/google/apis/youtube_v3/classes.rb +111 -78
  265. data/generated/google/apis/youtube_v3/representations.rb +2 -0
  266. data/generated/google/apis/youtube_v3/service.rb +78 -246
  267. data/generated/google/apis/youtubereporting_v1.rb +38 -0
  268. data/generated/google/apis/youtubereporting_v1/classes.rb +258 -0
  269. data/generated/google/apis/youtubereporting_v1/representations.rb +128 -0
  270. data/generated/google/apis/youtubereporting_v1/service.rb +364 -0
  271. data/google-api-client.gemspec +3 -3
  272. data/lib/google/api_client/auth/installed_app.rb +2 -2
  273. data/lib/google/api_client/auth/key_utils.rb +1 -0
  274. data/lib/google/api_client/auth/storage.rb +1 -0
  275. data/lib/google/api_client/auth/storages/file_store.rb +1 -0
  276. data/lib/google/api_client/auth/storages/redis_store.rb +1 -0
  277. data/lib/google/api_client/client_secrets.rb +4 -5
  278. data/lib/google/apis/core/api_command.rb +2 -2
  279. data/lib/google/apis/core/base_service.rb +1 -0
  280. data/lib/google/apis/core/batch.rb +25 -8
  281. data/lib/google/apis/core/download.rb +1 -1
  282. data/lib/google/apis/core/http_command.rb +24 -12
  283. data/lib/google/apis/core/multipart.rb +20 -6
  284. data/lib/google/apis/core/upload.rb +11 -4
  285. data/lib/google/apis/generator/annotator.rb +29 -10
  286. data/lib/google/apis/generator/helpers.rb +1 -1
  287. data/lib/google/apis/generator/templates/_method.tmpl +5 -6
  288. data/lib/google/apis/options.rb +7 -3
  289. data/lib/google/apis/version.rb +1 -1
  290. data/samples/calendar/calendar.rb +1 -1
  291. data/samples/drive/drive.rb +9 -2
  292. data/samples/pubsub/pubsub.rb +5 -6
  293. data/samples/translate/translate.rb +1 -5
  294. data/script/generate +20 -5
  295. data/spec/fixtures/files/child/.gitignore +0 -0
  296. data/spec/fixtures/files/invalid.json +1 -0
  297. data/spec/google/api_client/client_secrets_spec.rb +38 -1
  298. data/spec/google/apis/core/batch_spec.rb +22 -8
  299. data/spec/google/apis/core/download_spec.rb +13 -0
  300. data/spec/google/apis/core/http_command_spec.rb +26 -9
  301. data/spec/google/apis/core/upload_spec.rb +65 -17
  302. data/spec/google/apis/options_spec.rb +8 -0
  303. data/spec/integration_tests/adsense_spec.rb +28 -0
  304. data/spec/integration_tests/pubsub_spec.rb +3 -3
  305. data/spec/spec_helper.rb +5 -1
  306. data/third_party/hurley_patches.rb +103 -0
  307. metadata +87 -7
@@ -15,16 +15,16 @@ Gem::Specification.new do |spec|
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ['lib', 'generated']
18
+ spec.require_paths = ['lib', 'generated', 'third_party']
19
19
 
20
- spec.add_runtime_dependency 'representable', '~> 2.1'
20
+ spec.add_runtime_dependency 'representable', '~> 2.3.0'
21
21
  spec.add_runtime_dependency 'multi_json', '~> 1.11'
22
22
  spec.add_runtime_dependency 'retriable', '~> 2.0'
23
23
  spec.add_runtime_dependency 'activesupport', '>= 3.2'
24
24
  spec.add_runtime_dependency 'addressable', '~> 2.3'
25
25
  spec.add_runtime_dependency 'mime-types', '>= 1.6'
26
26
  spec.add_runtime_dependency 'hurley', '~> 0.1'
27
- spec.add_runtime_dependency 'googleauth', '~> 0.2'
27
+ spec.add_runtime_dependency 'googleauth', '~> 0.5'
28
28
  spec.add_runtime_dependency 'thor', '~> 0.19'
29
29
  spec.add_runtime_dependency 'memoist', '~> 0.11'
30
30
  end
@@ -33,6 +33,7 @@ module Google
33
33
  # drive = Drive::DriveService.new
34
34
  # drive.authorization = authorization
35
35
  #
36
+ # @deprecated Use google-auth-library-ruby instead
36
37
  class InstalledAppFlow
37
38
 
38
39
  RESPONSE_BODY = <<-HTML
@@ -85,7 +86,7 @@ module Google
85
86
  #
86
87
  # @return [Signet::OAuth2::Client]
87
88
  # Authorization instance, nil if user cancelled.
88
- def authorize(storage=nil, options=nil)
89
+ def authorize(storage=nil, options={})
89
90
  auth = @authorization
90
91
 
91
92
  server = WEBrick::HTTPServer.new(
@@ -125,4 +126,3 @@ module Google
125
126
 
126
127
  end
127
128
  end
128
-
@@ -18,6 +18,7 @@ module Google
18
18
  # Helper for loading keys from the PKCS12 files downloaded when
19
19
  # setting up service accounts at the APIs Console.
20
20
  #
21
+ # @deprecated Use google-auth-library-ruby instead
21
22
  module KeyUtils
22
23
  ##
23
24
  # Loads a key from PKCS12 file, assuming a single private key
@@ -21,6 +21,7 @@ module Google
21
21
  # JSON serialized file. Meant to resemble the serialized format
22
22
  # http://google-api-python-client.googlecode.com/hg/docs/epy/oauth2client.file.Storage-class.html
23
23
  #
24
+ # @deprecated Use google-auth-library-ruby instead
24
25
  class Storage
25
26
 
26
27
  AUTHORIZATION_URI = 'https://accounts.google.com/o/oauth2/auth'
@@ -21,6 +21,7 @@ module Google
21
21
  # JSON serialized file. Meant to resemble the serialized format
22
22
  # http://google-api-python-client.googlecode.com/hg/docs/epy/oauth2client.file.Storage-class.html
23
23
  #
24
+ # @deprecated Use google-auth-library-ruby instead
24
25
  class FileStore
25
26
 
26
27
  attr_accessor :path
@@ -16,6 +16,7 @@ require 'json'
16
16
 
17
17
  module Google
18
18
  class APIClient
19
+ # @deprecated Use google-auth-library-ruby instead
19
20
  class RedisStore
20
21
 
21
22
  DEFAULT_REDIS_CREDENTIALS_KEY = "google_api_credentials"
@@ -23,7 +23,7 @@ module Google
23
23
  # inspired by the Google API Python client.
24
24
  #
25
25
  # @see https://developers.google.com/api-client-library/python/guide/aaa_client_secrets
26
- #
26
+ # @deprecated Use google-auth-library-ruby instead
27
27
  # @example
28
28
  # {
29
29
  # "web": {
@@ -46,7 +46,6 @@ module Google
46
46
  # }
47
47
  # }
48
48
  class ClientSecrets
49
-
50
49
  ##
51
50
  # Reads client configuration from a file
52
51
  #
@@ -77,7 +76,7 @@ module Google
77
76
  end
78
77
 
79
78
  ##
80
- # Intialize OAuth client settings.
79
+ # Initialize OAuth client settings.
81
80
  #
82
81
  # @param [Hash] options
83
82
  # Parsed client secrets files
@@ -122,7 +121,7 @@ module Google
122
121
  def to_json
123
122
  return MultiJson.dump(to_hash)
124
123
  end
125
-
124
+
126
125
  def to_hash
127
126
  {
128
127
  self.flow => ({
@@ -147,7 +146,7 @@ module Google
147
146
  end
148
147
  }
149
148
  end
150
-
149
+
151
150
  def to_authorization
152
151
  gem 'signet', '>= 0.4.0'
153
152
  require 'signet/oauth_2/client'
@@ -96,8 +96,8 @@ module Google
96
96
  if error
97
97
  message = error['reason'] if error.has_key?('reason')
98
98
  raise Google::Apis::RateLimitError.new(message,
99
- status_code: status,
100
- header: header,
99
+ status_code: status,
100
+ header: header,
101
101
  body: body) if RATE_LIMIT_ERRORS.include?(message)
102
102
  end
103
103
  super(status, header, body, message)
@@ -292,6 +292,7 @@ module Google
292
292
  def new_client
293
293
  client = Hurley::Client.new
294
294
  client.request_options.timeout = request_options.timeout_sec
295
+ client.request_options.open_timeout = request_options.open_timeout_sec
295
296
  client.request_options.proxy = client_options.proxy_url
296
297
  client.request_options.query_class = Hurley::Query::Flat
297
298
  client.ssl_options.ca_file = File.join(Google::Apis::ROOT, 'lib', 'cacerts.pem')
@@ -31,7 +31,7 @@ require 'google/apis/core/http_command'
31
31
  require 'google/apis/core/upload'
32
32
  require 'google/apis/core/download'
33
33
  require 'addressable/uri'
34
-
34
+ require 'securerandom'
35
35
  module Google
36
36
  module Apis
37
37
  module Core
@@ -47,6 +47,7 @@ module Google
47
47
  def initialize(method, url)
48
48
  super(method, url)
49
49
  @calls = []
50
+ @base_id = SecureRandom.uuid
50
51
  end
51
52
 
52
53
  ##
@@ -78,9 +79,12 @@ module Google
78
79
  parts = split_parts(body, m[1])
79
80
  deserializer = CallDeserializer.new
80
81
  parts.each_index do |index|
81
- call, callback = @calls[index]
82
+ response = deserializer.to_http_response(parts[index])
83
+ outer_header = response.shift
84
+ call_id = header_to_id(outer_header[:content_id]) || index
85
+ call, callback = @calls[call_id]
82
86
  begin
83
- result = call.process_response(*deserializer.to_http_response(parts[index])) unless call.nil?
87
+ result = call.process_response(*response) unless call.nil?
84
88
  success(result, &callback)
85
89
  rescue => e
86
90
  error(e, &callback)
@@ -103,9 +107,11 @@ module Google
103
107
 
104
108
  serializer = CallSerializer.new
105
109
  multipart = Multipart.new(boundary: BATCH_BOUNDARY, content_type: MULTIPART_MIXED)
106
- @calls.each do |(call, _)|
110
+ @calls.each_index do |index|
111
+ call, _ = @calls[index]
112
+ content_id = id_to_header(index)
107
113
  io = serializer.to_upload_io(call)
108
- multipart.add_upload(io)
114
+ multipart.add_upload(io, content_id: content_id)
109
115
  end
110
116
  self.body = multipart.assemble
111
117
 
@@ -120,6 +126,17 @@ module Google
120
126
  end
121
127
  fail Google::Apis::ClientError, 'Invalid command object' unless command.is_a?(HttpCommand)
122
128
  end
129
+
130
+ def id_to_header(call_id)
131
+ return sprintf('<%s+%i>', @base_id, call_id)
132
+ end
133
+
134
+ def header_to_id(content_id)
135
+ match = /<response-.*\+(\d+)>/.match(content_id)
136
+ return match[1].to_i if match
137
+ return nil
138
+ end
139
+
123
140
  end
124
141
 
125
142
  # Wrapper request for batching multiple uploads in a single server request
@@ -180,19 +197,19 @@ module Google
180
197
  # Deconstructs a raw HTTP response part
181
198
  # @private
182
199
  class CallDeserializer
183
- # Convert a single batched response into a BatchedCallResponse object.
200
+ # Parse a batched response.
184
201
  #
185
202
  # @param [String] call_response
186
203
  # the response to parse.
187
204
  # @return [Array<(Fixnum, Hurley::Header, String)>]
188
205
  # Status, header, and response body.
189
206
  def to_http_response(call_response)
190
- _, outer_body = split_header_and_body(call_response)
207
+ outer_header, outer_body = split_header_and_body(call_response)
191
208
  status_line, payload = outer_body.split(/\n/, 2)
192
209
  _, status = status_line.split(' ', 3)
193
210
 
194
211
  header, body = split_header_and_body(payload)
195
- [status.to_i, header, body]
212
+ [outer_header, status.to_i, header, body]
196
213
  end
197
214
 
198
215
  protected
@@ -71,7 +71,7 @@ module Google
71
71
  logger.debug { sprintf('Resuming download from offset %d', @offset) }
72
72
  req.header[RANGE_HEADER] = sprintf('bytes=%d-', @offset)
73
73
  end
74
- req.on_body do |res, chunk|
74
+ req.on_body(200, 201) do |res, chunk|
75
75
  check_status(res.status_code, chunk) unless res.status_code.nil?
76
76
  logger.debug { sprintf('Writing chunk (%d bytes)', chunk.length) }
77
77
  @offset += chunk.length
@@ -19,6 +19,7 @@ require 'google/apis/errors'
19
19
  require 'retriable'
20
20
  require 'hurley'
21
21
  require 'hurley/addressable'
22
+ require 'hurley_patches'
22
23
  require 'google/apis/core/logging'
23
24
  require 'pp'
24
25
 
@@ -91,7 +92,6 @@ module Google
91
92
  # @raise [Google::Apis::AuthorizationError] Authorization is required
92
93
  def execute(client)
93
94
  prepare!
94
- proc = block_given? ? Proc.new : nil
95
95
  begin
96
96
  Retriable.retriable tries: options.retries + 1,
97
97
  base_interval: 1,
@@ -104,11 +104,19 @@ module Google
104
104
  Retriable.retriable tries: auth_tries,
105
105
  on: [Google::Apis::AuthorizationError],
106
106
  on_retry: proc { |*| refresh_authorization } do
107
- return execute_once(client, &proc)
107
+ execute_once(client).tap do |result|
108
+ if block_given?
109
+ yield result, nil
110
+ end
111
+ end
108
112
  end
109
113
  end
110
114
  rescue => e
111
- raise e if proc.nil?
115
+ if block_given?
116
+ yield nil, e
117
+ else
118
+ raise e
119
+ end
112
120
  end
113
121
  ensure
114
122
  release!
@@ -136,7 +144,7 @@ module Google
136
144
  def prepare!
137
145
  header.update(options.header) if options && options.header
138
146
  self.url = url.expand(params) if url.is_a?(Addressable::Template)
139
- url.query_values = query
147
+ url.query_values = query.merge(url.query_values || {})
140
148
  end
141
149
 
142
150
  # Release any resources used by this command
@@ -167,7 +175,7 @@ module Google
167
175
  #
168
176
  # @param [Fixnum] status
169
177
  # HTTP status code of response
170
- # @param
178
+ # @param
171
179
  # @param [Hurley::Header] header
172
180
  # HTTP response headers
173
181
  # @param [String] body
@@ -184,16 +192,16 @@ module Google
184
192
  when 200...300
185
193
  nil
186
194
  when 301, 302, 303, 307
187
- message ||= sprintf('Redirect to %s', header[:location])
195
+ message ||= sprintf('Redirect to %s', header[:location])
188
196
  raise Google::Apis::RedirectError.new(message, status_code: status, header: header, body: body)
189
197
  when 401
190
198
  message ||= 'Unauthorized'
191
199
  raise Google::Apis::AuthorizationError.new(message, status_code: status, header: header, body: body)
192
200
  when 304, 400, 402...500
193
- message ||= 'Invalid request'
201
+ message ||= 'Invalid request'
194
202
  raise Google::Apis::ClientError.new(message, status_code: status, header: header, body: body)
195
203
  when 500...600
196
- message ||= 'Server error'
204
+ message ||= 'Server error'
197
205
  raise Google::Apis::ServerError.new(message, status_code: status, header: header, body: body)
198
206
  else
199
207
  logger.warn(sprintf('Encountered unexpected status code %s', status))
@@ -244,25 +252,29 @@ module Google
244
252
  # @private
245
253
  # @param [Hurley::Client] client
246
254
  # HTTP client
247
- # @yield [result, err] Result or error if block supplied
248
255
  # @return [Object]
249
256
  # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
250
257
  # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
251
258
  # @raise [Google::Apis::AuthorizationError] Authorization is required
252
- def execute_once(client, &block)
259
+ def execute_once(client)
253
260
  body.rewind if body.respond_to?(:rewind)
254
261
  begin
255
262
  logger.debug { sprintf('Sending HTTP %s %s', method, url) }
256
263
  response = client.send(method, url, body) do |req|
264
+ # Temporary workaround for Hurley bug where the connection preference
265
+ # is ignored and it uses nested anyway
266
+ req.url.query_class = Hurley::Query::Flat
267
+ query.each { | k, v| req.url.query[k] = v }
268
+ # End workaround
257
269
  apply_request_options(req)
258
270
  end
259
271
  logger.debug { response.status_code }
260
272
  logger.debug { response.inspect }
261
273
  response = process_response(response.status_code, response.header, response.body)
262
- success(response, &block)
274
+ success(response)
263
275
  rescue => e
264
276
  logger.debug { sprintf('Caught error %s', e) }
265
- error(e, rethrow: true, &block)
277
+ error(e, rethrow: true)
266
278
  end
267
279
  end
268
280
 
@@ -31,7 +31,7 @@ module Google
31
31
  # Multipart boundary
32
32
  # @param [String] value
33
33
  # JSON content
34
- def initialize(boundary, value)
34
+ def initialize(boundary, value, header = {})
35
35
  @part = build_part(boundary, value)
36
36
  @length = @part.bytesize
37
37
  @io = StringIO.new(@part)
@@ -95,19 +95,25 @@ module Google
95
95
  # @param [Hash] header
96
96
  # Headers for the part
97
97
  def build_head(boundary, type, content_len, header)
98
+ content_id = ''
99
+ if header[:content_id]
100
+ content_id = sprintf(CID_FORMAT, header[:content_id])
101
+ end
98
102
  sprintf(HEAD_FORMAT,
99
103
  boundary,
100
104
  content_len.to_i,
105
+ content_id,
101
106
  header[:content_type] || type,
102
107
  header[:content_transfer_encoding] || DEFAULT_TR_ENCODING)
103
108
  end
104
109
 
105
110
  DEFAULT_TR_ENCODING = 'binary'.freeze
106
111
  FOOT = "\r\n".freeze
112
+ CID_FORMAT = "Content-ID: %s\r\n"
107
113
  HEAD_FORMAT = <<-END
108
114
  --%s\r
109
115
  Content-Length: %d\r
110
- Content-Type: %s\r
116
+ %sContent-Type: %s\r
111
117
  Content-Transfer-Encoding: %s\r
112
118
  \r
113
119
  END
@@ -137,9 +143,12 @@ Content-Transfer-Encoding: %s\r
137
143
  #
138
144
  # @param [String] body
139
145
  # JSON text
146
+ # @param [String] content_id
147
+ # Optional unique ID of this part
140
148
  # @return [self]
141
- def add_json(body)
142
- @parts << Google::Apis::Core::JsonPart.new(@boundary, body)
149
+ def add_json(body, content_id: nil)
150
+ header = { :content_id => content_id }
151
+ @parts << Google::Apis::Core::JsonPart.new(@boundary, body, header)
143
152
  self
144
153
  end
145
154
 
@@ -147,9 +156,14 @@ Content-Transfer-Encoding: %s\r
147
156
  #
148
157
  # @param [Google::Apis::Core::UploadIO] upload_io
149
158
  # IO stream
159
+ # @param [String] content_id
160
+ # Optional unique ID of this part
150
161
  # @return [self]
151
- def add_upload(upload_io)
152
- @parts << Google::Apis::Core::FilePart.new(@boundary, upload_io)
162
+ def add_upload(upload_io, content_id: nil)
163
+ header = { :content_id => content_id }
164
+ @parts << Google::Apis::Core::FilePart.new(@boundary,
165
+ upload_io,
166
+ header)
153
167
  self
154
168
  end
155
169
 
@@ -178,7 +178,6 @@ module Google
178
178
  def process_response(status, header, body)
179
179
  @offset = Integer(header[BYTES_RECEIVED_HEADER]) if header.key?(BYTES_RECEIVED_HEADER)
180
180
  @upload_url = header[UPLOAD_URL_HEADER] if header.key?(UPLOAD_URL_HEADER)
181
-
182
181
  upload_status = header[UPLOAD_STATUS_HEADER]
183
182
  logger.debug { sprintf('Upload status %s', upload_status) }
184
183
  if upload_status == STATUS_ACTIVE
@@ -254,12 +253,16 @@ module Google
254
253
  # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
255
254
  # @raise [Google::Apis::AuthorizationError] Authorization is required
256
255
  def execute_once(client, &block)
257
- if @state == :start
256
+ case @state
257
+ when :start
258
258
  response = send_start_command(client)
259
- else
259
+ result = process_response(response.status_code, response.header, response.body)
260
+ when :active
260
261
  response = send_query_command(client)
262
+ result = process_response(response.status_code, response.header, response.body)
263
+ when :cancelled, :final
264
+ error(@last_error, rethrow: true, &block)
261
265
  end
262
- result = process_response(response.status_code, response.header, response.body)
263
266
  if @state == :active
264
267
  response = send_upload_command(client)
265
268
  result = process_response(response.status_code, response.header, response.body)
@@ -267,6 +270,10 @@ module Google
267
270
 
268
271
  success(result, &block) if @state == :final
269
272
  rescue => e
273
+ # Some APIs like Youtube generate non-retriable 401 errors and mark
274
+ # the upload as finalized. Save the error just in case we get
275
+ # retried.
276
+ @last_error = e
270
277
  error(e, rethrow: true, &block)
271
278
  end
272
279
  end