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
@@ -97,11 +97,20 @@ module Google
97
97
  # Fragment of the discovery doc describing the method
98
98
  def infer_method_name_for_rpc(method)
99
99
  return nil if method.request.nil?
100
- verb = ActiveSupport::Inflector.underscore(method.id.split('.').last)
100
+ parts = method.id.split('.')
101
+ parts.shift
102
+ verb = ActiveSupport::Inflector.underscore(parts.pop)
101
103
  match = method.request._ref.match(/(.*)(?i:request)/)
102
104
  return nil if match.nil?
103
105
  name = ActiveSupport::Inflector.underscore(match[1])
104
106
  return nil unless name == verb || name.start_with?(verb + '_')
107
+ if !parts.empty?
108
+ resource_name = ActiveSupport::Inflector.singularize(parts.pop)
109
+ resource_name = ActiveSupport::Inflector.underscore(resource_name)
110
+ if !name.include?(resource_name)
111
+ name = name.split('_').insert(1, resource_name).join('_')
112
+ end
113
+ end
105
114
  name
106
115
  end
107
116
 
@@ -112,17 +121,24 @@ module Google
112
121
  def infer_method_name_from_id(method)
113
122
  parts = method.id.split('.')
114
123
  parts.shift
115
- verb = parts.pop
116
- return ActiveSupport::Inflector.underscore(verb) if parts.empty?
117
- resource_name = parts.pop
118
- method_name = verb + '_'
119
- method_name += parts.map { |p| ActiveSupport::Inflector.singularize(p) }.join('_') + '_' unless parts.empty?
124
+ verb = ActiveSupport::Inflector.underscore(parts.pop)
125
+ return verb if parts.empty?
126
+ resource_name = ActiveSupport::Inflector.underscore(parts.pop)
120
127
  if pluralize_method?(verb)
121
- method_name += ActiveSupport::Inflector.pluralize(resource_name)
128
+ resource_name = ActiveSupport::Inflector.pluralize(resource_name)
122
129
  else
123
- method_name += ActiveSupport::Inflector.singularize(resource_name)
130
+ resource_name = ActiveSupport::Inflector.singularize(resource_name)
124
131
  end
125
- ActiveSupport::Inflector.underscore(method_name)
132
+ if parts.empty?
133
+ resource_path = resource_name
134
+ else
135
+ resource_path = parts.map do |p|
136
+ p = ActiveSupport::Inflector.singularize(p)
137
+ ActiveSupport::Inflector.underscore(p)
138
+ end.join('_') + '_' + resource_name
139
+ end
140
+ method_name = verb.split('_').insert(1, resource_path.split('_')).join('_')
141
+ method_name
126
142
  end
127
143
  end
128
144
 
@@ -260,7 +276,10 @@ module Google
260
276
 
261
277
  def check_duplicate_method(m)
262
278
  if @all_methods.include?(m.generated_name)
263
- logger.error { sprintf('Duplicate method %s generated', m.generated_name) }
279
+ logger.error do
280
+ sprintf('Duplicate method %s generated, path %s',
281
+ m.generated_name, @names.key)
282
+ end
264
283
  fail 'Duplicate name generated'
265
284
  end
266
285
  @all_methods[m.generated_name] = m
@@ -6,7 +6,7 @@ module Google
6
6
  module NameHelpers
7
7
  KEYWORDS = %w(__ENCODING__ def in self __LINE__ defined? module super __FILE__ do next then BEGIN
8
8
  else nil true END elsif not undef alias end or unless and ensure redo until begin
9
- false rescue when break for retry while case if return yield class)
9
+ false rescue when break for retry while case if return yield class command)
10
10
  PLURAL_METHODS = %w(list search)
11
11
 
12
12
  # Check to see if the method name should be plauralized
@@ -50,24 +50,23 @@
50
50
  # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
51
51
  # @raise [Google::Apis::AuthorizationError] Authorization is required
52
52
  def <%= api_method.generated_name %>(<% for param in api_method.required_parameters %><%= param.generated_name %>, <% end %><% if api_method.request %><%= api.schemas[api_method.request._ref].generated_name %>_object = nil, <% end %><% for param in api_method.optional_query_parameters %><%= param.generated_name %>: nil, <% end %><% for param in api.parameters.values.reject {|p| p.name == 'key'} %><%= param.generated_name %>: nil, <% end %><% if api_method.supports_media_upload? %>upload_source: nil, content_type: nil, <% elsif api_method.supports_media_download? %>download_dest: nil, <% end %>options: nil, &block)
