-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate bindings override for REST mixins (#865)
- Loading branch information
1 parent
b26b3e0
commit 354157d
Showing
49 changed files
with
305 additions
and
2,223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%- assert_locals package -%> | ||
<%= render partial: "lib/binding_override", | ||
layout: "layouts/ruby", | ||
locals: { package: package, | ||
namespace: package.parent_namespace } | ||
%> |
23 changes: 23 additions & 0 deletions
23
gapic-generator/templates/default/lib/_binding_override.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<%- assert_locals package -%> | ||
<% @requires = capture do %> | ||
require "gapic/config" | ||
<%- end -%> | ||
|
||
module <%= package.module_name %> | ||
def self.configure | ||
<%= indent render(partial: "lib/package/self_configure", locals: { package: package }), 4 %> | ||
end | ||
|
||
class Configuration | ||
extend ::Gapic::Config | ||
|
||
config_attr :bindings_override, {}, ::Hash, nil | ||
|
||
# @private | ||
def initialize parent_config = nil | ||
@parent_config = parent_config unless parent_config.nil? | ||
|
||
yield self if block_given? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
gapic-generator/templates/default/lib/package/_self_configure.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<%- assert_locals package -%> | ||
@configure ||= begin | ||
namespace = <%= package.parent_namespace.split("::").reject(&:empty?).inspect %> | ||
parent_config = while namespace.any? | ||
parent_name = namespace.join "::" | ||
parent_const = const_get parent_name | ||
break parent_const.configure if parent_const.respond_to? :configure | ||
namespace.pop | ||
end | ||
|
||
default_config = Configuration.new parent_config | ||
<%= indent_tail render(partial: "lib/package/self_configure_defaults", locals: {package: package}), 2 %> | ||
default_config | ||
end | ||
yield @configure if block_given? | ||
@configure |
13 changes: 13 additions & 0 deletions
13
gapic-generator/templates/default/lib/package/_self_configure_defaults.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<%- assert_locals package -%> | ||
<%- package.first_service_with_rest.rest.mixin_presenters.each do |subclient| -%> | ||
<%- subclient.bindings_override.each do |method, bindings| -%> | ||
default_config.bindings_override["<%= method %>"] = [ | ||
|
||
<%- last_binding_index = bindings.count - 1 -%> | ||
<%- bindings.each_with_index do |http_binding, index| -%> | ||
<%- comma = last_binding_index == index ? "" : "," -%> | ||
<%= indent render(partial: "lib/package/self_configure/binding_default", locals: { http_binding: http_binding }), 4 %><%= comma %> | ||
<%- end -%> | ||
] | ||
<%- end -%> | ||
<%- end -%> |
15 changes: 15 additions & 0 deletions
15
gapic-generator/templates/default/lib/package/self_configure/_binding_default.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<%- assert_locals http_binding -%> | ||
Gapic::Rest::GrpcTranscoder::HttpBinding.create_with_validation( | ||
uri_method: :<%= http_binding.verb %>, | ||
uri_template: "<%= http_binding.uri_for_transcoding %>", | ||
matches: [ | ||
<%- http_binding.routing_params_transcoder_matches_strings.each do |match_str| -%> | ||
<%= match_str %> | ||
<%- end -%> | ||
], | ||
<%- if http_binding.body? -%> | ||
body: "<%= http_binding.body %>" | ||
<%- else -%> | ||
body: nil | ||
<%- end -%> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...-generator/templates/default/service/rest/client/method/def/_response_nonstandard_lro.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
gapic-generator/templates/default/service/rest/client/method/def/_response_normal.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
gapic-generator/templates/default/service/rest/client/method/def/_response_paged.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
gapic-generator/templates/default/service/rest/service_stub/method/def/_response.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.