gapic-generator 0.45.3 → 0.46.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 271aec2d05b52adb5498c05c65461142789397a22d3b9a99d1d09f1559e8cf4f
4
- data.tar.gz: 16e8bbbf90f2c0eb2174939cc7972fa37552cb807cfd24ecc0d74c9ed252a642
3
+ metadata.gz: a1581701f0920357a40caf74e135e5893b7caef2bcbf5e675e78acc072177ed0
4
+ data.tar.gz: fdb1ecf452f4ae7e99ec59fba3d883aa02be16b7fe1f53e6e55f4756d7776b9f
5
5
  SHA512:
6
- metadata.gz: e46aeb79a605c9395704b0cc14d4b8b540c34c119c9ee7d33178fc8d1a384d91fecfc42e92311e7197e36f9cec7cf21cb85e3a29850256643d348eae6571e8d2
7
- data.tar.gz: 9f953a7d82a33f19a6309b6ca6abdf5da4b0f5bec294f6f1da8b0aadec47466f335a4df091c8021dd87a9596b0a310bdfa006fd617f03af8e167067a76712d47
6
+ metadata.gz: 8fc649d55af2f891a22cdef09c9d8aaa690dae27b63e5c5c0d7e13fa3a2720729d5b88c7307efa47678ea1be3c56143569fee7212d126ae8b2066419bdf361d3
7
+ data.tar.gz: bd3343fa686b52dea9d673de62a8dc42de92ad15bcb78c31eb42e0fee90a521ed1d85da72515610ccccd45b36ee70735a9f2ea380083b67a56a99dd00de71e17
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Release History for gapic-generator
2
2
 
3
+ ### 0.46.0 / 2025-08-13
4
+
5
+ * Feature: use HTTP binding configuration class from new gapic-common
6
+ * Fix: Remove unnecessary services_pb import from tests
7
+ * Fix: no longer generate cross-package references for mixin objects
8
+ * Feature: add support for multiple patterns with same arguments
9
+
10
+ ### 0.45.4 / 2025-06-26
11
+
12
+ * Fix: docs for oneof parameters
13
+ * Fix: remove require when rest operations are not generated
14
+
3
15
  ### 0.45.3 / 2025-06-21
4
16
 
5
17
  * Fix: correct pagination heuristic for Compute
@@ -116,7 +116,12 @@ module Gapic
116
116
  def format_line_xrefs api, line, disable_xrefs, transport
117
117
  while (m = @xref_detector.match line)
118
118
  entity = api.lookup m[:addr]
119
- return line if entity.nil?
119
+ is_mixin_field_addr = Gapic::Model::Mixins.mixin_message_field_address?(
120
+ m[:addr],
121
+ gem_name: api.configuration.fetch(:gem, nil)&.fetch(:name, "")
122
+ )
123
+ return line if entity.nil? || is_mixin_field_addr
124
+
120
125
  text = m[:text]
121
126
  yard_link = disable_xrefs ? text : yard_link_for_entity(entity, text, transport)
122
127
  return line if yard_link.nil?
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Gapic
18
18
  module Generator
19
- VERSION = "0.45.3"
19
+ VERSION = "0.46.0"
20
20
  end
21
21
  end
@@ -162,6 +162,25 @@ module Gapic
162
162
  MIXIN_GEM_NAMES.include?(service_address) && gem_name != MIXIN_GEM_NAMES[service_address]
163
163
  end
164
164
 
165
+ ##
166
+ # Returns true if the given service address is a mixin.
167
+ # This just checks the service against a (hard-coded) set of known mixins.
168
+ # If `gem_name` is provided, objects from the package of the service
169
+ # that corresponds to that gem_name are not considered mixins.
170
+ #
171
+ # @param message_field_address [String,Array<String>] The address (either array
172
+ # or dot-delimited) of the message or field to check.
173
+ # @param gem_name [String] The name of the gem.
174
+ # @return [boolean]
175
+ #
176
+ def self.mixin_message_field_address? message_field_address, gem_name: nil
177
+ message_field_address = message_field_address.join "." unless message_field_address.is_a? String
178
+ # NB: messages are checked against package, not service
179
+ service_address = MIXIN_GEM_NAMES.keys.find { |sn| message_field_address.start_with? MIXIN_PACKAGE_NAMES[sn] }
180
+
181
+ !service_address.nil? && gem_name != MIXIN_GEM_NAMES[service_address]
182
+ end
183
+
165
184
  private
