gapic-generator 0.2.3 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/lib/gapic/formatting_utils.rb +9 -7
  4. data/lib/gapic/generator/version.rb +1 -1
  5. data/lib/gapic/generators/default_generator.rb +11 -10
  6. data/lib/gapic/helpers/filepath_helper.rb +1 -0
  7. data/lib/gapic/helpers/namespace_helper.rb +8 -1
  8. data/lib/gapic/presenters/field_presenter.rb +9 -9
  9. data/lib/gapic/presenters/file_presenter.rb +1 -1
  10. data/lib/gapic/presenters/gem_presenter.rb +4 -0
  11. data/lib/gapic/presenters/method_presenter.rb +24 -18
  12. data/lib/gapic/presenters/package_presenter.rb +16 -1
  13. data/lib/gapic/presenters/resource_presenter.rb +3 -9
  14. data/lib/gapic/presenters/service_presenter.rb +58 -13
  15. data/lib/gapic/resource_lookup.rb +23 -45
  16. data/lib/gapic/ruby_info.rb +93 -0
  17. data/lib/gapic/schema/api.rb +102 -1
  18. data/lib/gapic/schema/loader.rb +9 -2
  19. data/lib/gapic/schema/wrappers.rb +109 -22
  20. data/templates/default/gem/entrypoint.erb +8 -0
  21. data/templates/default/gem/gemspec.erb +1 -1
  22. data/templates/default/gem/readme.erb +15 -1
  23. data/templates/default/gem/rubocop.erb +13 -41
  24. data/templates/default/layouts/_ruby.erb +5 -4
  25. data/templates/default/lib/_package.erb +17 -0
  26. data/templates/default/lib/_service.erb +32 -0
  27. data/templates/default/package.erb +5 -5
  28. data/templates/default/proto_docs/_message.erb +2 -2
  29. data/templates/default/service.erb +5 -7
  30. data/templates/default/service/_helpers.erb +3 -0
  31. data/templates/default/service/client.erb +1 -1
  32. data/templates/default/service/client/_client.erb +13 -19
  33. data/templates/default/service/client/_config.erb +26 -26
  34. data/templates/default/service/client/_credentials.erb +1 -1
  35. data/templates/default/service/client/_operations.erb +1 -5
  36. data/templates/default/service/client/_resource.erb +1 -1
  37. data/templates/default/service/client/method/def/_options_defaults.erb +2 -2
  38. data/templates/default/service/client/method/def/_request_normal.erb +2 -2
  39. data/templates/default/service/client/method/def/_request_streaming.erb +3 -3
  40. data/templates/default/service/client/method/def/_response_normal.erb +1 -1
  41. data/templates/default/service/client/method/def/_response_paged.erb +2 -2
  42. data/templates/default/service/client/method/docs/_error.erb +1 -1
  43. data/templates/default/service/client/method/docs/_request_normal.erb +11 -6
  44. data/templates/default/service/client/method/docs/_request_streaming.erb +2 -2
  45. data/templates/default/service/client/method/docs/_response.erb +1 -1
  46. data/templates/default/service/client/resource/_def.erb +1 -1
  47. data/templates/default/service/client/resource/_multi.erb +2 -2
  48. data/templates/default/service/client/resource/_single.erb +1 -1
  49. data/templates/default/service/credentials.erb +1 -1
  50. data/templates/default/service/operations.erb +1 -1
  51. data/templates/default/service/paths.erb +1 -1
  52. data/templates/default/service/test/client.erb +16 -2
  53. data/templates/default/service/test/client_operations.erb +2 -2
  54. data/templates/default/service/test/method/_configure.erb +19 -0
  55. metadata +9 -4
  56. data/templates/default/service/client/_helpers.erb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a5c16d4ae2bf94ccb62b00d0a7cd0d35fbebc348072649684f7550950ef370d
4
- data.tar.gz: 162528840170a3992fa85e76d17e6110779cad71d22e5c670cc07647e6c931e6
3
+ metadata.gz: bd638c7b5855aa89dfd03c87f3f5d8d936d78005b51dd04a409ac7552e3eea05
4
+ data.tar.gz: 6372183134b8556a0a5ac7a4a6bf1250820c5b167b576454fae5f0228194078c
5
5
  SHA512:
6
- metadata.gz: 9b0f283cae815e46051faed3bb47ce892772f3f8635b9ce85d6c1d1af7e7d66f87e5900079011abe356ff5f34e1a5e3b0a2bb5eb49d85237f47a695724b7acb1
7
- data.tar.gz: d81fb0ca1e7787beb0dd886a2cf8e58ad53b05de862b73334e1f8eafb395de6d4f30538bd53b0ff27876c6e9d14d3dc4641297b6b669d6f99c193f80a925c71d
6
+ metadata.gz: 67b82518fe047ac185a3b596af6b3da223c774c96dbc6cb01761998920ca164e546bd72fc2222c6a945636c49e39a5b80ded892b821d493d79f40133fa973fa3
7
+ data.tar.gz: c316dd8c291a1204e73f18d7df06800734bf7e3690db5d5967e586cbaf0c215b02496a090a44eb5baee9b501fd418717312b8bb33d096fda5f5c6ef84e11d1fa
@@ -1,5 +1,43 @@
1
1
  # Release History for gapic-generator
2
2
 
3
+ ### 0.4.2 / 2020-04-28
4
+
5
+ * Prepend double-colon to absolute/global namespaces to prevent conflicts.
6
+ * Fix documentation/examples of timeouts to clarify they are in seconds.
7
+
8
+ ### 0.4.0 / 2020-04-20
9
+
10
+ * Support generating clients of "common" interfaces by delegating to another service config.
11
+ * Added an accessor for the long-running-operation client from the main client.
12
+ * Generate tests for the configure method and operations client accessor.
13
+ * Prevent generation of RPC or factory methods with reserved names.
14
+ * Fixed: LRO clients weren't inheriting custom endpoints from the main client.
15
+ * Fixed: Cross-references weren't interpreted if the text included backticks, spaces, or hyphens.
16
+
17
+ ### 0.3.3 / 2020-04-13
18
+
19
+ * Fix cross-reference links to multi-word enum values.
20
+
21
+ ### 0.3.2 / 2020-04-12
22
+
23
+ * Fix the talent.v4beta1 hack.
24
+
25
+ ### 0.3.1 / 2020-04-11
26
+
27
+ * Disable ModuleLength metric for generated code.
28
+ * Omit nonconforming resource patterns instead of crashing.
29
+
30
+ ### 0.3.0 / 2020-04-10
31
+
32
+ * Detect when a resource is referenced implicitly via child_type, and generate path helpers.
33
+ * Update grpc-google-iam-v1 dependency to require the latest version.
34
+ * Generated require graph is more sane and does not include cycles.
35
+ * The bundler entrypoint now loads the entire gem for wrapper gems.
36
+ * Generated readmes are more useful and include a quickstart.
37
+ * Package and service modules now have basic documentation.
38
+ * Overloads for methods now have basic explanatory documentation, including how to pass an empty request.
39
+ * Request object documentation no longer duplicates the method documentation.
40
+
3
41
  ### 0.2.3 / 2020-04-06
4
42
 
5
43
  * No changes
@@ -22,7 +22,7 @@ module Gapic
22
22
  #
23
23
  module FormattingUtils
