gapic-generator 0.45.4 → 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: e3f7283592167653163c4acebf0950f43eae341db2d41e0a8ff65f5cbad56194
4
- data.tar.gz: d9680dfecc27af932856241ab1e269044df8d27e33fb662b55649866dbd83554
3
+ metadata.gz: a1581701f0920357a40caf74e135e5893b7caef2bcbf5e675e78acc072177ed0
4
+ data.tar.gz: fdb1ecf452f4ae7e99ec59fba3d883aa02be16b7fe1f53e6e55f4756d7776b9f
5
5
  SHA512:
6
- metadata.gz: 6cd6639f82511f747baebc0aeb4117f42561bd9987a248bfc23bdf4d9cea7f2cf04c60a00de6aefbc7e40cf3cf7861515f17b7e970ef1c7c88d793b6f52b19dd
7
- data.tar.gz: 5479a3b76164c023acbe2415805809be3a33850f6fa71930882c507dce92d06ba289d41a2f5d94fca464a084dd7f440717c6fd902666415f2bb57a5c8235f7e1
6
+ metadata.gz: 8fc649d55af2f891a22cdef09c9d8aaa690dae27b63e5c5c0d7e13fa3a2720729d5b88c7307efa47678ea1be3c56143569fee7212d126ae8b2066419bdf361d3
7
+ data.tar.gz: bd3343fa686b52dea9d673de62a8dc42de92ad15bcb78c31eb42e0fee90a521ed1d85da72515610ccccd45b36ee70735a9f2ea380083b67a56a99dd00de71e17
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
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
+
3
10
  ### 0.45.4 / 2025-06-26
4
11
 
5
12
  * Fix: docs for oneof parameters
@@ -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.4"
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
 
@@ -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
  #
@@ -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
@@ -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.4
4
+ version: 0.46.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernest Landrito