166
185
 
167
186
  # @return [Enumerable<String>] Names of all services that are specified
@@ -179,6 +198,13 @@ module Gapic
179
198
  }.freeze
180
199
  private_constant :MIXIN_GEM_NAMES
181
200
 
201
+ MIXIN_PACKAGE_NAMES = {
202
+ LOCATIONS_SERVICE => "google.cloud.location",
203
+ IAM_SERVICE => "google.iam.v1",
204
+ LRO_SERVICE => "google.longrunning.operations"
205
+ }.freeze
206
+ private_constant :MIXIN_PACKAGE_NAMES
207
+
182
208
  # Since mixins are scope-limited to a couple of services, it is easier to
183
209
  # have these in lookup tables than to construct a ServicePresenter
184
210
 
@@ -72,8 +72,8 @@ module Gapic
72
72
  # gRPC client classes. Uses the default transport if not provided.
73
73
  # @return [String]
74
74
  #
75
- def doc_description transport: nil
76
- @field.docs_leading_comments transport: transport
75
+ def doc_description transport: nil, is_rpc_param: false
76
+ @field.docs_leading_comments transport: transport, is_rpc_param: is_rpc_param
77
77
  end
78
78
 
79
79
  def default_value
@@ -256,7 +256,7 @@ module Gapic
256
256
 
257
257
  def dependencies
258
258
  @dependencies ||= begin
259
- deps = { "gapic-common" => "~> 1.0" }
259
+ deps = { "gapic-common" => "~> 1.1" }
260
260
  deps["grpc-google-iam-v1"] = "~> 1.11" if iam_dependency?
261
261
  extra_deps = gem_config_dependencies
262
262
  deps.merge! mixins_model.dependencies if mixins_model.mixins?
@@ -26,10 +26,13 @@ module Gapic
26
26
  def initialize resource
27
27
  @resource = resource
28
28
 
29
- @patterns = resource.pattern.map { |pattern| PatternPresenter.new pattern }
29
+ all_patterns = resource.pattern.map { |pattern| PatternPresenter.new pattern }
30
30
 
31
31
  # Keep only patterns that can be used to create path helpers
32
- @patterns.filter!(&:useful_for_helpers?)
32
+ all_useful_patterns = all_patterns.filter(&:useful_for_helpers?)
33
+
34
+ # Remove patterns where key is duplicated
35
+ @patterns = ResourcePresenter.dedup_patterns all_useful_patterns
33
36
  end
34
37
 
35
38
  def dup
@@ -52,6 +55,25 @@ module Gapic
52
55
  "#{ActiveSupport::Inflector.underscore name}_path"
53
56
  end
54
57
 
58
+ ##
59
+ # Deduplicates pattern that have the same `arguments_key`. Our design for the "paths" helper
60
+ # only allows for one pattern per `arguments_key`.
61
+ #
62
+ # If patterns with the same `arguments_key` are detected, the shortest is taken. If there is
63
+ # a tie, the lexicographically first is taken.
64
+ #
65
+ # @param patterns [Array<PatternPresenter>]
66
+ #
67
+ # @return [Array<PatternPresenter>]
68
+ #
69
+ def self.dedup_patterns patterns
70
+ patterns.group_by(&:arguments_key).map do |_arguments_key, group|
71
+ group.min_by do |pattern|
72
+ [pattern.pattern.length, pattern.pattern]
73
+ end
74
+ end
75
+ end
76
+
55
77
  ##
56
78
  # A presenter for a particular pattern
57
79
  #
@@ -983,16 +983,22 @@ module Gapic
983
983
 
984
984
  # @private
985
985
  # Override this to add a note related to oneofs being mutually exclusive.
986
- def docs_leading_comments disable_xrefs: false, transport: nil
987
- str = super
986
+ def docs_leading_comments disable_xrefs: false, transport: nil, is_rpc_param: false
987
+ str = super(disable_xrefs: disable_xrefs, transport: transport)
988
988
  return str unless @oneof_siblings && @oneof_siblings.size > 1
989
989
  siblings = @oneof_siblings.map { |field| "`#{field.name}`" }.join ", "
