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.
Files changed (397) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +20 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +7 -0
  5. data/.rubocop_todo.yml +63 -0
  6. data/.travis.yml +21 -0
  7. data/.yardopts +12 -0
  8. data/CHANGELOG.md +6 -3
  9. data/CONTRIBUTING.md +31 -0
  10. data/Gemfile +28 -2
  11. data/MIGRATING.md +171 -0
  12. data/README.md +158 -150
  13. data/Rakefile +1 -40
  14. data/api_names.yaml +872 -0
  15. data/api_names_out.yaml +20843 -0
  16. data/bin/generate-api +93 -0
  17. data/generated/google/apis/adexchangebuyer_v1_3.rb +35 -0
  18. data/generated/google/apis/adexchangebuyer_v1_3/classes.rb +1124 -0
  19. data/generated/google/apis/adexchangebuyer_v1_3/representations.rb +375 -0
  20. data/generated/google/apis/adexchangebuyer_v1_3/service.rb +893 -0
  21. data/generated/google/apis/adexchangeseller_v2_0.rb +38 -0
  22. data/generated/google/apis/adexchangeseller_v2_0/classes.rb +792 -0
  23. data/generated/google/apis/adexchangeseller_v2_0/representations.rb +309 -0
  24. data/generated/google/apis/adexchangeseller_v2_0/service.rb +682 -0
  25. data/generated/google/apis/admin_directory_v1.rb +89 -0
  26. data/generated/google/apis/admin_directory_v1/classes.rb +2389 -0
  27. data/generated/google/apis/admin_directory_v1/representations.rb +780 -0
  28. data/generated/google/apis/admin_directory_v1/service.rb +2805 -0
  29. data/generated/google/apis/admin_reports_v1.rb +38 -0
  30. data/generated/google/apis/admin_reports_v1/classes.rb +582 -0
  31. data/generated/google/apis/admin_reports_v1/representations.rb +231 -0
  32. data/generated/google/apis/admin_reports_v1/service.rb +341 -0
  33. data/generated/google/apis/adsense_v1_4.rb +38 -0
  34. data/generated/google/apis/adsense_v1_4/classes.rb +1279 -0
  35. data/generated/google/apis/adsense_v1_4/representations.rb +493 -0
  36. data/generated/google/apis/adsense_v1_4/service.rb +1752 -0
  37. data/generated/google/apis/adsensehost_v4_1.rb +35 -0
  38. data/generated/google/apis/adsensehost_v4_1/classes.rb +834 -0
  39. data/generated/google/apis/adsensehost_v4_1/representations.rb +327 -0
  40. data/generated/google/apis/adsensehost_v4_1/service.rb +1190 -0
  41. data/generated/google/apis/analytics_v3.rb +49 -0
  42. data/generated/google/apis/analytics_v3/classes.rb +5113 -0
  43. data/generated/google/apis/analytics_v3/representations.rb +1661 -0
  44. data/generated/google/apis/analytics_v3/service.rb +3600 -0
  45. data/generated/google/apis/androidenterprise_v1.rb +34 -0
  46. data/generated/google/apis/androidenterprise_v1/classes.rb +1162 -0
  47. data/generated/google/apis/androidenterprise_v1/representations.rb +431 -0
  48. data/generated/google/apis/androidenterprise_v1/service.rb +1979 -0
  49. data/generated/google/apis/androidpublisher_v2.rb +34 -0
  50. data/generated/google/apis/androidpublisher_v2/classes.rb +1374 -0
  51. data/generated/google/apis/androidpublisher_v2/representations.rb +630 -0
  52. data/generated/google/apis/androidpublisher_v2/service.rb +2390 -0
  53. data/generated/google/apis/appsactivity_v1.rb +46 -0
  54. data/generated/google/apis/appsactivity_v1/classes.rb +392 -0
  55. data/generated/google/apis/appsactivity_v1/representations.rb +184 -0
  56. data/generated/google/apis/appsactivity_v1/service.rb +129 -0
  57. data/generated/google/apis/appstate_v1.rb +34 -0
  58. data/generated/google/apis/appstate_v1/classes.rb +154 -0
  59. data/generated/google/apis/appstate_v1/representations.rb +79 -0
  60. data/generated/google/apis/appstate_v1/service.rb +265 -0
  61. data/generated/google/apis/autoscaler_v1beta2.rb +38 -0
  62. data/generated/google/apis/autoscaler_v1beta2/classes.rb +747 -0
  63. data/generated/google/apis/autoscaler_v1beta2/representations.rb +281 -0
  64. data/generated/google/apis/autoscaler_v1beta2/service.rb +488 -0
  65. data/generated/google/apis/bigquery_v2.rb +49 -0
  66. data/generated/google/apis/bigquery_v2/classes.rb +2255 -0
  67. data/generated/google/apis/bigquery_v2/representations.rb +754 -0
  68. data/generated/google/apis/bigquery_v2/service.rb +1003 -0
  69. data/generated/google/apis/blogger_v3.rb +37 -0
  70. data/generated/google/apis/blogger_v3/classes.rb +1354 -0
  71. data/generated/google/apis/blogger_v3/representations.rb +562 -0
  72. data/generated/google/apis/blogger_v3/service.rb +1620 -0
  73. data/generated/google/apis/books_v1.rb +34 -0
  74. data/generated/google/apis/books_v1/classes.rb +3515 -0
  75. data/generated/google/apis/books_v1/representations.rb +1361 -0
  76. data/generated/google/apis/books_v1/service.rb +2170 -0
  77. data/generated/google/apis/calendar_v3.rb +37 -0
  78. data/generated/google/apis/calendar_v3/classes.rb +1702 -0
  79. data/generated/google/apis/calendar_v3/representations.rb +566 -0
  80. data/generated/google/apis/calendar_v3/service.rb +1943 -0
  81. data/generated/google/apis/civicinfo_v2.rb +31 -0
  82. data/generated/google/apis/civicinfo_v2/classes.rb +1057 -0
  83. data/generated/google/apis/civicinfo_v2/representations.rb +374 -0
  84. data/generated/google/apis/civicinfo_v2/service.rb +284 -0
  85. data/generated/google/apis/cloudmonitoring_v2beta2.rb +34 -0
  86. data/generated/google/apis/cloudmonitoring_v2beta2/classes.rb +679 -0
  87. data/generated/google/apis/cloudmonitoring_v2beta2/representations.rb +311 -0
  88. data/generated/google/apis/cloudmonitoring_v2beta2/service.rb +458 -0
  89. data/generated/google/apis/cloudresourcemanager_v1beta1.rb +38 -0
  90. data/generated/google/apis/cloudresourcemanager_v1beta1/classes.rb +139 -0
  91. data/generated/google/apis/cloudresourcemanager_v1beta1/representations.rb +65 -0
  92. data/generated/google/apis/cloudresourcemanager_v1beta1/service.rb +301 -0
  93. data/generated/google/apis/compute_v1.rb +49 -0
  94. data/generated/google/apis/compute_v1/classes.rb +6391 -0
  95. data/generated/google/apis/compute_v1/representations.rb +2209 -0
  96. data/generated/google/apis/compute_v1/service.rb +6352 -0
  97. data/generated/google/apis/container_v1beta1.rb +35 -0
  98. data/generated/google/apis/container_v1beta1/classes.rb +466 -0
  99. data/generated/google/apis/container_v1beta1/representations.rb +177 -0
  100. data/generated/google/apis/container_v1beta1/service.rb +394 -0
  101. data/generated/google/apis/content_v2.rb +35 -0
  102. data/generated/google/apis/content_v2/classes.rb +3780 -0
  103. data/generated/google/apis/content_v2/representations.rb +1456 -0
  104. data/generated/google/apis/content_v2/service.rb +1706 -0
  105. data/generated/google/apis/coordinate_v1.rb +37 -0
  106. data/generated/google/apis/coordinate_v1/classes.rb +669 -0
  107. data/generated/google/apis/coordinate_v1/representations.rb +285 -0
  108. data/generated/google/apis/coordinate_v1/service.rb +687 -0
  109. data/{lib/google/api_client/auth/compute_service_account.rb → generated/google/apis/customsearch_v1.rb} +13 -10
  110. data/generated/google/apis/customsearch_v1/classes.rb +771 -0
  111. data/generated/google/apis/customsearch_v1/representations.rb +276 -0
  112. data/generated/google/apis/customsearch_v1/service.rb +208 -0
  113. data/generated/google/apis/datastore_v1beta2.rb +40 -0
  114. data/generated/google/apis/datastore_v1beta2/classes.rb +1186 -0
  115. data/generated/google/apis/datastore_v1beta2/representations.rb +526 -0
  116. data/generated/google/apis/datastore_v1beta2/service.rb +300 -0
  117. data/generated/google/apis/deploymentmanager_v2beta2.rb +41 -0
  118. data/generated/google/apis/deploymentmanager_v2beta2/classes.rb +820 -0
  119. data/generated/google/apis/deploymentmanager_v2beta2/representations.rb +303 -0
  120. data/generated/google/apis/deploymentmanager_v2beta2/service.rb +647 -0
  121. data/generated/google/apis/dfareporting_v2_1.rb +37 -0
  122. data/generated/google/apis/dfareporting_v2_1/classes.rb +10755 -0
  123. data/generated/google/apis/dfareporting_v2_1/representations.rb +3438 -0
  124. data/generated/google/apis/dfareporting_v2_1/service.rb +8775 -0
  125. data/generated/google/apis/discovery_v1.rb +32 -0
  126. data/generated/google/apis/discovery_v1/classes.rb +947 -0
  127. data/generated/google/apis/discovery_v1/representations.rb +355 -0
  128. data/generated/google/apis/discovery_v1/service.rb +144 -0
  129. data/generated/google/apis/dns_v1.rb +41 -0
  130. data/generated/google/apis/dns_v1/classes.rb +406 -0
  131. data/generated/google/apis/dns_v1/representations.rb +151 -0
  132. data/generated/google/apis/dns_v1/service.rb +460 -0
  133. data/{spec/google/api_client/request_spec.rb → generated/google/apis/doubleclickbidmanager_v1.rb} +15 -13
  134. data/generated/google/apis/doubleclickbidmanager_v1/classes.rb +709 -0
  135. data/generated/google/apis/doubleclickbidmanager_v1/representations.rb +297 -0
  136. data/generated/google/apis/doubleclickbidmanager_v1/service.rb +349 -0
  137. data/generated/google/apis/doubleclicksearch_v2.rb +35 -0
  138. data/generated/google/apis/doubleclicksearch_v2/classes.rb +947 -0
  139. data/generated/google/apis/doubleclicksearch_v2/representations.rb +315 -0
  140. data/generated/google/apis/doubleclicksearch_v2/service.rb +490 -0
  141. data/generated/google/apis/drive_v2.rb +55 -0
  142. data/generated/google/apis/drive_v2/classes.rb +2519 -0
  143. data/generated/google/apis/drive_v2/representations.rb +781 -0
  144. data/generated/google/apis/drive_v2/service.rb +2685 -0
  145. data/generated/google/apis/fitness_v1.rb +49 -0
  146. data/generated/google/apis/fitness_v1/classes.rb +809 -0
  147. data/generated/google/apis/fitness_v1/representations.rb +295 -0
  148. data/generated/google/apis/fitness_v1/service.rb +684 -0
  149. data/generated/google/apis/fusiontables_v2.rb +37 -0
  150. data/generated/google/apis/fusiontables_v2/classes.rb +1048 -0
  151. data/generated/google/apis/fusiontables_v2/representations.rb +409 -0
  152. data/generated/google/apis/fusiontables_v2/service.rb +1496 -0
  153. data/generated/google/apis/games_configuration_v1configuration.rb +34 -0
  154. data/generated/google/apis/games_configuration_v1configuration/classes.rb +506 -0
  155. data/generated/google/apis/games_configuration_v1configuration/representations.rb +206 -0
  156. data/generated/google/apis/games_configuration_v1configuration/service.rb +578 -0
  157. data/generated/google/apis/games_v1.rb +40 -0
  158. data/generated/google/apis/games_v1/classes.rb +4578 -0
  159. data/generated/google/apis/games_v1/representations.rb +1570 -0
  160. data/generated/google/apis/games_v1/service.rb +2306 -0
  161. data/generated/google/apis/gan_v1beta1.rb +31 -0
  162. data/generated/google/apis/gan_v1beta1/classes.rb +1428 -0
  163. data/generated/google/apis/gan_v1beta1/representations.rb +428 -0
  164. data/generated/google/apis/gan_v1beta1/service.rb +692 -0
  165. data/generated/google/apis/genomics_v1beta2.rb +46 -0
  166. data/generated/google/apis/genomics_v1beta2/classes.rb +3288 -0
  167. data/generated/google/apis/genomics_v1beta2/representations.rb +1194 -0
  168. data/generated/google/apis/genomics_v1beta2/service.rb +2356 -0
  169. data/generated/google/apis/gmail_v1.rb +49 -0
  170. data/generated/google/apis/gmail_v1/classes.rb +794 -0
  171. data/generated/google/apis/gmail_v1/representations.rb +339 -0
  172. data/generated/google/apis/gmail_v1/service.rb +1502 -0
  173. data/generated/google/apis/groupsmigration_v1.rb +34 -0
  174. data/generated/google/apis/groupsmigration_v1/classes.rb +51 -0
  175. data/generated/google/apis/groupsmigration_v1/representations.rb +38 -0
  176. data/generated/google/apis/groupsmigration_v1/service.rb +111 -0
  177. data/generated/google/apis/groupssettings_v1.rb +34 -0
  178. data/generated/google/apis/groupssettings_v1/classes.rb +221 -0
  179. data/generated/google/apis/groupssettings_v1/representations.rb +64 -0
  180. data/generated/google/apis/groupssettings_v1/service.rb +179 -0
  181. data/generated/google/apis/identitytoolkit_v3.rb +31 -0
  182. data/generated/google/apis/identitytoolkit_v3/classes.rb +1229 -0
  183. data/generated/google/apis/identitytoolkit_v3/representations.rb +422 -0
  184. data/generated/google/apis/identitytoolkit_v3/service.rb +491 -0
  185. data/generated/google/apis/licensing_v1.rb +34 -0
  186. data/generated/google/apis/licensing_v1/classes.rb +132 -0
  187. data/generated/google/apis/licensing_v1/representations.rb +68 -0
  188. data/generated/google/apis/licensing_v1/service.rb +376 -0
  189. data/generated/google/apis/logging_v1beta3.rb +35 -0
  190. data/generated/google/apis/logging_v1beta3/classes.rb +505 -0
  191. data/generated/google/apis/logging_v1beta3/representations.rb +222 -0
  192. data/generated/google/apis/logging_v1beta3/service.rb +670 -0
  193. data/generated/google/apis/manager_v1beta2.rb +50 -0
  194. data/generated/google/apis/manager_v1beta2/classes.rb +1287 -0
  195. data/generated/google/apis/manager_v1beta2/representations.rb +536 -0
  196. data/generated/google/apis/manager_v1beta2/service.rb +380 -0
  197. data/generated/google/apis/mapsengine_v1.rb +38 -0
  198. data/generated/google/apis/mapsengine_v1/classes.rb +2873 -0
  199. data/generated/google/apis/mapsengine_v1/representations.rb +1235 -0
  200. data/generated/google/apis/mapsengine_v1/service.rb +3465 -0
  201. data/generated/google/apis/mirror_v1.rb +37 -0
  202. data/generated/google/apis/mirror_v1/classes.rb +1072 -0
  203. data/generated/google/apis/mirror_v1/representations.rb +350 -0
  204. data/generated/google/apis/mirror_v1/service.rb +1001 -0
  205. data/generated/google/apis/oauth2_v2.rb +43 -0
  206. data/generated/google/apis/oauth2_v2/classes.rb +245 -0
  207. data/generated/google/apis/oauth2_v2/representations.rb +94 -0
  208. data/generated/google/apis/oauth2_v2/service.rb +203 -0
  209. data/generated/google/apis/pagespeedonline_v2.rb +32 -0
  210. data/generated/google/apis/pagespeedonline_v2/classes.rb +614 -0
  211. data/generated/google/apis/pagespeedonline_v2/representations.rb +244 -0
  212. data/generated/google/apis/pagespeedonline_v2/service.rb +120 -0
  213. data/generated/google/apis/plus_domains_v1.rb +61 -0
  214. data/generated/google/apis/plus_domains_v1/classes.rb +2402 -0
  215. data/generated/google/apis/plus_domains_v1/representations.rb +873 -0
  216. data/generated/google/apis/plus_domains_v1/service.rb +924 -0
  217. data/generated/google/apis/plus_v1.rb +43 -0
  218. data/generated/google/apis/plus_v1/classes.rb +2384 -0
  219. data/generated/google/apis/plus_v1/representations.rb +812 -0
  220. data/generated/google/apis/plus_v1/service.rb +616 -0
  221. data/generated/google/apis/prediction_v1_6.rb +44 -0
  222. data/generated/google/apis/prediction_v1_6/classes.rb +751 -0
  223. data/generated/google/apis/prediction_v1_6/representations.rb +327 -0
  224. data/generated/google/apis/prediction_v1_6/service.rb +388 -0
  225. data/generated/google/apis/pubsub_v1beta2.rb +37 -0
  226. data/generated/google/apis/pubsub_v1beta2/classes.rb +824 -0
  227. data/generated/google/apis/pubsub_v1beta2/representations.rb +366 -0
  228. data/generated/google/apis/pubsub_v1beta2/service.rb +778 -0
  229. data/generated/google/apis/qpx_express_v1.rb +31 -0
  230. data/generated/google/apis/qpx_express_v1/classes.rb +1268 -0
  231. data/generated/google/apis/qpx_express_v1/representations.rb +424 -0
  232. data/generated/google/apis/qpx_express_v1/service.rb +101 -0
  233. data/generated/google/apis/replicapool_v1beta2.rb +41 -0
  234. data/generated/google/apis/replicapool_v1beta2/classes.rb +621 -0
  235. data/generated/google/apis/replicapool_v1beta2/representations.rb +235 -0
  236. data/generated/google/apis/replicapool_v1beta2/service.rb +620 -0
  237. data/generated/google/apis/replicapoolupdater_v1beta1.rb +41 -0
  238. data/generated/google/apis/replicapoolupdater_v1beta1/classes.rb +682 -0
  239. data/generated/google/apis/replicapoolupdater_v1beta1/representations.rb +247 -0
  240. data/generated/google/apis/replicapoolupdater_v1beta1/service.rb +472 -0
  241. data/generated/google/apis/reseller_v1.rb +37 -0
  242. data/generated/google/apis/reseller_v1/classes.rb +502 -0
  243. data/generated/google/apis/reseller_v1/representations.rb +199 -0
  244. data/generated/google/apis/reseller_v1/service.rb +637 -0
  245. data/generated/google/apis/resourceviews_v1beta2.rb +47 -0
  246. data/generated/google/apis/resourceviews_v1beta2/classes.rb +660 -0
  247. data/generated/google/apis/resourceviews_v1beta2/representations.rb +269 -0
  248. data/generated/google/apis/resourceviews_v1beta2/service.rb +574 -0
  249. data/generated/google/apis/site_verification_v1.rb +37 -0
  250. data/generated/google/apis/site_verification_v1/classes.rb +185 -0
  251. data/generated/google/apis/site_verification_v1/representations.rb +101 -0
  252. data/generated/google/apis/site_verification_v1/service.rb +322 -0
  253. data/generated/google/apis/sqladmin_v1beta4.rb +37 -0
  254. data/generated/google/apis/sqladmin_v1beta4/classes.rb +1817 -0
  255. data/generated/google/apis/sqladmin_v1beta4/representations.rb +688 -0
  256. data/generated/google/apis/sqladmin_v1beta4/service.rb +1534 -0
  257. data/generated/google/apis/storage_v1.rb +43 -0
  258. data/generated/google/apis/storage_v1/classes.rb +1177 -0
  259. data/generated/google/apis/storage_v1/representations.rb +427 -0
  260. data/generated/google/apis/storage_v1/service.rb +1920 -0
  261. data/generated/google/apis/tagmanager_v1.rb +52 -0
  262. data/generated/google/apis/tagmanager_v1/classes.rb +1226 -0
  263. data/generated/google/apis/tagmanager_v1/representations.rb +461 -0
  264. data/generated/google/apis/tagmanager_v1/service.rb +1978 -0
  265. data/generated/google/apis/taskqueue_v1beta2.rb +37 -0
  266. data/generated/google/apis/taskqueue_v1beta2/classes.rb +254 -0
  267. data/generated/google/apis/taskqueue_v1beta2/representations.rb +114 -0
  268. data/generated/google/apis/taskqueue_v1beta2/service.rb +416 -0
  269. data/generated/google/apis/tasks_v1.rb +37 -0
  270. data/generated/google/apis/tasks_v1/classes.rb +296 -0
  271. data/generated/google/apis/tasks_v1/representations.rb +115 -0
  272. data/generated/google/apis/tasks_v1/service.rb +657 -0
  273. data/generated/google/apis/translate_v2.rb +31 -0
  274. data/generated/google/apis/translate_v2/classes.rb +168 -0
  275. data/generated/google/apis/translate_v2/representations.rb +109 -0
  276. data/generated/google/apis/translate_v2/service.rb +185 -0
  277. data/generated/google/apis/urlshortener_v1.rb +34 -0
  278. data/generated/google/apis/urlshortener_v1/classes.rb +246 -0
  279. data/generated/google/apis/urlshortener_v1/representations.rb +111 -0
  280. data/generated/google/apis/urlshortener_v1/service.rb +179 -0
  281. data/generated/google/apis/webmasters_v3.rb +37 -0
  282. data/generated/google/apis/webmasters_v3/classes.rb +563 -0
  283. data/generated/google/apis/webmasters_v3/representations.rb +250 -0
  284. data/generated/google/apis/webmasters_v3/service.rb +587 -0
  285. data/generated/google/apis/youtube_analytics_v1.rb +46 -0
  286. data/generated/google/apis/youtube_analytics_v1/classes.rb +540 -0
  287. data/generated/google/apis/youtube_analytics_v1/representations.rb +242 -0
  288. data/generated/google/apis/youtube_analytics_v1/service.rb +567 -0
  289. data/generated/google/apis/youtube_v3.rb +49 -0
  290. data/generated/google/apis/youtube_v3/classes.rb +7225 -0
  291. data/generated/google/apis/youtube_v3/representations.rb +2529 -0
  292. data/generated/google/apis/youtube_v3/service.rb +4051 -0
  293. data/google-api-client.gemspec +27 -39
  294. data/lib/google/api_client/auth/storage.rb +3 -2
  295. data/lib/google/api_client/auth/storages/file_store.rb +1 -3
  296. data/lib/google/api_client/auth/storages/redis_store.rb +6 -2
  297. data/lib/google/apis.rb +48 -0
  298. data/lib/google/apis/core/api_command.rb +128 -0
  299. data/lib/google/apis/core/base_service.rb +314 -0
  300. data/lib/google/apis/core/batch.rb +222 -0
  301. data/lib/google/apis/core/download.rb +94 -0
  302. data/lib/google/apis/core/hashable.rb +44 -0
  303. data/lib/google/apis/core/http_command.rb +275 -0
  304. data/lib/google/apis/core/json_representation.rb +122 -0
  305. data/lib/google/{api_client/version.rb → apis/core/logging.rb} +12 -8
  306. data/lib/google/apis/core/multipart.rb +173 -0
  307. data/lib/google/apis/core/upload.rb +275 -0
  308. data/lib/google/{api_client → apis}/errors.rb +32 -28
  309. data/lib/google/apis/generator.rb +70 -0
  310. data/lib/google/apis/generator/annotator.rb +271 -0
  311. data/lib/google/apis/generator/helpers.rb +74 -0
  312. data/lib/google/apis/generator/model.rb +130 -0
  313. data/lib/google/apis/generator/template.rb +124 -0
  314. data/lib/google/apis/generator/templates/_class.tmpl +40 -0
  315. data/lib/google/apis/generator/templates/_method.tmpl +90 -0
  316. data/lib/google/apis/generator/templates/_representation.tmpl +51 -0
  317. data/lib/google/apis/generator/templates/_representation_stub.tmpl +15 -0
  318. data/lib/google/apis/generator/templates/_representation_type.tmpl +10 -0
  319. data/lib/google/{api_client/reference.rb → apis/generator/templates/classes.rb.tmpl} +11 -9
  320. data/lib/google/apis/generator/templates/module.rb.tmpl +40 -0
  321. data/lib/google/apis/generator/templates/representations.rb.tmpl +32 -0
  322. data/lib/google/apis/generator/templates/service.rb.tmpl +60 -0
  323. data/lib/google/apis/options.rb +79 -0
  324. data/lib/google/apis/version.rb +39 -0
  325. data/rakelib/metrics.rake +22 -0
  326. data/rakelib/rubocop.rake +10 -0
  327. data/rakelib/spec.rake +11 -0
  328. data/rakelib/yard.rake +11 -0
  329. data/samples/calendar/calendar.rb +43 -0
  330. data/samples/drive/drive.rb +40 -0
  331. data/samples/pubsub/pubsub.rb +52 -0
  332. data/{lib/google/api_client/discovery.rb → samples/translate/translate.rb} +14 -5
  333. data/script/generate +79 -0
  334. data/script/package +8 -0
  335. data/script/release +15 -0
  336. data/spec/fixtures/files/api_names.yaml +3 -0
  337. data/spec/fixtures/files/auth_stored_credentials.json +8 -0
  338. data/spec/fixtures/files/client_secrets.json +1 -0
  339. data/spec/fixtures/files/test.blah +1 -0
  340. data/spec/fixtures/files/test.txt +1 -0
  341. data/spec/fixtures/files/test_api.json +440 -0
  342. data/spec/google/api_client/auth/storage_spec.rb +1 -3
  343. data/spec/google/api_client/auth/storages/file_store_spec.rb +1 -2
  344. data/spec/google/api_client/auth/storages/redis_store_spec.rb +1 -3
  345. data/spec/google/apis/core/api_command_spec.rb +170 -0
  346. data/spec/google/apis/core/batch_spec.rb +128 -0
  347. data/spec/google/apis/core/download_spec.rb +90 -0
  348. data/spec/google/apis/core/hashable_spec.rb +60 -0
  349. data/spec/google/apis/core/http_command_spec.rb +238 -0
  350. data/spec/google/apis/core/json_representation_spec.rb +192 -0
  351. data/spec/google/apis/core/service_spec.rb +247 -0
  352. data/spec/google/apis/core/upload_spec.rb +238 -0
  353. data/{lib/google/api_client/service_account.rb → spec/google/apis/generated_spec.rb} +14 -8
  354. data/spec/google/apis/generator/generator_spec.rb +272 -0
  355. data/spec/google/apis/logging_spec.rb +45 -0
  356. data/spec/google/apis/options_spec.rb +40 -0
  357. data/spec/integration_tests/drive_spec.rb +35 -0
  358. data/spec/integration_tests/pubsub_spec.rb +48 -0
  359. data/spec/integration_tests/url_shortener_spec.rb +31 -0
  360. data/spec/spec_helper.rb +102 -46
  361. metadata +433 -178
  362. data/lib/compat/multi_json.rb +0 -19
  363. data/lib/google/api_client.rb +0 -750
  364. data/lib/google/api_client/auth/file_storage.rb +0 -59
  365. data/lib/google/api_client/auth/jwt_asserter.rb +0 -126
  366. data/lib/google/api_client/auth/key_utils.rb +0 -93
  367. data/lib/google/api_client/auth/pkcs12.rb +0 -41
  368. data/lib/google/api_client/batch.rb +0 -326
  369. data/lib/google/api_client/charset.rb +0 -33
  370. data/lib/google/api_client/discovery/api.rb +0 -310
  371. data/lib/google/api_client/discovery/media.rb +0 -77
  372. data/lib/google/api_client/discovery/method.rb +0 -363
  373. data/lib/google/api_client/discovery/resource.rb +0 -156
  374. data/lib/google/api_client/discovery/schema.rb +0 -117
  375. data/lib/google/api_client/environment.rb +0 -42
  376. data/lib/google/api_client/gzip.rb +0 -28
  377. data/lib/google/api_client/logging.rb +0 -32
  378. data/lib/google/api_client/media.rb +0 -259
  379. data/lib/google/api_client/railtie.rb +0 -18
  380. data/lib/google/api_client/request.rb +0 -350
  381. data/lib/google/api_client/result.rb +0 -255
  382. data/lib/google/api_client/service.rb +0 -233
  383. data/lib/google/api_client/service/batch.rb +0 -110
  384. data/lib/google/api_client/service/request.rb +0 -144
  385. data/lib/google/api_client/service/resource.rb +0 -40
  386. data/lib/google/api_client/service/result.rb +0 -162
  387. data/lib/google/api_client/service/simple_file_store.rb +0 -151
  388. data/lib/google/api_client/service/stub_generator.rb +0 -61
  389. data/spec/google/api_client/batch_spec.rb +0 -248
  390. data/spec/google/api_client/discovery_spec.rb +0 -708
  391. data/spec/google/api_client/gzip_spec.rb +0 -98
  392. data/spec/google/api_client/media_spec.rb +0 -178
  393. data/spec/google/api_client/result_spec.rb +0 -207
  394. data/spec/google/api_client/service_account_spec.rb +0 -169
  395. data/spec/google/api_client/service_spec.rb +0 -618
  396. data/spec/google/api_client/simple_file_store_spec.rb +0 -133
  397. data/spec/google/api_client_spec.rb +0 -352
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 670147e4e2c5fde1aed72ab3774aa74321e40512
4
- data.tar.gz: f082392c923335d2de7da780fb694239ad3c745a
3
+ metadata.gz: 028a4cc7ea1dd004a24511d10bbc5f57901ab4c6
4
+ data.tar.gz: 3a2a4c1b22ddf53624736bd96c6be999798bb8b1
5
5
  SHA512:
6
- metadata.gz: f4f6f24c0442e8801e8582a131b5c3bac060dbfc9542a326d8525b97b237df522faa3cf6e2b9ac0d0160915a30080ca33e0aeb2805541435a8574b3be4b04cab
7
- data.tar.gz: 9a07c7aecac858ea22b2cb743bb508c890a07a0afb4f11e2e31cc32ef15c8902881e1c449007bb4e07d01ec7d04a3ce0c401de4eae8e5b2e271d45c981b37b7f
6
+ metadata.gz: 8195661fd5d8a642b7cee3296228ff82f460ad775e7c1432a7503fb9260f7ee60ecf2229d7a18111b977b3d9df1666f1693ed90842521dfde26a2cb7c4a82134
7
+ data.tar.gz: cc0a433396c213916086f277f1612c64755d19a0e40d91a669d175a5278e04cd8674730e9e5fb44873b85324965bedbe64fdfd639313a19b080f168eea6982e1
@@ -0,0 +1,20 @@
1
+ ._*
2
+ .DS_Store
3
+ .yardoc
4
+ .bundle
5
+ .rvmrc
6
+ Gemfile.lock
7
+ coverage
8
+ doc
9
+ heckling
10
+ pkg
11
+ specdoc
12
+ wiki
13
+ .google-api.yaml
14
+ *.log
15
+
16
+ #IntelliJ
17
+ .idea
18
+ *.iml
19
+ atlassian*
20
+
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -0,0 +1,7 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Metrics/LineLength:
4
+ Max: 120
5
+
6
+ Style/FormatString:
7
+ EnforcedStyle: sprintf
@@ -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
@@ -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
@@ -0,0 +1,12 @@
1
+ --hide-void-return
2
+ --no-private
3
+ --verbose
4
+ --markup-provider=redcarpet
5
+ --markup=markdown
6
+ lib/**/*.rb
7
+ generated/**/*.rb
8
+ -
9
+ README.md
10
+ MIGRATING.md
11
+ CONTRIBUTING.md
12
+ LICENSE
@@ -1,5 +1,8 @@
1
- # 0.8.7
2
- * Lock activesupport version to < 5.0
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 `:faraday_options` option to allow passthrough settings to Faraday connection
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
 