24
24
  @brace_detector = /\A(?<pre>[^`]*(`[^`]*`[^`]*)*[^`\\])?\{(?<inside>[^\s][^}]*)\}(?<post>.*)\z/m
25
- @xref_detector = /\A(?<pre>[^`]*(`[^`]*`[^`]*)*)?\[(?<text>[\w\.]+)\]\[(?<addr>[\w\.]+)\](?<post>.*)\z/m
25
+ @xref_detector = /\A(?<pre>[^`]*(`[^`]*`[^`]*)*)?\[(?<text>[\w\. `-]+)\]\[(?<addr>[\w\.]+)\](?<post>.*)\z/m
26
26
  @list_element_detector = /\A\s*(\*|\+|-|[0-9a-zA-Z]+\.)\s/
27
27
 
28
28
  class << self
@@ -137,13 +137,15 @@ module Gapic
137
137
 
138
138
  case entity
139
139
  when Gapic::Schema::Service
140
- "{#{convert_address_to_ruby entity}::Client #{text}}"
140
+ "{::#{convert_address_to_ruby entity}::Client #{text}}"
141
141
  when Gapic::Schema::Method
142
- "{#{convert_address_to_ruby entity.parent}::Client##{entity.name.underscore} #{text}}"
143
- when Gapic::Schema::Message, Gapic::Schema::Enum, Gapic::Schema::EnumValue
144
- "{#{convert_address_to_ruby entity} #{text}}"
142
+ "{::#{convert_address_to_ruby entity.parent}::Client##{entity.name.underscore} #{text}}"
143
+ when Gapic::Schema::Message, Gapic::Schema::Enum
144
+ "{::#{convert_address_to_ruby entity} #{text}}"
145
+ when Gapic::Schema::EnumValue
146
+ "{::#{convert_address_to_ruby entity.parent}::#{entity.name} #{text}}"
145
147
  when Gapic::Schema::Field
146
- "{#{convert_address_to_ruby entity.parent}##{entity.name} #{text}}"
148
+ "{::#{convert_address_to_ruby entity.parent}##{entity.name} #{text}}"
147
149
  end
148
150
  end
149
151
 
@@ -153,7 +155,7 @@ module Gapic
153
155
  address = entity.address
154
156
  address = address.join "." if address.is_a? Array
155
157
  address = address.sub file.package, file.ruby_package if file.ruby_package&.present?
156
- address.split(".").reject(&:empty?).map(&:camelize).map { |node| api.fix_namespace node }.join("::")
158
+ address.split(/\.|::/).reject(&:empty?).map(&:camelize).map { |node| api.fix_namespace node }.join("::")
157
159
  end
158
160
  end
159
161
  end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Gapic
18
18
  module Generator
19
- VERSION = "0.2.3"
19
+ VERSION = "0.4.2"
20
20
  end
21
21
  end
@@ -63,16 +63,17 @@ module Gapic
63
63
  end
64
64
 
65
65
  # Gem level files
66
- files << g("gem/gitignore.erb", ".gitignore", gem: gem)
67
- files << g("gem/version.erb", "lib/#{gem.version_file_path}", gem: gem)
68
- files << g("gem/gemspec.erb", "#{gem.name}.gemspec", gem: gem)
69
- files << g("gem/gemfile.erb", "Gemfile", gem: gem)
70
- files << g("gem/rakefile.erb", "Rakefile", gem: gem)
71
- files << g("gem/readme.erb", "README.md", gem: gem)
72
- files << g("gem/changelog.erb", "CHANGELOG.md", gem: gem)
73
- files << g("gem/rubocop.erb", ".rubocop.yml", gem: gem)
74
- files << g("gem/yardopts.erb", ".yardopts", gem: gem)
75
- files << g("gem/license.erb", "LICENSE.md", gem: gem)
66
+ files << g("gem/gitignore.erb", ".gitignore", gem: gem)
67
+ files << g("gem/version.erb", "lib/#{gem.version_file_path}", gem: gem)
68
+ files << g("gem/gemspec.erb", "#{gem.name}.gemspec", gem: gem)
69
+ files << g("gem/gemfile.erb", "Gemfile", gem: gem)
70
+ files << g("gem/rakefile.erb", "Rakefile", gem: gem)
71
+ files << g("gem/readme.erb", "README.md", gem: gem)
72
+ files << g("gem/changelog.erb", "CHANGELOG.md", gem: gem)
73
+ files << g("gem/rubocop.erb", ".rubocop.yml", gem: gem)
74
+ files << g("gem/yardopts.erb", ".yardopts", gem: gem)
75
+ files << g("gem/license.erb", "LICENSE.md", gem: gem)
76
+ files << g("gem/entrypoint.erb", "lib/#{gem.name}.rb", gem: gem)
76
77
 
77
78
  gem.proto_files.each do |proto_file|
78
79
  files << g("proto_docs/proto_file.erb", "proto_docs/#{proto_file.docs_file_path}", file: proto_file)
@@ -25,6 +25,7 @@ module Gapic
25
25
  ##
26
26
  # Converts a ruby namespace string to a file path string.
27
27
  def ruby_file_path api, namespace
28
+ namespace = namespace.sub(/^::/, "")
28
29
  file_path = ruby_file_path_for_namespace namespace
29
30
  fix_file_path api, file_path
30
31
  end
@@ -38,7 +38,14 @@ module Gapic
38
38
  # Ruby double-semicolon separators.
39
39
  def ruby_namespace_for_address address
40
40
  address = address.split "." if address.is_a? String
41
- address.reject(&:empty?).map(&:camelize).join "::"
41
+ ensure_absolute_namespace address.reject(&:empty?).map(&:camelize).join("::")
42
+ end
43
+
44
+ ##
45
+ # Returns the given namespace, ensuring double colons are prepended
46
+ #
47
+ def ensure_absolute_namespace namespace
48
+ namespace.start_with?("::") ? namespace : "::#{namespace}"
42
49
  end
43
50
 
44
51
  ##
@@ -95,21 +95,21 @@ module Gapic
95
95
  base_type =
96
96
  if field.message?
97
97
  type = message_ruby_type field.message
98
- output ? type : "#{type} | Hash"
98
+ output ? type : "#{type}, ::Hash"
99
99
  elsif field.enum?
100
100
  # TODO: handle when arg message is nil and enum is the type
101
101
  message_ruby_type field.enum
102
102
  else
103
103
  case field.type
104
- when 1, 2 then "Float"
105
- when 3, 4, 5, 6, 7, 13, 15, 16, 17, 18 then "Integer"
106
- when 9, 12 then "String"
107
- when 8 then "Boolean"
104
+ when 1, 2 then "::Float"
105
+ when 3, 4, 5, 6, 7, 13, 15, 16, 17, 18 then "::Integer"
106
+ when 9, 12 then "::String"
107
+ when 8 then "::Boolean"
108
108
  else
109
- "Object"
109
+ "::Object"
110
110
  end
111
111
  end
112
- field.repeated? ? "Array<#{base_type}>" : base_type
112
+ field.repeated? ? "::Array<#{base_type}>" : base_type
113
113
  end
114
114
 
115
115
  def field_map_type entry_message, output
@@ -118,7 +118,7 @@ module Gapic
118
118
  key_field = field if field.name == "key"
119
119
  value_field = field if field.name == "value"
120
120
  end
121
- class_name = output ? "Google::Protobuf::Map" : "Hash"
121
+ class_name = output ? "::Google::Protobuf::Map" : "::Hash"
122
122
  if key_field && value_field
123
123
  key_type = field_doc_types key_field, output
124
124
  value_type = field_doc_types value_field, output
@@ -141,7 +141,7 @@ module Gapic
141
141
  when 9, 12 then "\"hello world\""
142
142
  when 8 then "true"
143
143
  else
144
- "Object"
144
+ "::Object"
145
145
  end
146
146
  end
147
147
  end
@@ -39,7 +39,7 @@ module Gapic
39
39
  end
40
40
 
41
41
  def namespace
42
- return @file.ruby_package if @file.ruby_package.present?
42
+ return ensure_absolute_namespace @file.ruby_package if @file.ruby_package.present?
43
43
  ruby_namespace_for_address address
44
44
  end
45
45
 
@@ -37,6 +37,10 @@ module Gapic
37
37
  end
38
38
  end
39
39
 
40
+ def packages?
41
+ !packages.empty?
42
+ end
43
+
40
44
  def services
41
45
  @services ||= begin
42
46
  files = @api.generate_files
@@ -16,6 +16,7 @@
16
16
 
17
17
  require "active_support/inflector"
18
18
  require "gapic/path_template"
19
+ require "gapic/ruby_info"
19
20
  require "gapic/helpers/namespace_helper"
20
21
 
21
22
  module Gapic
@@ -36,7 +37,11 @@ module Gapic
36
37
  end
37
38
 
38
39
  def name
39
- ActiveSupport::Inflector.underscore @method.name
40
+ @name ||= begin
41
+ candidate = ActiveSupport::Inflector.underscore @method.name
42
+ candidate = "call_#{candidate}" if Gapic::RubyInfo.excluded_method_names.include? candidate
43
+ candidate
44
+ end
40
45
  end
41
46
 
42
47
  def kind
@@ -59,13 +64,13 @@ module Gapic
59
64
 
60
65
  def doc_response_type
61
66
  ret = return_type
62
- ret = "Gapic::Operation" if lro?
67
+ ret = "::Gapic::Operation" if lro?
63
68
  if server_streaming?
64
- ret = "Enumerable<#{ret}>"
69
+ ret = "::Enumerable<#{ret}>"
65
70
  elsif paged?
66
71
  paged_type = paged_response_type
67
- paged_type = "Gapic::Operation" if paged_type == "Google::Longrunning::Operation"
68
- ret = "Gapic::PagedEnumerable<#{paged_type}>"
72
+ paged_type = "::Gapic::Operation" if paged_type == "::Google::Longrunning::Operation"
73
+ ret = "::Gapic::PagedEnumerable<#{paged_type}>"
69
74
  end
70
75
  ret
71
76
  end
@@ -118,7 +123,7 @@ module Gapic
118
123
  return [
119
124
  OpenStruct.new(
120
125
  name: "operation",
121
- doc_types: "Gapic::Operation"
126
+ doc_types: "::Gapic::Operation"
122
127
  )
123
128
  ]
124
129
  end
@@ -129,7 +134,7 @@ module Gapic
129
134
  ),
130
135
  OpenStruct.new(
131
136
  name: "operation",
132
- doc_types: "GRPC::ActiveCall::Operation"
137
+ doc_types: "::GRPC::ActiveCall::Operation"
133
138
  )
134
139
  ]
135
140
  end
@@ -145,9 +150,9 @@ module Gapic
145
150
  end
146
151
 
147
152
  def lro?
148
- return paged_response_type == "Google::Longrunning::Operation" if paged?
153
+ return paged_response_type == "::Google::Longrunning::Operation" if paged?
149
154
 
150
- message_ruby_type(@method.output) == "Google::Longrunning::Operation"
155
+ message_ruby_type(@method.output) == "::Google::Longrunning::Operation"
151
156
  end
152
157
 
153
158
  def client_streaming?
@@ -166,8 +171,9 @@ module Gapic
166
171
  # to be removed when these methods no longer conform to AIP-4233.) For
167
172
  # detailed information, see internal link go/actools-talent-pagination.
168
173
  address = @method.address.join "."
169
- return false if address == "google.cloud.talent.v4beta1.SearchProfiles"
170
- return false if address == "google.cloud.talent.v4beta1.SearchJobs"
174
+ return false if address == "google.cloud.talent.v4beta1.ProfileService.SearchProfiles"
175
+ return false if address == "google.cloud.talent.v4beta1.JobService.SearchJobs"
176
+ return false if address == "google.cloud.talent.v4beta1.JobService.SearchJobsForAlert"
171
177
 
172
178
  paged_request?(@method.input) && paged_response?(@method.output)
173
179
  end
@@ -214,18 +220,18 @@ module Gapic
214
220
 
215
221
  def doc_types_for arg
216
222
  if arg.message?
217
- "#{message_ruby_type arg.message} | Hash"
223
+ "#{message_ruby_type arg.message}, Hash"
218
224
  elsif arg.enum?
219
225
  # TODO: handle when arg message is nil and enum is the type
220
226
  message_ruby_type arg.enum
221
227
  else
222
228
  case arg.type
223
- when 1, 2 then "Float"
224
- when 3, 4, 5, 6, 7, 13, 15, 16, 17, 18 then "Integer"
225
- when 9, 12 then "String"
226
- when 8 then "Boolean"
229
+ when 1, 2 then "::Float"
230
+ when 3, 4, 5, 6, 7, 13, 15, 16, 17, 18 then "::Integer"
231
+ when 9, 12 then "::String"
232
+ when 8 then "::Boolean"
227
233
  else
228
- "Object"
234
+ "::Object"
229
235
  end
230
236
  end
231
237
  end
@@ -250,7 +256,7 @@ module Gapic
250
256
  when 9, 12 then "\"hello world\""
251
257
  when 8 then "true"
252
258
  else
253
- "Object"
259
+ "::Object"
254
260
  end
255
261
  end
256
262
  end
@@ -45,10 +45,25 @@ module Gapic
45
45
  ruby_namespace_for_address address
46
46
  end
47
47
 
48
+ def parent_namespace
49
+ namespace.split("::")[0...-1].join("::")
50
+ end
51
+
52
+ def module_name
53
+ namespace.split("::").last
54
+ end
55
+
56
+ # Services whose clients should be generated in this package namespace.
48
57
  def services
49
58
  @services ||= begin
50
59
  files = @api.generate_files.select { |f| f.package == @package }
51
- files.map(&:services).flatten.map { |s| ServicePresenter.new @api, s }
60
+ services = files.map(&:services).flatten
61
+ # Omit common services in this package. Common service clients do not
62
+ # go into their own package.
63
+ normal_services = services.select { |s| @api.delegate_service_for(s).nil? }
64
+ # But include common services that delegate to normal services in this package.
65
+ common_services = normal_services.flat_map { |s| @api.common_services_for s }
66
+ (normal_services + common_services).map { |s| ServicePresenter.new @api, s }
52
67
  end
53
68
  end
54
69
 
@@ -38,15 +38,9 @@ module Gapic
38
38
  )
39
39
  end
40
40
 
41
- @patterns.each do |pattern|
42
- # URI path template verification for expected proto resource usage
43
- if named_arg_patterns? pattern.segments
44
- raise ArgumentError, "only resources without named patterns are supported, " \
45
- " not #{pattern.template}"
46
- elsif positional_args? pattern.segments
47
- raise ArgumentError, "only resources with named segments are supported, " \
48
- " not #{pattern.template}"
49
- end
41
+ # Keep only patterns that can be used to create path helpers
42
+ @patterns.reject! do |pattern|
43
+ named_arg_patterns?(pattern.segments) || positional_args?(pattern.segments)
50
44
  end
51
45
  end
52
46
 
@@ -55,8 +55,26 @@ module Gapic
55
55
  @service.address
56
56
  end
57
57
 
58
+ # Returns a presenter for this service's delegate (if it is a common service)
59
+ # otherwise returns `nil`.
60
+ def common_service_delegate
61
+ unless defined? @common_service_delegate
62
+ delegate = @api.delegate_service_for @service
63
+ @common_service_delegate = delegate ? ServicePresenter.new(@api, delegate) : nil
64
+ end
65
+ @common_service_delegate
66
+ end
67
+
68
+ # The namespace of the client. Normally this is the version module. This
69
+ # may be different from the proto namespace for a common service.
58
70
  def namespace
59
- return @service.ruby_package if @service.ruby_package.present?
71
+ # If this service is a common service, its client should go into its
72
+ # delegate's namespace rather than its own. For example, KMS includes
73
+ # the common IAMPolicy service, but that service's client should go
74
+ # into the KMS namespace.
75
+ return common_service_delegate.namespace if common_service_delegate
76
+
77
+ return ensure_absolute_namespace @service.ruby_package if @service.ruby_package.present?
60
78
 
61
79
  namespace = ruby_namespace_for_address @service.address[0...-1]
62
80
  fix_namespace @api, namespace
@@ -74,8 +92,22 @@ module Gapic
74
92
  @service.name
75
93
  end
76
94
 
95
+ # The namespace of the protos. This may be different from the client
96
+ # namespace for a common service.
97
+ def proto_namespace
98
+ return ensure_absolute_namespace @service.ruby_package if @service.ruby_package.present?
99
+
100
+ namespace = ruby_namespace_for_address @service.address[0...-1]
101
+ @api.override_proto_namespaces? ? fix_namespace(@api, namespace) : namespace
102
+ end
103
+
77
104
  def proto_service_name_full
78
- fix_namespace @api, "#{namespace}::#{name}"
105
+ name_full = "#{proto_namespace}::#{name}"
106
+ @api.override_proto_namespaces? ? fix_namespace(@api, name_full) : name_full
107
+ end
108
+
109
+ def module_name
110
+ service_name_full.split("::").last
79
111
  end
80
112
 
81
113
  def proto_service_file_path
@@ -106,6 +138,10 @@ module Gapic
106
138
  "#{proto_service_name_full}::Stub"
107
139
  end
108
140
 
141
+ def service_name_full
142
+ fix_namespace @api, "#{namespace}::#{name}"
143
+ end
144
+
109
145
  def service_file_path
110
146
  service_require + ".rb"
111
147
  end
@@ -114,8 +150,12 @@ module Gapic
114
150
  service_file_path.split("/").last
115
151
  end
116
152
 
153
+ def service_directory_name
154
+ service_require.split("/").last
155
+ end
156
+
117
157
  def service_require
118
- ruby_file_path @api, proto_service_name_full
158
+ ruby_file_path @api, service_name_full
119
159
  end
120
160
 
121
161
  def client_name
@@ -123,7 +163,7 @@ module Gapic
123
163
  end
124
164
 
125
165
  def client_name_full
126
- fix_namespace @api, "#{proto_service_name_full}::#{client_name}"
166
+ fix_namespace @api, "#{service_name_full}::#{client_name}"
127
167
  end
128
168
 
129
169
  def create_client_call
@@ -147,12 +187,17 @@ module Gapic
147
187
  end
148
188
 
149
189
  def client_endpoint
150
- return @parent_service.client_endpoint if @parent_service
151
- @service.host || default_config(:default_host) || "localhost"
190
+ @parent_service&.client_endpoint ||
191
+ common_service_delegate&.client_endpoint ||
192
+ @service.host ||
193
+ default_config(:default_host) ||
194
+ "localhost"
152
195
  end
153
196
 
154
197
  def client_scopes
155
- @service.scopes || default_config(:oauth_scopes)
198
+ common_service_delegate&.client_scopes ||
199
+ @service.scopes ||
200
+ default_config(:oauth_scopes)
156
201
  end
157
202
 
158
203
  def client_proto_name
@@ -164,7 +209,7 @@ module Gapic
164
209
  end
165
210
 
166
211
  def credentials_name_full
167
- fix_namespace @api, "#{proto_service_name_full}::#{credentials_name}"
212
+ fix_namespace @api, "#{service_name_full}::#{credentials_name}"
168
213
  end
169
214
 
170
215
  def credentials_class_xref
@@ -192,7 +237,7 @@ module Gapic
192
237
  end
193
238
 
194
239
  def helpers_require
195
- ruby_file_path @api, "#{proto_service_name_full}::Helpers"
240
+ ruby_file_path @api, "#{service_name_full}::Helpers"
196
241
  end
197
242
 
198
243
  def references
@@ -208,7 +253,7 @@ module Gapic
208
253
  end
209
254
 
210
255
  def paths_name_full
211
- fix_namespace @api, "#{proto_service_name_full}::#{paths_name}"
256
+ fix_namespace @api, "#{service_name_full}::#{paths_name}"
212
257
  end
213
258
 
214
259
  def paths_file_path
@@ -220,7 +265,7 @@ module Gapic
220
265
  end
221
266
 
222
267
  def paths_require
223
- ruby_file_path @api, "#{proto_service_name_full}::#{paths_name}"
268
+ ruby_file_path @api, "#{service_name_full}::#{paths_name}"
224
269
  end
225
270
 
226
271
  def test_client_file_path
@@ -252,7 +297,7 @@ module Gapic
252
297
  end
253
298
 
254
299
  def operations_name_full
255
- fix_namespace @api, "#{proto_service_name_full}::#{operations_name}"
300
+ fix_namespace @api, "#{service_name_full}::#{operations_name}"
256
301
  end
257
302
 
258
303
  def operations_file_path
@@ -264,7 +309,7 @@ module Gapic
264
309
  end
265
310
 
266
311
  def operations_require
267
- ruby_file_path @api, "#{proto_service_name_full}::#{operations_name}"
312
+ ruby_file_path @api, "#{service_name_full}::#{operations_name}"
268
313
  end
269
314
 
270
315
  def lro_service