990
- note = "Note: The following fields are mutually exclusive: " \
991
- "#{siblings}. If a field in that set is populated, all other " \
992
- "fields in the set will automatically be cleared."
990
+ note =
991
+ if is_rpc_param
992
+ "Note: The following parameters are mutually exclusive: #{siblings}. " \
993
+ "At most one of these parameters can be set. If more than one is set, " \
994
+ "only one will be used, and it is not defined which one."
995
+ else
996
+ "Note: The following fields are mutually exclusive: #{siblings}. " \
997
+ "If a field in that set is populated, all other fields in the set " \
998
+ "will automatically be cleared."
999
+ end
993
1000
  str ? "#{str.strip}\n\n#{note}" : note
994
1001
  end
995
-
996
1002
  # @!method name
997
1003
  # @return [String] the unqualified name of the field.
998
1004
  # @!method number
@@ -1,6 +1,6 @@
1
1
  <%- assert_locals package -%>
2
2
  <% @requires = capture do %>
3
- require "gapic/config"
3
+ require "gapic/rest"
4
4
  <%- end -%>
5
5
 
6
6
  <%- if package.first_service_with_rest&.generate_rest_clients? -%>
@@ -19,31 +19,4 @@ module <%= package.module_name %>
19
19
  def self.configure
20
20
  <%= indent render(partial: "lib/package/self_configure", locals: { package: package }), 4 %>
21
21
  end
22
-
23
- ##
24
- # @private
25
- # Configuration class for the <%= package.name %> package.
26
- #
27
- # This class contains common configuration for all services
28
- # of the <%= package.name %> package.
29
- #
30
- # This configuration is for internal use of the client library classes,
31
- # and it is not intended that the end-users will read or change it.
32
- #
33
- class Configuration
34
- extend ::Gapic::Config
35
-
36
- # @private
37
- # Overrides for http bindings for the RPC of the mixins for this package.
38
- # Services in this package should use these when creating clients for the mixin services.
39
- # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
40
- config_attr :bindings_override, {}, ::Hash, nil
41
-
42
- # @private
43
- def initialize parent_config = nil
44
- @parent_config = parent_config unless parent_config.nil?
45
-
46
- yield self if block_given?
47
- end
48
- end
49
22
  end
@@ -8,7 +8,7 @@
8
8
  namespace.pop
9
9
  end
10
10
 
11
- default_config = Configuration.new parent_config
11
+ default_config = ::Gapic::Rest::HttpBindingOverrideConfiguration.new parent_config
12
12
  <%= indent_tail render(partial: "lib/package/self_configure_defaults", locals: {package: package}), 2 %>
13
13
  default_config
14
14
  end
@@ -15,7 +15,7 @@ require "<%= service.credentials_require %>"
15
15
  <%- if service.paths? -%>
16
16
  require "<%= service.paths_require %>"
17
17
  <%- end -%>
18
- <%- if service.lro? -%>
18
+ <%- if service.rest.lro? -%>
19
19
  require "<%= service.rest.operations_require %>"
20
20
  <%- end -%>
21
21
  <%- if service.nonstandard_lro_provider? -%>
@@ -19,7 +19,7 @@
19
19
  <%- method.arguments.each do |arg| -%>
20
20
  # @param <%= arg.name %> [<%= arg.doc_types %>]
21
21
  <%- if arg.doc_description -%>
22
- <%= indent arg.doc_description(transport: :grpc), "# " %>
22
+ <%= indent arg.doc_description(transport: :grpc, is_rpc_param: true), "# " %>
23
23
  <%- end -%>
24
24
  <%- end -%>
25
25
  <%- end -%>
@@ -19,7 +19,7 @@
19
19
  <%- method.arguments.each do |arg| -%>
20
20
  # @param <%= arg.name %> [<%= arg.doc_types %>]
21
21
  <%- if arg.doc_description -%>
22
- <%= indent arg.doc_description(transport: :rest), "# " %>
22
+ <%= indent arg.doc_description(transport: :rest, is_rpc_param: true), "# " %>
23
23
  <%- end -%>
24
24
  <%- end -%>
25
25
  <%- end -%>
@@ -5,7 +5,6 @@ require "helper"
5
5
  require "gapic/grpc/service_stub"
6
6
 
7
7
  require "<%= service.proto_service_require %>"
8
- require "<%= service.proto_services_require %>"
9
8
  require "<%= service.service_require %>"
10
9
 
11
10
  class <%= service.client_name_full %>Test < Minitest::Test
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gapic-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.45.3
4
+ version: 0.46.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernest Landrito