@@ -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
- gem 'jruby-openssl', :platforms => :jruby
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
@@ -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
- <dl>
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
- [![Build Status](https://secure.travis-ci.org/google/google-api-ruby-client.png)](http://travis-ci.org/google/google-api-ruby-client)
11
- [![Dependency Status](https://gemnasium.com/google/google-api-ruby-client.png)](https://gemnasium.com/google/google-api-ruby-client)
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
- ## Description
8
+ ## Migrating from 0.8.x
14
9
 
15
- The Google API Ruby Client makes it trivial to discover and access supported
16
- APIs.
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
- ## Alpha
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
19
16
 
20
- This library is in Alpha. We will make an effort to support the library, but we reserve the right to make incompatible changes when necessary.
17
+ ```ruby
18
+ gem 'google-api-client'
19
+ ```
21
20
 
22
- ## Install
21
+ And then execute:
23
22
 
24
- Be sure `https://rubygems.org/` is in your gem sources.
23
+ $ bundle
25
24
 
26
- For normal client usage, this is sufficient:
25
+ Or install it yourself as:
27
26
 
28
- ```bash
29
- $ gem install google-api-client
30
- ```
27
+ $ gem install google-api-client
31
28
 
32
- ## Example Usage
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/api_client'
36
- require 'google/api_client/client_secrets'
37
- require 'google/api_client/auth/installed_app'
38
-
39
- # Initialize the client.
40
- client = Google::APIClient.new(
41
- :application_name => 'Example Ruby application',
42
- :application_version => '1.0.0'
43
- )
44
-
45
- # Initialize Google+ API. Note this will make a request to the
46
- # discovery service every time, so be sure to use serialization
47
- # in your production code. Check the samples for more details.
48
- plus = client.discovered_api('plus')
49
-
50
- # Load client secrets from your client_secrets.json.
51
- client_secrets = Google::APIClient::ClientSecrets.load
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
- ## API Features
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
- ### API Discovery
68
+ ### Errors & Retries
74
69
 
75
- To take full advantage of the client, load API definitions prior to use. To load an API:
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
- urlshortener = client.discovered_api('urlshortener')
76
+ Google::Apis::RequestOptions.default.retries = 5
79
77
  ```
80
78
 
81
- Specific versions of the API can be loaded as well:
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 = client.discovered_api('drive', 'v2')
83
+ drive.insert_file(metadata, upload_source: 'test.txt', content_type: 'text/plain', options: { retries: 0 })
85
84
  ```
86
85
 
87
- Locally cached discovery documents may be used as well. To load an API from a local file:
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
- ```ruby
90
- # Output discovery document to JSON
91
- File.open('my-api.json', 'w') do |f| f.puts MultiJson.dump(client.discovery_document('myapi', 'v1')) end
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
- # Read discovery document and load API
94
- doc = File.read('my-api.json')
95
- client.register_discovery_document('myapi', 'v1', doc)
96
- my_api = client.discovered_api('myapi', 'v1')
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
- ### Authorization
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
- Most interactions with Google APIs require users to authorize applications via OAuth 2.0. The client library uses [Signet](https://github.com/google/signet) to handle most aspects of authorization. For additional details about Google's OAuth support, see [Google Developers](https://developers.google.com/accounts/docs/OAuth2).
109
+ ### Batches
102
110
 
103
- Credentials can be managed at the connection level, as shown, or supplied on a per-request basis when calling `execute`.
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
- As of version 0.8.3, service accounts can be configured using
108
- [Application Default Credentials][1], which rely on the credentials being
109
- available in a well-known location. If the credentials are not present
110
- and it's being used on a Compute Engine VM, it will use the VM's default credentials.
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
- client.authorization = :google_app_default # in a later version, this will become the default
114
- client.authorization.fetch_access_token!
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
- This is simpler API to use than in previous versions, although that is still available:
144
+ is equivalent to:
119
145
 
120
146
  ```ruby
121
- key = Google::APIClient::KeyUtils.load_from_pkcs12('client.p12', 'notasecret')
122
- client.authorization = Signet::OAuth2::Client.new(
123
- :token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
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
- Service accounts are also used for delegation in Google Apps domains. The target user for impersonation is specified by setting the `:person` parameter to the user's email address
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
- ### Automatic Retries & Backoff
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 API client can automatically retry requests for recoverable errors. To enable retries, set the `client.retries` property to
138
- the number of additional attempts. To avoid flooding servers, retries invovle a 1 second delay that increases on each subsequent retry.
139
- In the case of authentication token expiry, the API client will attempt to refresh the token and retry the failed operation - this
140
- is a specific exception to the retry rules.
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
- The default value for retries is 0, but will be enabled by default in future releases.
165
+ For per-user authorization, use [Signet](https://github.com/google/signet) to obtain user authorization.
143
166
 
144
- ### Batching Requests
167
+ ### Passing authorization to requests
145
168
 
146
- Some Google APIs support batching requests into a single HTTP request. Use `Google::APIClient::BatchRequest`
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
- Example:
171
+ Set authorization for all service:
150
172
 
151
173
  ```ruby
152
- client = Google::APIClient.new
153
- urlshortener = client.discovered_api('urlshortener')
174
+ Google::Apis::RequestOptions.default.authorization = authorization
175
+ # Services instantiated after this will inherit the authorization
176
+ ```
154
177
 
155
- batch = Google::APIClient::BatchRequest.new do |result|
156
- puts result.data
157
- end
178
+ On a per-service level:
179
+
180
+ ```ruby
181
+ drive = Google::Apis::DriveV2::DriveService.new
182
+ drive.authorization = authorization
158
183
 
159
- batch.add(:api_method => urlshortener.url.insert,
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
- Blocks for handling responses can be specified either at the batch level or when adding an individual API call. For example:
187
+ Per-request:
167
188
 
168
189
  ```ruby
169
- batch.add(:api_method=>urlshortener.url.insert, :body_object => { 'longUrl' => 'http://example.com/bar' }) do |result|
170
- puts result.data
171
- end
190
+ drive.get_file('123', options: { authorization: authorization })
172
191
  ```
173
192
 
174
- ### Media Upload
193
+ ## Generating APIs
175
194
 
176
- For APIs that support file uploads, use `Google::APIClient::UploadIO` to load the stream. Both multipart and resumable
177
- uploads can be used. For example, to upload a file to Google Drive using multipart
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
- ```ruby
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
- To use resumable uploads, change the `uploadType` parameter to `resumable`. To check the status of the upload
194
- and continue if necessary, check `result.resumable_upload`.
200
+ $ generate-api gen <outdir> --file=<path>
195
201
 
196
- ```ruby
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
- ## Samples
204
+ $ generate-api gen <outdir> --url=<url>
210
205
 
211
- See the full list of [samples on Github](https://github.com/google/google-api-ruby-client-samples).
206
+ ## TODO
212
207
 
208
+ * ETag support (if-not-modified)
209
+ * Auto-paging results (maybe)
210
+ * Caching
211
+ * Model validations
213
212
 
214
- ## Support
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
- Please [report bugs at the project on Github](https://github.com/google/google-api-ruby-client/issues). Don't hesitate to [ask questions](http://stackoverflow.com/questions/tagged/google-api-ruby-client) about the client or APIs on [StackOverflow](http://stackoverflow.com).
220
+ See [CONTRIBUTING](contributing).
221
+
222
+ ## Support
217
223
 
218
- [1]: https://developers.google.com/accounts/docs/application-default-credentials
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).