53
- path = '<%= api_method.path %>'
54
53
  <% if api_method.supports_media_upload? -%>
55
54
  if upload_source.nil?
56
- command = make_simple_command(:<%= api_method.http_method.downcase %>, path, options)
55
+ command = make_simple_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
57
56
  else
58
- command = make_upload_command(:<%= api_method.http_method.downcase %>, path, options)
57
+ command = make_upload_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
59
58
  command.upload_source = upload_source
60
59
  command.upload_content_type = content_type
61
60
  end
62
61
  <% elsif api_method.supports_media_download? -%>
63
62
  if download_dest.nil?
64
- command = make_simple_command(:<%= api_method.http_method.downcase %>, path, options)
63
+ command = make_simple_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
65
64
  else
66
- command = make_download_command(:<%= api_method.http_method.downcase %>, path, options)
65
+ command = make_download_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
67
66
  command.download_dest = download_dest
68
67
  end
69
68
  <% else -%>
70
- command = make_simple_command(:<%= api_method.http_method.downcase %>, path, options)
69
+ command = make_simple_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
71
70
  <% end -%>
72
71
  <% if api_method.request -%>
73
72
  command.request_representation = <%= api.schemas[api_method.request._ref].generated_type %>::Representation
@@ -24,7 +24,8 @@ module Google
24
24
  :authorization,
25
25
  :retries,
26
26
  :header,
27
- :timeout_sec)
27
+ :timeout_sec,
28
+ :open_timeout_sec)
28
29
 
29
30
  # General client options
30
31
  class ClientOptions
@@ -44,12 +45,14 @@ module Google
44
45
 
45
46
  # Request options
46
47
  class RequestOptions
47
- # @!attribute [rw] credentials
48
+ # @!attribute [rw] authorization
48
49
  # @return [Signet::OAuth2::Client, #apply(Hash)] OAuth2 credentials
49
50
  # @!attribute [rw] retries
50
51
  # @return [Fixnum] Number of times to retry requests on server error
51
52
  # @!attribute [rw] timeout_sec
52
53
  # @return [Fixnum] How long, in seconds, before requests time out
54
+ # @!attribute [rw] open_timeout_sec
55
+ # @return [Fixnum] How long, in seconds, before failed connections time out
53
56
  # @!attribute [rw] header
54
57
  # @return [Hash<String,String] Additional HTTP headers to include in requests
55
58
 
@@ -63,7 +66,7 @@ module Google
63
66
  return self if options.nil?
64
67
 
65
68
  new_options = dup
66
- %w(authorization retries timeout_sec).each do |opt|
69
+ members.each do |opt|
67
70
  opt = opt.to_sym
68
71
  new_options[opt] = options[opt] unless options[opt].nil?
69
72
  end
@@ -75,5 +78,6 @@ module Google
75
78
  ClientOptions.default.application_version = '0.0.0'
76
79
 
77
80
  RequestOptions.default.retries = 0
81
+ RequestOptions.default.open_timeout_sec = 20
78
82
  end
79
83
  end
@@ -15,7 +15,7 @@
15
15
  module Google
16
16
  module Apis
17
17
  # Client library version
18
- VERSION = '0.9.pre3'
18
+ VERSION = '0.9.pre4'
19
19
 
20
20
  # Current operating system
21
21
  # @private
@@ -33,7 +33,7 @@ puts "Created event '#{event.summary}' (#{event.id})"
33
33
  events = calendar.list_events('primary', max_results: 10, single_events: true,
34
34
  order_by: 'startTime', time_min: Time.now.iso8601)
35
35
  puts "Upcoming events:"
36
- events.items.each do |evt|
36
+ events.items.each do |event|
37
37
  start = event.start.date || event.start.date_time
38
38
  puts "- #{event.summary} (#{start}) (ID: #{event.id})"
39
39
  end
@@ -12,6 +12,13 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ # Pass all auth variables to .env file
16
+ # Read more about auth on https://developers.google.com/drive/web/about-auth
17
+ # For example, in my case I added GOOGLE_APPLICATION_CREDENTIALS=credentials.json
18
+
19
+ require 'dotenv'
20
+ Dotenv.load
21
+
15
22
  require 'tempfile'
16
23
  require 'googleauth'
17
24
  require 'google/apis/drive_v2'
@@ -22,7 +29,7 @@ drive = Drive::DriveService.new
22
29
  drive.authorization = Google::Auth.get_application_default([Drive::AUTH_DRIVE])
23
30
 
