gapic-generator 0.11.0 → 0.45.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +303 -0
  3. data/CONTRIBUTING.md +1 -1
  4. data/README.md +71 -37
  5. data/bin/protoc-gen-ruby_gapic +2 -2
  6. data/lib/gapic/file_formatter.rb +23 -19
  7. data/lib/gapic/formatting_utils.rb +24 -10
  8. data/lib/gapic/gem_builder.rb +15 -17
  9. data/lib/gapic/generator/version.rb +1 -1
  10. data/lib/gapic/generators/base_generator.rb +6 -4
  11. data/lib/gapic/generators/default_generator.rb +70 -34
  12. data/lib/gapic/generators/default_generator_parameters.rb +9 -3
  13. data/lib/gapic/grpc_service_config/parser.rb +2 -2
  14. data/lib/gapic/model/api_metadata.rb +173 -0
  15. data/lib/gapic/model/method/http_annotation.rb +158 -60
  16. data/lib/gapic/model/method/lro.rb +8 -5
  17. data/lib/gapic/model/method/routing.rb +3 -18
  18. data/lib/gapic/model/mixins.rb +76 -10
  19. data/lib/gapic/model/service/nonstandard_lro_provider.rb +10 -11
  20. data/lib/gapic/package_snippets.rb +159 -0
  21. data/lib/gapic/path_pattern/parser.rb +11 -2
  22. data/lib/gapic/path_pattern/pattern.rb +18 -1
  23. data/lib/gapic/path_pattern/segment.rb +11 -4
  24. data/lib/gapic/presenters/enum_presenter.rb +14 -0
  25. data/lib/gapic/presenters/enum_value_presenter.rb +4 -1
  26. data/lib/gapic/presenters/field_presenter.rb +78 -21
  27. data/lib/gapic/presenters/gem_presenter.rb +109 -35
  28. data/lib/gapic/presenters/message_presenter.rb +15 -0
  29. data/lib/gapic/presenters/method/{rest_pagination_info.rb → compute_pagination_info.rb} +31 -20
  30. data/lib/gapic/presenters/method/http_binding_presenter.rb +128 -0
  31. data/lib/gapic/presenters/method_presenter.rb +109 -35
  32. data/lib/gapic/presenters/method_rest_presenter.rb +83 -137
  33. data/lib/gapic/presenters/package_presenter.rb +63 -18
  34. data/lib/gapic/presenters/resource_presenter.rb +9 -3
  35. data/lib/gapic/presenters/service/lro_client_presenter.rb +14 -14
  36. data/lib/gapic/presenters/service/mixin_client_presenter.rb +89 -0
  37. data/lib/gapic/presenters/service/sub_client_presenter.rb +84 -0
  38. data/lib/gapic/presenters/service_presenter.rb +183 -31
  39. data/lib/gapic/presenters/service_rest_presenter.rb +180 -27
  40. data/lib/gapic/presenters/snippet/client_call_presenter.rb +82 -0
  41. data/lib/gapic/presenters/snippet/client_initialization_presenter.rb +87 -0
  42. data/lib/gapic/presenters/snippet/declaration_presenter.rb +91 -0
  43. data/lib/gapic/presenters/snippet/expression_presenter.rb +154 -0
  44. data/lib/gapic/presenters/snippet/iteration_presenter.rb +118 -0
  45. data/lib/gapic/presenters/snippet/parameter_presenter.rb +67 -0
  46. data/lib/gapic/presenters/snippet/request_initialization_presenters.rb +202 -0
  47. data/lib/gapic/presenters/snippet/response_handling_presenters.rb +329 -0
  48. data/lib/gapic/presenters/snippet/statement_presenter.rb +134 -0
  49. data/lib/gapic/presenters/snippet/type_presenter.rb +98 -0
  50. data/lib/gapic/presenters/snippet_presenter.rb +199 -10
  51. data/lib/gapic/presenters.rb +2 -0
  52. data/lib/gapic/runner.rb +1 -1
  53. data/lib/gapic/schema/api.rb +49 -3
  54. data/lib/gapic/schema/loader.rb +67 -22
  55. data/lib/gapic/schema/parameter_schema.rb +8 -8
  56. data/lib/gapic/schema/proto_tools.rb +193 -0
  57. data/lib/gapic/schema/request_param_parser.rb +5 -7
  58. data/lib/gapic/schema/service_config_parser.rb +38 -4
  59. data/lib/gapic/schema/wrappers.rb +192 -31
  60. data/lib/gapic/uri_template/parser.rb +15 -7
  61. data/lib/google/cloud/tools/snippetgen/configlanguage/v1/snippet_config_language_pb.rb +104 -0
  62. data/lib/google/cloud/tools/snippetgen/snippetindex/v1/snippet_index_pb.rb +58 -0
  63. data/lib/google/protobuf/compiler/plugin_pb.rb +47 -0
  64. data/templates/default/binding_override.text.erb +6 -0
  65. data/templates/default/gem/gemfile.text.erb +12 -0
  66. data/templates/default/gem/{gemspec.erb → gemspec.text.erb} +3 -11
  67. data/templates/default/gem/{readme.erb → readme.text.erb} +10 -6
  68. data/templates/default/gem/{rubocop.erb → rubocop.text.erb} +3 -0
  69. data/templates/default/gem/{test_helper.erb → test_helper.text.erb} +4 -2
  70. data/templates/default/gem/toys.text.erb +12 -0
  71. data/templates/default/helpers/default_helper.rb +33 -1
  72. data/templates/default/lib/_binding_override.text.erb +49 -0
  73. data/templates/default/lib/{_package.erb → _package.text.erb} +6 -9
  74. data/templates/default/lib/_package_rest.text.erb +24 -0
  75. data/templates/default/lib/{_service.erb → _service.text.erb} +11 -23
  76. data/templates/default/lib/package/_self_configure.text.erb +16 -0
  77. data/templates/default/lib/package/_self_configure_defaults.text.erb +13 -0
  78. data/templates/default/lib/package/self_configure/_binding_default.text.erb +15 -0
  79. data/templates/default/lib/rest/_rest.text.erb +46 -0
  80. data/templates/default/package_rest.text.erb +6 -0
  81. data/templates/default/proto_docs/_deprecated.text.erb +9 -0
  82. data/templates/default/proto_docs/{_enum.erb → _enum.text.erb} +1 -0
  83. data/templates/default/proto_docs/{_message.erb → _message.text.erb} +2 -0
  84. data/templates/default/service/client/{_client.erb → _client.text.erb} +60 -12
  85. data/templates/default/service/client/{_config.erb → _config.text.erb} +39 -8
  86. data/templates/default/service/client/{_operations.erb → _operations.text.erb} +24 -3
  87. data/templates/default/service/client/method/{_def.erb → _def.text.erb} +2 -2
  88. data/templates/default/service/client/method/def/{_options_defaults.erb → _options_defaults.text.erb} +2 -1
  89. data/templates/default/service/client/method/def/_request_normal.text.erb +18 -0
  90. data/templates/default/service/client/method/def/_request_streaming.text.erb +23 -0
  91. data/templates/default/service/client/method/def/{_response.erb → _response.text.erb} +2 -0
  92. data/templates/default/service/client/method/def/{_response_nonstandard_lro.erb → _response_nonstandard_lro.text.erb} +1 -1
  93. data/templates/default/service/client/method/def/_response_normal.text.erb +4 -0
  94. data/templates/default/service/client/method/def/{_response_normal.erb → _response_normal_lro.text.erb} +1 -3
  95. data/templates/default/service/client/method/def/{_response_paged.erb → _response_paged.text.erb} +1 -1
  96. data/templates/default/service/client/method/docs/{_request_normal.erb → _request_normal.text.erb} +1 -1
  97. data/templates/default/service/client/method/docs/_snippets.text.erb +6 -0
  98. data/templates/default/service/client/resource/_def.text.erb +7 -0
  99. data/templates/default/service/nonstandard_lro.text.erb +6 -0
  100. data/templates/default/service/rest/client/{_client.erb → _client.text.erb} +82 -13
  101. data/templates/default/service/rest/client/_config.text.erb +178 -0
  102. data/templates/default/service/rest/client/_operations.text.erb +124 -0
  103. data/templates/default/service/rest/client/method/{_def.erb → _def.text.erb} +7 -1
  104. data/templates/default/service/rest/client/method/def/{_options_defaults.erb → _options_defaults.text.erb} +8 -3
  105. data/templates/default/service/rest/client/method/def/{_response.erb → _response.text.erb} +4 -0
  106. data/templates/default/service/rest/client/method/def/{_response_nonstandard_lro.erb → _response_nonstandard_lro.text.erb} +5 -4
  107. data/templates/default/service/rest/client/method/def/_response_normal.text.erb +5 -0
  108. data/templates/default/service/rest/client/method/def/_response_normal_lro.text.erb +7 -0
  109. data/templates/default/service/rest/client/method/def/_response_paged.text.erb +7 -0
  110. data/templates/default/service/rest/client/method/def/_response_server_streaming.text.erb +11 -0
  111. data/templates/default/service/rest/client/method/docs/{_request.erb → _request.text.erb} +1 -3
  112. data/templates/default/service/rest/client/method/docs/_result.text.erb +10 -0
  113. data/templates/default/service/rest/client/method/docs/_snippets.text.erb +6 -0
  114. data/templates/default/service/{nonstandard_lro.erb → rest/nonstandard_lro.text.erb} +1 -1
  115. data/templates/default/service/rest/operations.text.erb +6 -0
  116. data/templates/default/service/rest/service_stub/_service_stub.text.erb +63 -0
  117. data/templates/default/service/rest/service_stub/grpc_transcoding_method/_def.text.erb +37 -0
  118. data/templates/default/service/rest/service_stub/method/_def.text.erb +35 -0
  119. data/templates/default/service/rest/service_stub/method/def/_response.text.erb +37 -0
  120. data/templates/default/service/rest/test/{client.erb → client.text.erb} +3 -3
  121. data/templates/default/service/rest/test/method/_assert_response.text.erb +2 -0
  122. data/templates/default/service/rest/test/method/{_configure.erb → _configure.text.erb} +3 -2
  123. data/templates/default/service/rest/test/method/_normal.text.erb +60 -0
  124. data/templates/default/service/rest/test/method/_server.text.erb +60 -0
  125. data/templates/default/service/rest/test/method/{_setup.erb → _setup.text.erb} +26 -10
  126. data/templates/default/service/test/{_resource.erb → _resource.text.erb} +1 -1
  127. data/templates/default/service/test/{client.erb → client.text.erb} +3 -2
  128. data/templates/default/service/test/client_paths.text.erb +33 -0
  129. data/templates/default/service/test/method/{_bidi.erb → _bidi.text.erb} +1 -1
  130. data/templates/default/service/test/method/{_client.erb → _client.text.erb} +1 -1
  131. data/templates/default/service/test/method/{_configure.erb → _configure.text.erb} +2 -1
  132. data/templates/default/service/test/method/{_normal.erb → _normal.text.erb} +1 -1
  133. data/templates/default/service/test/method/{_server.erb → _server.text.erb} +1 -1
  134. data/templates/default/service/test/method/{_setup.erb → _setup.text.erb} +19 -2
  135. data/templates/default/snippets/{gemfile.erb → gemfile.text.erb} +2 -2
  136. data/templates/default/snippets/snippet/_body.text.erb +24 -0
  137. data/templates/default/snippets/snippet/_inline.text.erb +11 -0
  138. data/templates/default/snippets/snippet/_standalone.text.erb +25 -0
  139. data/templates/default/snippets/{standalone.erb → standalone.text.erb} +1 -1
  140. metadata +199 -274
  141. data/lib/google/api/annotations.pb.rb +0 -39
  142. data/lib/google/api/auth.pb.rb +0 -75
  143. data/lib/google/api/backend.pb.rb +0 -59
  144. data/lib/google/api/billing.pb.rb +0 -53
  145. data/lib/google/api/client.pb.rb +0 -43
  146. data/lib/google/api/context.pb.rb +0 -47
  147. data/lib/google/api/control.pb.rb +0 -38
  148. data/lib/google/api/documentation.pb.rb +0 -56
  149. data/lib/google/api/endpoint.pb.rb +0 -42
  150. data/lib/google/api/field_behavior.pb.rb +0 -51
  151. data/lib/google/api/http.pb.rb +0 -60
  152. data/lib/google/api/label.pb.rb +0 -49
  153. data/lib/google/api/launch_stage.pb.rb +0 -37
  154. data/lib/google/api/log.pb.rb +0 -47
  155. data/lib/google/api/logging.pb.rb +0 -48
  156. data/lib/google/api/metric.pb.rb +0 -90
  157. data/lib/google/api/monitored_resource.pb.rb +0 -68
  158. data/lib/google/api/monitoring.pb.rb +0 -48
  159. data/lib/google/api/quota.pb.rb +0 -63
  160. data/lib/google/api/resource.pb.rb +0 -80
  161. data/lib/google/api/routing.pb.rb +0 -58
  162. data/lib/google/api/service.pb.rb +0 -90
  163. data/lib/google/api/source_info.pb.rb +0 -44
  164. data/lib/google/api/system_parameter.pb.rb +0 -51
  165. data/lib/google/api/usage.pb.rb +0 -47
  166. data/lib/google/cloud/extended_operations.pb.rb +0 -57
  167. data/lib/google/longrunning/operations.pb.rb +0 -115
  168. data/lib/google/protobuf/any.pb.rb +0 -40
  169. data/lib/google/protobuf/api.pb.rb +0 -69
  170. data/lib/google/protobuf/compiler/plugin.pb.rb +0 -79
  171. data/lib/google/protobuf/descriptor.pb.rb +0 -360
  172. data/lib/google/protobuf/duration.pb.rb +0 -41
  173. data/lib/google/protobuf/empty.pb.rb +0 -36
  174. data/lib/google/protobuf/source_context.pb.rb +0 -39
  175. data/lib/google/protobuf/struct.pb.rb +0 -65
  176. data/lib/google/protobuf/type.pb.rb +0 -128
  177. data/lib/google/protobuf/wrappers.pb.rb +0 -80
  178. data/lib/google/rpc/status.pb.rb +0 -46
  179. data/templates/default/gem/gemfile.erb +0 -4
  180. data/templates/default/lib/rest/_rest.erb +0 -9
  181. data/templates/default/service/client/method/def/_request_normal.erb +0 -4
  182. data/templates/default/service/client/method/def/_request_streaming.erb +0 -9
  183. data/templates/default/service/client/method/docs/_deprecated.erb +0 -5
  184. data/templates/default/service/client/method/docs/_snippets.erb +0 -6
  185. data/templates/default/service/client/resource/_def.erb +0 -6
  186. data/templates/default/service/rest/client/_config.erb +0 -122
  187. data/templates/default/service/rest/client/method/def/_response_normal.erb +0 -6
  188. data/templates/default/service/rest/client/method/def/_response_paged.erb +0 -7
  189. data/templates/default/service/rest/client/method/docs/_result.erb +0 -6
  190. data/templates/default/service/rest/service_stub/_service_stub.erb +0 -25
  191. data/templates/default/service/rest/service_stub/grpc_transcoding_method/_def.erb +0 -24
  192. data/templates/default/service/rest/service_stub/method/_def.erb +0 -20
  193. data/templates/default/service/rest/service_stub/method/def/_response.erb +0 -17
  194. data/templates/default/service/rest/test/method/_assert_response.erb +0 -2
  195. data/templates/default/service/rest/test/method/_normal.erb +0 -71
  196. data/templates/default/service/test/client_paths.erb +0 -15
  197. data/templates/default/snippets/snippet/_structure.erb +0 -71
  198. /data/gem_templates/{binary.erb → binary.text.erb} +0 -0
  199. /data/gem_templates/{dockerfile.erb → dockerfile.text.erb} +0 -0
  200. /data/gem_templates/{entrypoint.erb → entrypoint.text.erb} +0 -0
  201. /data/gem_templates/{gapic_sh.erb → gapic_sh.text.erb} +0 -0
  202. /data/gem_templates/{gemfile.erb → gemfile.text.erb} +0 -0
  203. /data/gem_templates/{gemspec.erb → gemspec.text.erb} +0 -0
  204. /data/gem_templates/{generator.erb → generator.text.erb} +0 -0
  205. /data/gem_templates/{gitignore.erb → gitignore.text.erb} +0 -0
  206. /data/gem_templates/{rakefile.erb → rakefile.text.erb} +0 -0
  207. /data/gem_templates/{readme.erb → readme.text.erb} +0 -0
  208. /data/gem_templates/{rubocop.erb → rubocop.text.erb} +0 -0
  209. /data/gem_templates/shared/{_header.erb → _header.text.erb} +0 -0
  210. /data/gem_templates/shared/{_license.erb → _license.text.erb} +0 -0
  211. /data/gem_templates/shared/{_warning.erb → _warning.text.erb} +0 -0
  212. /data/gem_templates/{test_generator.erb → test_generator.text.erb} +0 -0
  213. /data/gem_templates/{test_helper.erb → test_helper.text.erb} +0 -0
  214. /data/gem_templates/{version.erb → version.text.erb} +0 -0
  215. /data/templates/default/gem/{_version.erb → _version.text.erb} +0 -0
  216. /data/templates/default/gem/{changelog.erb → changelog.text.erb} +0 -0
  217. /data/templates/default/gem/{entrypoint.erb → entrypoint.text.erb} +0 -0
  218. /data/templates/default/gem/{gapic_metadata_json.erb → gapic_metadata_json.text.erb} +0 -0
  219. /data/templates/default/gem/{gitignore.erb → gitignore.text.erb} +0 -0
  220. /data/templates/default/gem/{license.erb → license.text.erb} +0 -0
  221. /data/templates/default/gem/{rakefile.erb → rakefile.text.erb} +0 -0
  222. /data/templates/default/gem/{version.erb → version.text.erb} +0 -0
  223. /data/templates/default/gem/{yardopts.erb → yardopts.text.erb} +0 -0
  224. /data/templates/default/layouts/{_ruby.erb → _ruby.text.erb} +0 -0
  225. /data/templates/default/{package.erb → package.text.erb} +0 -0
  226. /data/templates/default/proto_docs/{_proto_file.erb → _proto_file.text.erb} +0 -0
  227. /data/templates/default/proto_docs/{proto_file.erb → proto_file.text.erb} +0 -0
  228. /data/templates/default/proto_docs/{readme.erb → readme.text.erb} +0 -0
  229. /data/templates/default/service/{_helpers.erb → _helpers.text.erb} +0 -0
  230. /data/templates/default/service/client/{_credentials.erb → _credentials.text.erb} +0 -0
  231. /data/templates/default/service/client/{_nonstandard_lro.erb → _nonstandard_lro.text.erb} +0 -0
  232. /data/templates/default/service/client/{_paths.erb → _paths.text.erb} +0 -0
  233. /data/templates/default/service/client/{_requires.erb → _requires.text.erb} +0 -0
  234. /data/templates/default/service/client/{_resource.erb → _resource.text.erb} +0 -0
  235. /data/templates/default/service/client/{_self_configure.erb → _self_configure.text.erb} +0 -0
  236. /data/templates/default/service/client/{_self_configure_defaults.erb → _self_configure_defaults.text.erb} +0 -0
  237. /data/templates/default/service/client/method/def/{_request.erb → _request.text.erb} +0 -0
  238. /data/templates/default/service/client/method/def/{_rescue.erb → _rescue.text.erb} +0 -0
  239. /data/templates/default/service/client/method/def/{_routing_params.erb → _routing_params.text.erb} +0 -0
  240. /data/templates/default/service/client/method/docs/{_error.erb → _error.text.erb} +0 -0
  241. /data/templates/default/service/client/method/docs/{_request.erb → _request.text.erb} +0 -0
  242. /data/templates/default/service/client/method/docs/{_request_field.erb → _request_field.text.erb} +0 -0
  243. /data/templates/default/service/client/method/docs/{_request_streaming.erb → _request_streaming.text.erb} +0 -0
  244. /data/templates/default/service/client/method/docs/{_response.erb → _response.text.erb} +0 -0
  245. /data/templates/default/service/client/method/docs/{_sample.erb → _sample.text.erb} +0 -0
  246. /data/templates/default/service/client/method/docs/{_sample_response.erb → _sample_response.text.erb} +0 -0
  247. /data/templates/default/service/client/method/docs/{_samples.erb → _samples.text.erb} +0 -0
  248. /data/templates/default/service/client/method/docs/request_field/{_arg.erb → _arg.text.erb} +0 -0
  249. /data/templates/default/service/client/method/docs/request_field/{_hash.erb → _hash.text.erb} +0 -0
  250. /data/templates/default/service/client/method/docs/sample_response/{_comment.erb → _comment.text.erb} +0 -0
  251. /data/templates/default/service/client/method/docs/sample_response/{_define.erb → _define.text.erb} +0 -0
  252. /data/templates/default/service/client/method/docs/sample_response/{_loop.erb → _loop.text.erb} +0 -0
  253. /data/templates/default/service/client/method/docs/sample_response/{_print.erb → _print.text.erb} +0 -0
  254. /data/templates/default/service/client/method/docs/sample_response/{_write_file.erb → _write_file.text.erb} +0 -0
  255. /data/templates/default/service/client/resource/{_doc.erb → _doc.text.erb} +0 -0
  256. /data/templates/default/service/client/resource/{_multi.erb → _multi.text.erb} +0 -0
  257. /data/templates/default/service/client/resource/{_single.erb → _single.text.erb} +0 -0
  258. /data/templates/default/service/{client.erb → client.text.erb} +0 -0
  259. /data/templates/default/service/{credentials.erb → credentials.text.erb} +0 -0
  260. /data/templates/default/service/{operations.erb → operations.text.erb} +0 -0
  261. /data/templates/default/service/{paths.erb → paths.text.erb} +0 -0
  262. /data/templates/default/service/rest/client/method/def/{_rescue.erb → _rescue.text.erb} +0 -0
  263. /data/templates/default/service/rest/client/method/docs/{_error.erb → _error.text.erb} +0 -0
  264. /data/templates/default/service/rest/{client.erb → client.text.erb} +0 -0
  265. /data/templates/default/service/rest/{grpc_transcoding.erb → grpc_transcoding.text.erb} +0 -0
  266. /data/templates/default/service/rest/service_stub/grpc_transcoding_method/def/{_query_string_param.erb → _query_string_param.text.erb} +0 -0
  267. /data/templates/default/service/rest/service_stub/method/def/{_request.erb → _request.text.erb} +0 -0
  268. /data/templates/default/service/rest/{service_stub.erb → service_stub.text.erb} +0 -0
  269. /data/templates/default/service/{rest.erb → rest.text.erb} +0 -0
  270. /data/templates/default/service/test/{client_operations.erb → client_operations.text.erb} +0 -0
  271. /data/templates/default/service/test/method/{_assert_response.erb → _assert_response.text.erb} +0 -0
  272. /data/templates/default/service/test/{smoke.erb → smoke.text.erb} +0 -0
  273. /data/templates/default/{service.erb → service.text.erb} +0 -0
  274. /data/templates/default/shared/{_header.erb → _header.text.erb} +0 -0
  275. /data/templates/default/shared/{_license.erb → _license.text.erb} +0 -0
  276. /data/templates/default/shared/{_warning.erb → _warning.text.erb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8baa3144f849b60f36cb51b7c7bed258165e9b3a646816aad586912001e4ddc
4
- data.tar.gz: f1dc6fb877e18c0eed6c461bf6937d3756409da0bb259484149c377244953a70
3
+ metadata.gz: 2f2a5263485263873c059ce342f1cd26c800bab3349b7b191132b57f79d986ea
4
+ data.tar.gz: eda4ecd48fe183ffd4f98927f80c6500fc7b1d578fd8a45f4d539c5e0cecc9bd
5
5
  SHA512:
6
- metadata.gz: 90b475c396bcdd3ecdadec8fb27e3e8089e6c8525ad75d2f83142525684b898a38765ebde17d22262e2acaac56b8452e6d77b6a6f2ccc4fab4c21ad3997c9019
7
- data.tar.gz: 84b4aab4d800b042c4be22f3159ca77fa1cc3489a903b79844d239202c56ffb0c02db39957afa7c0bee28b168547ff1e5afda93d373450f5f8a0e14feb969147
6
+ metadata.gz: a49ad3a37ed0d730ef3bed251a2d58f06a4f9686d9fb4d65bcc163e1074ff76d427396798e3e9223a9b2d0d4d82be27c712f9c079f3379f573fe7026bfebbd29
7
+ data.tar.gz: 84dd1fd882a77ff2c659d3d17e56722bb0f80240dc8a644c282290c321a090352ff315c415d4f0e74172830560868f143b9e48fe0b319ae8a56a36680b0f5089
data/CHANGELOG.md CHANGED
@@ -1,5 +1,308 @@
1
1
  # Release History for gapic-generator
2
2
 
3
+ ### 0.45.2 / 2025-06-04
4
+
5
+ * Fix: update Ruby prebuilt binary, version 3.4.3
6
+
7
+ ### 0.45.1 / 2025-05-01
8
+
9
+ No significant changes
10
+
11
+ ### 0.45.0 / 2025-05-01
12
+
13
+ * Feature: Updated rails to 8.0
14
+ * Feature: Update protobuf to 4.30
15
+ * Feature: Update common dependencies for generated clients
16
+ * Fix: update Ruby prebuilt binary, version 3.4.3
17
+
18
+ ### 0.44.0 / 2025-04-30
19
+
20
+ * Feature: Update Ruby for the generator to 3.2.8 including prebuilt binary
21
+ * Feature: Set minumum Ruby version for generated code to 3.1 and use google-style 1.31
22
+
23
+ ### 0.43.0 / 2025-04-24
24
+
25
+ * Fix: Fixed typo in generated wrapper readmes
26
+ * Fix: Provide a better check for grpc when typechecking credentials
27
+ * Feature: bless "::Google::Auth::BaseClient" as an allowed by default credentials type in Config
28
+
29
+ ### 0.42.1 / 2025-02-04
30
+
31
+ * Fix: Wrappers load release dependencies if local dependencies do not match
32
+
33
+ ### 0.42.0 / 2025-01-30
34
+
35
+ * Feature: Change REGAPIC pagination algorithm to the standard algorithm for non-compute clients
36
+
37
+ ### 0.41.0 / 2025-01-24
38
+
39
+ * Feature: Change minimum Ruby version to 3.0
40
+
41
+ ### 0.40.0 / 2025-01-24
42
+
43
+ No significant changes
44
+
45
+ ### 0.39.2 / 2025-01-24
46
+
47
+ * Fix: Add warning regarding external credential sourcing
48
+
49
+ ### 0.39.1 / 2025-01-23
50
+
51
+ * Fix: Updated minimum gapic-common version to 0.25
52
+
53
+ ### 0.39.0 / 2025-01-22
54
+
55
+ * Feature: Add clarifying notes to oneof members in proto_docs
56
+
57
+ ### 0.38.3 / 2024-12-10
58
+
59
+ * Fix: Added logger methods to generated dummy stub classes in generated tests
60
+
61
+ ### 0.38.2 / 2024-12-10
62
+
63
+ * Fix: Throw the correct result object for REST with nonstandard LRO
64
+
65
+ ### 0.38.1 / 2024-12-09
66
+
67
+ * Fix: fix wrapper gem tests by stubbing the stub_logger method
68
+
69
+ ### 0.38.0 / 2024-12-06
70
+
71
+ * Feature: Support request-response debug logging from generated GAPICs
72
+
73
+ ### 0.37.0 / 2024-10-24
74
+
75
+ * Feature: Remove path tests for clients using REST without gRPC
76
+
77
+ ### 0.36.1 / 2024-09-20
78
+
79
+ * Fix: Add missing local binding in resource path methods
80
+
81
+ ### 0.36.0 / 2024-08-22
82
+
83
+ * Feature: Support local binding for variables with keyword collision
84
+
85
+ ### 0.35.0 / 2024-08-15
86
+
87
+ * Feature: Disable xrefs for README files in wrapper gems
88
+
89
+ ### 0.34.1 / 2024-08-08
90
+
91
+ No significant changes
92
+
93
+ ### 0.34.0 / 2024-08-07
94
+
95
+ * Feature: Resolve keyword conflicts with path pattern variable names
96
+ * Feature: Prevent keyword collision with field names as values
97
+ * Feature: Refactor README.md and gemspec files
98
+
99
+ ### 0.33.0 / 2024-07-02
100
+
101
+ * Fix: Resolve BigDecimal warning
102
+ * Feature: Format path pattern variables to snake case
103
+
104
+ ### 0.32.0 / 2024-05-13
105
+
106
+ * Feature: Introduce google.api.api_version option to generated clients
107
+
108
+ ### 0.31.0 / 2024-04-25
109
+
110
+ * Feature: Remove api-common-protos dependency
111
+ * Feature: Use module name to prevent keyword collision with enum values
112
+
113
+ ### 0.30.0 / 2024-04-24
114
+
115
+ * Feature: support auto populating request fields with explicit presence
116
+ * Feature: avoid keyword collision for enum value names
117
+ * Fix: Start requiring ostruct in generated test helper files
118
+
119
+ ### 0.29.0 / 2024-02-22
120
+
121
+ * Feature: Update minimum Ruby version of generated libraries to 2.7
122
+ * Fix: update gemfiles and set bundle platforms to x86_64-linux
123
+
124
+ ### 0.28.0 / 2024-02-14
125
+
126
+ * Feature: introduce auto_populated_fields (uuid4) to generator
127
+
128
+ ### 0.27.4 / 2024-01-12
129
+
130
+ No significant changes
131
+
132
+ ### 0.27.3 / 2024-01-12
133
+
134
+ * Fix: Ensure the correct endpoint gets to mixin clients
135
+
136
+ ### 0.27.2 / 2024-01-11
137
+
138
+ No significant changes
139
+
140
+ ### 0.27.1 / 2024-01-09
141
+
142
+ * Fix: Update mixin dependencies to versions that support universe domain
143
+
144
+ ### 0.27.0 / 2024-01-08
145
+
146
+ * Feature: update generated samples docs
147
+ * Feature: Update rubocop autofix to use Rubocop 1.59
148
+ * Feature: add @deprecated tags to document items
149
+ * Feature: Generate toys files
150
+ * Feature: Support universe domain in GAPIC
151
+
152
+ ### 0.26.0 / 2023-12-04
153
+
154
+ * Feature: Use google-protobuf instead of third-party protobuf library
155
+ * Fix: clean up and update gem dependencies
156
+
157
+ ### 0.25.1 / 2023-09-12
158
+
159
+ * Fix: Workaround for grpc windows issue during tests
160
+
161
+ ### 0.25.0 / 2023-09-07
162
+
163
+ * Feature: Add support for channel pool in gapic generator
164
+ * Fix: Fix snippet generation for REGAPIC clients
165
+
166
+ ### 0.24.0 / 2023-07-05
167
+
168
+ * Feature: Loosen parsing for extra_dependencies
169
+
170
+ ### 0.23.4 / 2023-06-03
171
+
172
+ * Fix: Updates to the bundle locks
173
+ * Fix: Generated clients depend on gapic-common 0.19.1
174
+ * Fix: Fixes the enable_self_signed_jwt determination when the endpoint in the global configuration object (as opposed to the constructor configuration block) is modified
175
+
176
+ ### 0.23.3 / 2023-05-26
177
+
178
+ * Fix: Generated clients depend on gapic-common 0.19
179
+
180
+ ### 0.23.2 / 2023-03-08
181
+
182
+ * Fix: Remove html tags from description text parsed from service yaml
183
+ * Fix: Fail generation if Rubocop autoformatting fails
184
+ * Fix: Replace googleapis.dev links with equivalent cloud.google.com or rubydoc.info links
185
+ * Fix: Fix special case iam API shortname
186
+
187
+ ### 0.23.1 / 2023-02-28
188
+
189
+ * Fix: update gapic-common version
190
+ * Fix: Handle empty fields in service yaml
191
+
192
+ ### 0.23.0 / 2023-02-27
193
+
194
+ * Feature: Honor metadata from the service yaml
195
+
196
+ ### 0.22.0 / 2023-02-14
197
+
198
+ * Feature: Update mixin dependency versions to 0.4
199
+
200
+ ### 0.21.1 / 2023-02-13
201
+
202
+ * Fix: Get rubocop working in bazel
203
+
204
+ ### 0.21.0 / 2023-02-09
205
+
206
+ * Feature: Load and interpret snippetgen phase 2 config data
207
+ * Feature: Added SnippetGen phase2 implementation
208
+ * Feature: Reimplemented snippetgen phase 1 using phase 2
209
+ * Feature: Implemented enough of SnippetGen phase 2 to generate the initial test case
210
+ * Feature: add a transport operation class in Rest
211
+ * Fix: yield TransportOperation class instead of Faraday's
212
+
213
+ ### 0.20.0 / 2023-01-19
214
+
215
+ * Feature: migrate generator bazel (including prebuilts) to 3.1.3
216
+
217
+ ### 0.19.0 / 2023-01-17
218
+
219
+ * Fix: fail on rest transport and no bindings
220
+ * Feature: Bump mixin minimum version to 0.3
221
+
222
+ ### 0.18.1 / 2022-12-15
223
+
224
+ * Fix: Don't generate bindings_override.rb unless REST transport is active
225
+
226
+ ### 0.18.0 / 2022-12-15
227
+
228
+ * Feature: add quota project and misc to REGAPIC templates
229
+ * Feature: use retry policy in regapic templates
230
+ * Fix: avoid creating rest default configuration for non-rest methods
231
+ * Fix: transcoding in regapic tests
232
+ * Fix: Cross-ref links use the REST client class in REST client docs
233
+ * Feature: implements template changes for REST server-streaming.
234
+ * Feature: all fixes for the combined rest+grpc libraries
235
+ * Feature: generate bindings override for REST mixins
236
+ * Fix: handle only regapic errors for REST libraries
237
+ * Feature: Recognize transport argument for bazel jobs
238
+ * Feature: Updated wrapper generator to support multi-transport clients
239
+
240
+ ### 0.17.2 / 2022-10-27
241
+
242
+ * Fix: Update snippetgen phase 1 to conform to standard sample style
243
+
244
+ ### 0.17.1 / 2022-10-26
245
+
246
+ * Fix: Fixed typo in rest_numeric_enums bazel field handling
247
+
248
+ ### 0.17.0 / 2022-10-21
249
+
250
+ * Feature: Recognize rest_numeric_enums argument for bazel jobs
251
+
252
+ ### 0.16.1 / 2022-09-27
253
+
254
+ No significant changes
255
+
256
+ ### 0.16.0 / 2022-09-16
257
+
258
+ * Feature: Support numeric enums
259
+
260
+ ### 0.15.3 / 2022-08-18
261
+
262
+ * Fix: Fix out of date SDK auth documentation
263
+
264
+ ### 0.15.2 / 2022-07-27
265
+
266
+ * Fix: only do service config http binding override on Operations
267
+ * Fix: Apply both namespace and service overrides to service names in yard links
268
+
269
+ ### 0.15.1 / 2022-07-26
270
+
271
+ * Fix: mixin proto_docs removal works for iam
272
+
273
+ ### 0.15.0 / 2022-07-25
274
+
275
+ * Feature: classic (AIP-151) LROs in REST
276
+ * Feature: grpc transcoding with `additional_bindings`
277
+ * Fix: Honor service overrides in yard cross-references
278
+ * Fix: suppress generation of mixin proto_docs and wrapper client factory methods
279
+
280
+ ### 0.14.1 / 2022-06-29
281
+
282
+ * Fix: fix crash when generating generic endpoints
283
+
284
+ ### 0.14.0 / 2022-06-27
285
+
286
+ * Feature: generate code using full GRPC transcoding for rest libraries
287
+ * Feature: generating libraries with rest and grpc transports
288
+ * Fix: LRO-wrapped methods of the internal Operations client not working
289
+ * Feature: Update minimum Ruby version to 2.6
290
+
291
+ ### 0.13.0 / 2022-05-11
292
+
293
+ * Feature: Adjust links and repo metadata based on whether the product is part of gcp/cloud
294
+ * Fix: Loosen mixin dependencies to allow 1.x versions
295
+ * Fix: Disable generation of services that are handled as mixins
296
+ * Fix: Disable mixin generation when common services are configured
297
+
298
+ ### 0.12.0 / 2022-04-29
299
+
300
+ * Feature: Generate snippet metadata files
301
+
302
+ ### 0.11.1 / 2022-04-06
303
+
304
+ * Updated generated grpc-google-iam-v1 dependency to ~> 1.1
305
+
3
306
  ### 0.11.0 / 2022-03-01
4
307
 
5
308
  * New: Added generation of nonstandard LRO wrapper calls (currently used for Compute)
data/CONTRIBUTING.md CHANGED
@@ -11,7 +11,7 @@ this simply gives us permission to use and redistribute your contributions as
11
11
  part of the project. Head over to <https://cla.developers.google.com/> to see
12
12
  your current agreements on file or to sign a new one.
13
13
 
14
- You generally only need to submit a CLA once, so if you've already submitted one
14
+ You generally need to submit a CLA only once, so if you've already submitted one
15
15
  (even if it was for a different project), you probably don't need to do it
16
16
  again.
17
17
 
data/README.md CHANGED
@@ -2,24 +2,59 @@
2
2
 
3
3
  Create Ruby clients from a protocol buffer description of an API.
4
4
 
5
- **Note** This project is a preview. Please try it out and let us know what you think,
6
- but there are currently no guarantees of stability or support.
7
-
8
- ## Usage
5
+ This code is used to generate client libraries for many Google APIs including
6
+ Cloud and Ads services. The `gapic-generator` gem itself includes the main
7
+ generator, whereas the `gapic-generator-cloud` and `gapic-generator-ads` gems
8
+ provide modifications specific to Google Cloud and Google Ads APIs.
9
+
10
+ These gems can also be used to create clients for any other API, for Google or
11
+ non-Google services, that use protocol buffers as the description language. The
12
+ generators will work best for APIs that follow the design guidance documented
13
+ in the [Google AIPs](https://aip.dev/). An API that is not AIP-compliant should
14
+ still yield a usable client library, but it may be missing features such as
15
+ idiomatic naming, pagination, or retry configuration.
16
+
17
+ **Important:** This is not an official Google project. While it is being used
18
+ internally to generate official Google API client libraries, there is no
19
+ guarantee of support or stability for any other use.
20
+
21
+ ## Using the Ruby gem
22
+
23
+ This section provides a brief getting started guide for the Ruby gem. However,
24
+ we do not release the Ruby gems often, and they may be substantially behind the
25
+ current generator code. In most cases, we recommend generating from the
26
+ GitHub repository directly. See the main README for
27
+ https://github.com/googleapis/gapic-generator-ruby for more information.
9
28
 
10
29
  ### Install the Generator
11
30
 
12
- This tool is in pre-alpha so it is not yet released to RubyGems.
31
+ The generator is a plugin for **protoc**, the protocol buffers compiler, so
32
+ you'll need to install it first, along with the standard protobuf and grpc
33
+ plugins for Ruby. The easiest way to do this is to install the `grpc-tools` gem
34
+ which will provide all three. You can also follow the
35
+ [official install instructions](https://github.com/protocolbuffers/protobuf#protobuf-compiler-installation).
36
+ Note that if you installed protoc using `grpc-tools`, the compiler binary name
37
+ will be named `grpc_tools_ruby_protoc`; otherwise it will likely be `protoc`.
38
+
39
+ Install the `gapic-generator` gem to get access to the gapic generator plugin.
40
+
41
+ Optionally install either `gapic-generator-cloud` or `gapic-generator-ads` if
42
+ you want access to cloud-specific or ads-specific output.
43
+
44
+ Alternatively, add all the above to a Gemfile:
45
+
46
+ ```ruby
47
+ # Gemfile
48
+ source "https://rubygems.org/"
49
+
50
+ gem "grpc-tools"
51
+ gem "gapic-generator"
52
+ ```
53
+
54
+ And install using bundler:
13
55
 
14
56
  ```sh
15
- $ git clone https://github.com/googleapis/gapic-generator-ruby.git
16
- $ cd gapic-generator-ruby
17
- $ git submodule update --init
18
- $ cd gapic-generator
19
57
  $ bundle install
20
- $ bundle exec rake install
21
- $ which protoc-gen-ruby_gapic
22
- > {Non-empty path}
23
58
  ```
24
59
 
25
60
  ### Generate an API
@@ -28,45 +63,44 @@ Installing this generator exposes `protoc-gen-ruby_gapic` on the PATH. By doing
28
63
  so, it gives the protobuf compiler the CLI option `--ruby_gapic_out` on which
29
64
  you can specify an output path for this generator.
30
65
 
31
- If you want to experiment with an already-existing API, one example is available.
66
+ In most cases, in order to generate a functional client library, you must also
67
+ include the Ruby proto and grpc plugins, using the CLI options `--ruby_out` and
68
+ `--grpc_out`.
69
+
70
+ If you want to experiment with an already-existing API, you can use one of the
71
+ existing Google APIs from https://github.com/googleapis/googleapis.
32
72
  First you should get the protos and dependencies:
33
73
 
34
74
  ```sh
35
- $ git clone git@github.com:googleapis/api-common-protos.git
36
75
  $ git clone git@github.com:googleapis/googleapis.git
37
76
  ```
38
77
 
39
- Now you're ready to compile the API:
78
+ Now you're ready to compile the API. For example, to compile the Vision V1 API:
40
79
 
41
80
  ```sh
42
- $ protoc google/cloud/vision/v1/*.proto \
43
- --proto_path=api-common-protos/ \
44
- --proto_path=googleapis/ \
45
- --ruby_gapic_out=/dest/
46
- ```
47
-
48
- Or, if you don't have `protoc` installed, you can use `grpc_tools_ruby_protoc`
49
- from the `grpc-tools` gem:
50
-
51
- ```sh
52
- $ gem install grpc-tools
53
81
  $ grpc_tools_ruby_protoc google/cloud/vision/v1/*.proto \
54
- --proto_path=api-common-protos/ \
55
82
  --proto_path=googleapis/ \
56
- --ruby_gapic_out=/dest/
83
+ --ruby_out=/path/to/dest/ \
84
+ --grpc_out=/path/to/dest/ \
85
+ --ruby_gapic_out=/path/to/dest/ \
57
86
  ```
58
87
 
59
- ## Contributing
60
-
61
- Contributions to this library are always welcome and highly encouraged.
88
+ Note: most real-world client libraries require additional options to be passed
89
+ to the generator, via the `--ruby_gapic_opt` flag. Those options are not
90
+ covered in this document.
62
91
 
63
- See the [CONTRIBUTING](CONTRIBUTING.md) documentation for more information on how to get started.
92
+ If you want to use `gapic-generator-cloud` or `gapic-generator-ads`, see the
93
+ README for that gem for specific information.
64
94
 
65
- ## Versioning
95
+ ## Support
66
96
 
67
- This library is currently a **preview** with no guarantees of stability or support. Please get
68
- involved and let us know if you find it useful and we'll work towards a stable version.
97
+ This is not an official Google project. While it is being used internally to
98
+ generate official Google API client libraries, there is no guarantee of support
99
+ or stability for any other use.
69
100
 
70
- ## Disclaimer
101
+ As of January 2024, this generator can be run on Ruby 3.0 or later. In general,
102
+ we will make an effort to ensure it is supported on non-end-of-life versions of
103
+ Ruby.
71
104
 
72
- This is not an official Google product.
105
+ Issues can be filed on GitHub at
106
+ https://github.com/googleapis/gapic-generator-ruby/issues.
@@ -17,7 +17,7 @@
17
17
 
18
18
  $LOAD_PATH.unshift ::File.expand_path("../lib", __dir__)
19
19
  require "gapic/runner"
20
- require "google/protobuf/compiler/plugin.pb"
20
+ require "google/protobuf/compiler/plugin_pb"
21
21
 
22
22
  # Ensure that no encoding conversions are done on STDIN and STDOUT
23
23
  # since we are passing binary data back and forth. Otherwise these
@@ -30,4 +30,4 @@ request = Google::Protobuf::Compiler::CodeGeneratorRequest.decode $stdin.read
30
30
  # Run the request
31
31
  response = Gapic::Runner.run request
32
32
 
33
- $stdout.print response.serialize
33
+ $stdout.print Google::Protobuf::Compiler::CodeGeneratorResponse.encode response
@@ -16,6 +16,7 @@
16
16
 
17
17
  require "tmpdir"
18
18
  require "fileutils"
19
+ require "English"
19
20
 
20
21
  module Gapic
21
22
  ##
@@ -29,34 +30,37 @@ module Gapic
29
30
  #
30
31
  def initialize configuration, files
31
32
  @configuration = configuration
32
- @files = format! configuration, files
33
+ @files = format! files
33
34
  end
34
35
 
35
36
  protected
36
37
 
37
- def format! configuration, files
38
+ def format! files
38
39
  Dir.mktmpdir do |dir|
39
- files.each do |file|
40
- write_file dir, file
41
- end
40
+ Dir.chdir dir do
41
+ files.each do |file|
42
+ FileUtils.mkdir_p File.dirname file.name
43
+ File.write file.name, file.content
44
+ end
42
45
 
43
- system "rubocop --cache false -x #{dir} -o #{dir}/rubocop.out -c #{configuration}"
46
+ # Use the current Ruby binary path and invoke the CLI class directly
47
+ # rather than the normal rubocop executable, since the latter uses
48
+ # "/usr/bin/env ruby" which doesn't seem to work in the current bazel
49
+ # environment.
50
+ script = 'require "rubocop"; begin; RuboCop::CLI.new.run; rescue => e; p e; exit 1; end'
51
+ rubocop_cmd = "#{RbConfig.ruby} -e '#{script}' -- --cache false -a -o rubocop.out -c #{configuration}"
52
+ output = `#{rubocop_cmd}`.strip
53
+ unless output.empty?
54
+ warn "**** Rubocop output:"
55
+ warn output
56
+ end
57
+ raise "Rubocop failed" unless $CHILD_STATUS.success?
44
58
 
45
- files.each do |file|
46
- read_file dir, file
59
+ files.each do |file|
60
+ file.content = File.read file.name
61
+ end
47
62
  end
48
63
  end
49
64
  end
50
-
51
- def write_file dir, file
52
- tmp_file = File.join dir, file.name
53
- FileUtils.mkdir_p File.dirname tmp_file
54
- File.write tmp_file, file.content
55
- end
56
-
57
- def read_file dir, file
58
- tmp_file = File.join dir, file.name
59
- file.content = File.read tmp_file
60
- end
61
65
  end
62
66
  end
@@ -39,9 +39,12 @@ module Gapic
39
39
  # @param disable_xrefs [Boolean] (default is `false`) Disable linking to
40
40
  # cross-references, and render them simply as text. This can be used if
41
41
  # it is known that the targets are not present in the current library.
42
+ # @param transport [:grpc,:rest] Whether xref links should go to REST or
43
+ # gRPC client classes. Uses the default transport if not provided.
42
44
  # @return [Enumerable<String>]
43
45
  #
44
- def format_doc_lines api, lines, disable_xrefs: false
46
+ def format_doc_lines api, lines, disable_xrefs: false, transport: nil
47
+ transport ||= api&.default_transport || :grpc
45
48
  # To detect preformatted blocks, this tracks the "expected" base indent
46
49
  # according to Markdown. Specifically, this is the effective indent of
47
50
  # previous block, which is normally 0 except if we're in a list item.
@@ -58,7 +61,7 @@ module Gapic
58
61
  in_block, base_indent = update_indent_state in_block, base_indent, line, indent
59
62
  if in_block == false
60
63
  line = escape_line_braces line
61
- line = format_line_xrefs api, line, disable_xrefs
64
+ line = format_line_xrefs api, line, disable_xrefs, transport
62
65
  end
63
66
  end
64
67
  line
@@ -99,7 +102,8 @@ module Gapic
99
102
 
100
103
  def line_indent line
101
104
  m = /^( *)\S/.match line
102
- m.nil? ? nil : m[1].length
105
+ return nil unless m
106
+ m[1].length
103
107
  end
104
108
 
105
109
  def escape_line_braces line
@@ -109,12 +113,12 @@ module Gapic
109
113
  line
110
114
  end
111
115
 
112
- def format_line_xrefs api, line, disable_xrefs
116
+ def format_line_xrefs api, line, disable_xrefs, transport
113
117
  while (m = @xref_detector.match line)
114
118
  entity = api.lookup m[:addr]
115
119
  return line if entity.nil?
116
120
  text = m[:text]
117
- yard_link = disable_xrefs ? text : yard_link_for_entity(entity, text)
121
+ yard_link = disable_xrefs ? text : yard_link_for_entity(entity, text, transport)
118
122
  return line if yard_link.nil?
119
123
  line = "#{m[:pre]}#{yard_link}#{m[:post]}"
120
124
  end
@@ -126,9 +130,10 @@ module Gapic
126
130
  #
127
131
  # @param entity [Gapic::Schema::Proto] the entity to link to
128
132
  # @param text [String] the text for the link
133
+ # @param transport [:rest,:grpc] The transport for client classes
129
134
  # @return [String] YARD cross-reference syntax
130
135
  #
131
- def yard_link_for_entity entity, text
136
+ def yard_link_for_entity entity, text, transport
132
137
  # As a special case, omit the service "google.longrunning.Operations"
133
138
  # and its methods. This is because the generator creates
134
139
  # service-specific copies of the operations client, rather than a
@@ -136,11 +141,14 @@ module Gapic
136
141
  # general no way to tell what the actual service-specific namespace is.
137
142
  return text if entity.address[0, 3] == ["google", "longrunning", "Operations"]
138
143
 
144
+ client_class = transport == :grpc ? "Client" : "Rest::Client"
139
145
  case entity
140
146
  when Gapic::Schema::Service
141
- "{::#{convert_address_to_ruby entity}::Client #{text}}"
147
+ "{::#{convert_address_to_ruby entity, service: true}::#{client_class} #{text}}"
142
148
  when Gapic::Schema::Method
143
- "{::#{convert_address_to_ruby entity.parent}::Client##{entity.name.underscore} #{text}}"
149
+ namespace = convert_address_to_ruby entity.parent, service: true
150
+ method_name = entity.name.underscore
151
+ "{::#{namespace}::#{client_class}##{method_name} #{text}}"
144
152
  when Gapic::Schema::Message, Gapic::Schema::Enum
145
153
  "{::#{convert_address_to_ruby entity} #{text}}"
146
154
  when Gapic::Schema::EnumValue
@@ -150,13 +158,19 @@ module Gapic
150
158
  end
151
159
  end
152
160
 
153
- def convert_address_to_ruby entity
161
+ def convert_address_to_ruby entity, service: false
154
162
  file = entity.containing_file
155
163
  api = file.containing_api
156
164
  address = entity.address
157
165
  address = address.join "." if address.is_a? Array
158
166
  address = address.sub file.package, file.ruby_package if file.ruby_package&.present?
159
- address.split(/\.|::/).reject(&:empty?).map(&:camelize).map { |node| api.fix_namespace node }.join("::")
167
+ address = address.split(/\.|::/).reject(&:empty?)
168
+ last_index = address.size - 1 if service
169
+ address.each_with_index.map do |node, index|
170
+ node = node.camelize
171
+ node = api.fix_service_name node if index == last_index
172
+ api.fix_namespace node
173
+ end.join "::"
160
174
  end
161
175
  end
162
176
  end