templates/default/service/client/_client.erb in gapic-generator-0.10.1 vs templates/default/service/client/_client.erb in gapic-generator-0.11.0
- old
+ new
@@ -1,9 +1,16 @@
<%- assert_locals service -%>
<% @requires = capture do %>
<%= render partial: "service/client/requires", locals: { service: service} -%>
require "<%= service.proto_service_require %>"
+<%- if service.subclients? -%>
+<%- service.subclients.each do |subclient| -%>
+<%- unless subclient.client_class_name == "Operations" -%>
+require "<%= subclient.require_str %>"
+<%- end -%>
+<%- end -%>
+<%- end -%>
<% end %>
##
# Client for the <%= service.name %> service.
#
<%- if service.doc_description -%>
@@ -107,38 +114,43 @@
end
<%- end -%>
@quota_project_id = @config.quota_project
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
- <%- if service.lro? -%>
- <%= service.lro_client_ivar %> = <%= service.operations_name %>.new do |config|
+ <%- if service.subclients? -%>
+ <%- service.subclients.each do |subclient| -%>
+ @<%= subclient.client_var_name %> = <%= subclient.client_class_name %>.new do |config|
config.credentials = credentials
+ config.quota_project = @quota_project_id
config.endpoint = @config.endpoint
end
<%- end -%>
+ <%- end -%>
@<%= service.stub_name %> = ::Gapic::ServiceStub.new(
<%= service.proto_service_stub_name_full %>,
credentials: credentials,
endpoint: @config.endpoint,
channel_args: @config.channel_args,
interceptors: @config.interceptors
)
end
-<%- if service.lro? -%>
+ <%- if service.subclients? -%>
+ <%- service.subclients.each do |subclient| -%>
##
- # Get the associated client for long-running operations.
+ # Get the associated client for <%= subclient.service_description %>.
#
- # @return [<%= service.operations_name_full %>]
+ # @return [<%= subclient.client_class_docname %>]
#
- attr_reader :<%= service.lro_client_var %>
+ attr_reader :<%= subclient.client_var_name %>
-<%- end -%>
+ <%- end -%>
+ <%- end -%>
# Service calls
<%- service.methods.each do |method| -%>
<%= indent_tail render(partial: "service/client/method/def", locals: { method: method }), 2 %>
- <%- end %>
+ <%- end -%>
<%= indent_tail render(partial: "service/client/config", locals: { service: service }), 2 %>
end