24
31
  # Insert a file
25
- file = drive.insert_file({title: 'drive.rb'}, upload_source: 'drive.rb')
32
+ file = drive.insert_file({title: 'drive.rb'}, upload_source: __FILE__)
26
33
  puts "Created file #{file.title} (#{file.id})"
27
34
 
28
35
  # Search for it
@@ -37,4 +44,4 @@ tmp = drive.get_file(file.id, download_dest: Tempfile.new('drive'))
37
44
 
38
45
  # Delete it
39
46
  drive.delete_file(file.id)
40
- puts "File deleted"
47
+ puts "File deleted"
@@ -13,9 +13,9 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require 'googleauth'
16
- require 'google/apis/pubsub_v1beta2'
16
+ require 'google/apis/pubsub_v1'
17
17
 
18
- Pubsub = Google::Apis::PubsubV1beta2
18
+ Pubsub = Google::Apis::PubsubV1
19
19
 
20
20
  pubsub = Pubsub::PubsubService.new
21
21
  pubsub.authorization = Google::Auth.get_application_default([Pubsub::AUTH_PUBSUB])
@@ -33,10 +33,10 @@ pubsub.create_subscription(subscription, Pubsub::Subscription.new(topic: topic))
33
33
  request = Pubsub::PublishRequest.new(messages: [])
34
34
  request.messages << Pubsub::Message.new(attributes: { "language" => "en" }, data: 'Hello')
35
35
  request.messages << Pubsub::Message.new(attributes: { "language" => "en" }, data: 'World')
36
- pubsub.publish(topic, request)
36
+ pubsub.publish_topic(topic, request)
37
37
 
38
38
  # Pull messages
39
- response = pubsub.pull(subscription, Pubsub::PullRequest.new(max_messages: 5))
39
+ response = pubsub.pull_subscription(subscription, Pubsub::PullRequest.new(max_messages: 5))
40
40
  response.received_messages.each do |received_message|
41
41
  data = received_message.message.data
42
42
  puts "Received #{data}"
@@ -44,9 +44,8 @@ end
44
44
 
45
45
  # Acknowledge receipt
46
46
  ack_ids = response.received_messages.map{ |msg| msg.ack_id }
47
- pubsub.acknowledge(subscription, Pubsub::AcknowledgeRequest.new(ack_ids: ack_ids))
47
+ pubsub.acknowledge_subscription(subscription, Pubsub::AcknowledgeRequest.new(ack_ids: ack_ids))
48
48
 
49
49
  # Delete the subscription & topic
50
50
  pubsub.delete_subscription(subscription)
51
51
  pubsub.delete_topic(topic)
52
-
@@ -12,11 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require 'tempfile'
16
- require 'googleauth'
17
- require 'google/apis/translate_v2'
18
15
 
19
- Google::Apis.logger.level = Logger::DEBUG
16
+ require 'google/apis/translate_v2'
20
17
 
21
18
  Translate = Google::Apis::TranslateV2
22
19
 
@@ -25,4 +22,3 @@ translate.key = ARGV[0] || 'YOUR_API_KEY'
25
22
 
26
23
  result = translate.list_translations(source: 'en', target: 'es', q: 'Hello world!')
27
24
  puts result.translations.first.translated_text
28
-
data/script/generate CHANGED
@@ -7,12 +7,14 @@ DIR=$(dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))
7
7
  APIS=(adexchangebuyer:v1.3 \
8
8
  adexchangeseller:v2.0 \
9
9
  admin:directory_v1 \
10
+ admin:datatransfer_v1 \
10
11
  admin:reports_v1 \
11
12
  adsense:v1.4 \
12
13
  adsensehost:v4.1 \
13
14
  analytics:v3 \
14
15
  androidenterprise:v1 \
15
16
  androidpublisher:v2 \
17
+ appengine:v1beta4 \
16
18
  appsactivity:v1 \
17
19
  appstate:v1 \
18
20
  autoscaler:v1beta2 \
@@ -21,33 +23,40 @@ APIS=(adexchangebuyer:v1.3 \
21
23
  books:v1 \
22
24
  calendar:v3 \
23
25
  civicinfo:v2 \
24
- classroom:v1beta1 \
26
+ classroom:v1 \
27
+ cloudbilling:v1 \
28
+ clouddebugger:v2 \
25
29
  cloudmonitoring:v2beta2 \
26
30
  cloudresourcemanager:v1beta1 \
31
+ cloudtrace:v1 \
32
+ clouduseraccounts:beta \
27
33
  compute:v1 \
34
+ compute:beta \
28
35
  container:v1 \
29
36
  content:v2 \
30
37
  coordinate:v1 \
31
38
  customsearch:v1 \
32
39
  datastore:v1beta2 \
33
- deploymentmanager:v2beta2 \
40
+ deploymentmanager:v2 \
34
41
  dfareporting:v2.1 \
35
42
  discovery:v1 \
36
43
  dns:v1 \
37
44
  doubleclickbidmanager:v1 \
38
45
  doubleclicksearch:v2 \
39
46
  drive:v2 \
47
+ drive:v3 \
40
48
  fitness:v1 \
41
49
  fusiontables:v2 \
42
50
  games:v1 \
43
51
  gamesConfiguration:v1configuration \
44
- gamesConfiguration:v1management \
52
+ gamesManagement:v1management \
45
53
  gan:v1beta1 \
46
54
  genomics:v1 \
47
55
  gmail:v1 \
48
56
  groupsmigration:v1 \
49
57
  groupssettings:v1 \
50
58
  identitytoolkit:v3 \
59
+ kgsearch:v1 \
51
60
  licensing:v1 \
52
61
  logging:v1beta3 \
53
62
  manager:v1beta2 \
@@ -55,18 +64,22 @@ APIS=(adexchangebuyer:v1.3 \
55
64
  mirror:v1 \
56
65
  oauth2:v2 \
57
66
  pagespeedonline:v2 \
67
+ partners:v2 \
58
68
  plus:v1 \
59
69
  plusDomains:v1 \
60
70
  prediction:v1.6 \
61
- pubsub:v1beta2 \
71
+ proximitybeacon:v1beta1 \
72
+ pubsub:v1 \
62
73
  qpxExpress:v1 \
63
74
  replicapool:v1beta2 \
64
75
  replicapoolupdater:v1beta1 \
65
76
  reseller:v1 \
66
77
  resourceviews:v1beta2 \
78
+ script:v1 \
67
79
  siteVerification:v1 \
68
80
  sqladmin:v1beta4 \
69
81
  storage:v1 \
82
+ storagetransfer:v1 \
70
83
  tagmanager:v1 \
71
84
  taskqueue:v1beta2 \
72
85
  tasks:v1 \
@@ -75,6 +88,8 @@ APIS=(adexchangebuyer:v1.3 \
75
88
  webmasters:v3 \
76
89
  youtube:v3 \
77
90
  youtubeAnalytics:v1 \
91
+ youtubereporting:v1 \
78
92
  )
79
93
 
80
- echo 'a' | bundle exec bin/generate-api gen generated --names_out=$DIR/api_names_out.yaml --id=${APIS[*]}
94
+
95
+ echo 'a' | bundle exec bin/generate-api gen generated --from-discovery=true --names_out=$DIR/api_names_out.yaml --url='https://content.googleapis.com/discovery/v1/apis/compute/beta/rest' --id=${APIS[*]}
File without changes
@@ -0,0 +1 @@
1
+ {"invalid"}
@@ -48,6 +48,43 @@ RSpec.describe Google::APIClient::ClientSecrets do
48
48
  expect(hash["installed"]["client_secret"]).to be == 'i8YaXdGgiQ4_KrTVNGsB7QP1'
49
49
  end
50
50
 
51
+ it 'should remove empty value' do
52
+ expect(hash["installed"]["redirect_uris"]).to be nil
53
+ end
54
+
55
+ it 'should remove nil values' do
56
+ expect(hash["installed"]["issued_at"]).to be nil
57
+ end
58
+ end
59
+ end
60
+
61
+ context 'with no existing JSON file' do
62
+ it 'should raise exception' do
63
+ file = File.join(FIXTURES_PATH, 'files', 'no_file.json')
64
+ expect { Google::APIClient::ClientSecrets.load(file) }.to raise_exception(Errno::ENOENT)
65
+ end
66
+ end
67
+
68
+ context 'with invalid JSON file' do
69
+ it 'should raise exception' do
70
+ file = File.join(FIXTURES_PATH, 'files', 'invalid.json')
71
+ expect { Google::APIClient::ClientSecrets.load(file) }.to raise_exception(MultiJson::ParseError)
51
72
  end
52
73
  end
53
- end
74
+
75
+ context 'with folder name, which have json file in parents' do
76
+ it 'should load the correct client id' do
77
+ folder = File.join(FIXTURES_PATH, 'files', 'child')
78
+ secrets = Google::APIClient::ClientSecrets.load(folder)
79
+ expect(secrets.client_id).to be == '898243283568.apps.googleusercontent.com'
80
+ end
81
+ end
82
+
83
+ context 'with folder wihout client_secrets.json' do
84
+ it "should raise exception", fakefs: true do
85
+ FileUtils.mkdir("/tmp")
86
+ expect { Google::APIClient::ClientSecrets.load('/tmp') }.to raise_exception(ArgumentError)
87
+ end
88
+ end
89
+
90
+ end
@@ -42,9 +42,12 @@ RSpec.describe Google::Apis::Core::BatchCommand do
42
42
  end
43
43
 
44
44
  before(:example) do
45
+ allow(SecureRandom).to receive(:uuid).and_return('ffe23d1b-e8f7-47f5-8c01-2a30cf8ecb8f')
46
+
45
47
  response = <<EOF
46
48
  --batch123
47
49
  Content-Type: application/http
50
+ Content-ID: <response-ffe23d1b-e8f7-47f5-8c01-2a30cf8ecb8f+0>
48
51
 
49
52
  HTTP/1.1 200 OK
50
53
  Content-Type: text/plain; charset=UTF-8
@@ -52,18 +55,20 @@ Content-Type: text/plain; charset=UTF-8
52
55
  Hello
53
56
  --batch123
54
57
  Content-Type: application/http
58
+ Content-ID: <response-ffe23d1b-e8f7-47f5-8c01-2a30cf8ecb8f+2>
55
59
 
56
- HTTP/1.1 200 OK
60
+ HTTP/1.1 500 Server Error
57
61
  Content-Type: text/plain; charset=UTF-8
58
62
 
59
- world
63
+ Error!
60
64
  --batch123
61
65
  Content-Type: application/http
66
+ Content-ID: <response-ffe23d1b-e8f7-47f5-8c01-2a30cf8ecb8f+1>
62
67
 
63
- HTTP/1.1 500 Server Error
68
+ HTTP/1.1 200 OK
64
69
  Content-Type: text/plain; charset=UTF-8
65
70
 
66
- Error!
71
+ world
67
72
  --batch123--
68
73
  EOF
69
74
  stub_request(:post, 'https://www.googleapis.com/batch')
@@ -80,6 +85,7 @@ EOF
80
85
  expected_body = <<EOF.gsub(/\n/, "\r\n")
81
86
  --RubyApiBatchRequest
82
87
  Content-Length: 58
88
+ Content-ID: <ffe23d1b-e8f7-47f5-8c01-2a30cf8ecb8f+0>
83
89
  Content-Type: application/http
84
90
  Content-Transfer-Encoding: binary
85
91
 
@@ -89,6 +95,7 @@ Host: www.googleapis.com
89
95
 
90
96
  --RubyApiBatchRequest
91
97
  Content-Length: 96
98
+ Content-ID: <ffe23d1b-e8f7-47f5-8c01-2a30cf8ecb8f+1>
92
99
  Content-Type: application/http
93
100
  Content-Transfer-Encoding: binary
94
101
 
@@ -99,6 +106,7 @@ Host: www.googleapis.com
99
106
  Hello world
100
107
  --RubyApiBatchRequest
101
108
  Content-Length: 93
109
+ Content-ID: <ffe23d1b-e8f7-47f5-8c01-2a30cf8ecb8f+2>
102
110
  Content-Type: application/http
103
111
  Content-Transfer-Encoding: binary
104
112
 
@@ -115,11 +123,17 @@ EOF
115
123
 
116
124
  it 'should send decode responses' do
117
125
  expect do |b|
118
- command.add(get_command, &b)
119
- command.add(post_with_string_command, &b)
120
- command.add(post_with_io_command, &b)
126
+ command.add(get_command) do |res, err|
127
+ b.to_proc.call(1, res, err)
128
+ end
129
+ command.add(post_with_string_command) do |res, err|
130
+ b.to_proc.call(2, res, err)
131
+ end
132
+ command.add(post_with_io_command) do |res, err|
133
+ b.to_proc.call(3, res, err)
134
+ end
121
135
  command.execute(client)
122
- end.to yield_successive_args(['Hello', nil], ['world', nil], [nil, an_instance_of(Google::Apis::ServerError)])
136
+ end.to yield_successive_args([1, 'Hello', nil], [3, nil, an_instance_of(Google::Apis::ServerError)], [2, 'world', nil],)
123
137
  end
124
138
 
125
139
  it 'should raise error if batch is empty' do