gapic-generator 0.10.1 → 0.45.1
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 +4 -4
- data/CHANGELOG.md +333 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +71 -37
- data/bin/protoc-gen-ruby_gapic +2 -2
- data/lib/gapic/file_formatter.rb +23 -19
- data/lib/gapic/formatting_utils.rb +22 -9
- data/lib/gapic/gem_builder.rb +15 -17
- data/lib/gapic/generator/version.rb +1 -1
- data/lib/gapic/generators/base_generator.rb +6 -4
- data/lib/gapic/generators/default_generator.rb +70 -32
- data/lib/gapic/generators/default_generator_parameters.rb +11 -3
- data/lib/gapic/grpc_service_config/{service_config.rb → config.rb} +2 -2
- data/lib/gapic/grpc_service_config/parser.rb +10 -10
- data/lib/gapic/model/api_metadata.rb +173 -0
- data/lib/gapic/model/method/http_annotation.rb +221 -0
- data/lib/gapic/model/method/lro.rb +163 -0
- data/lib/gapic/model/method/routing.rb +248 -0
- data/lib/gapic/model/mixins.rb +247 -0
- data/lib/gapic/model/model_error.rb +26 -0
- data/lib/gapic/model/service/nonstandard_lro_provider.rb +292 -0
- data/lib/gapic/model.rb +22 -0
- data/lib/gapic/package_snippets.rb +159 -0
- data/lib/gapic/path_pattern/parser.rb +11 -2
- data/lib/gapic/path_pattern/pattern.rb +64 -1
- data/lib/gapic/path_pattern/segment.rb +108 -13
- data/lib/gapic/presenters/enum_presenter.rb +14 -0
- data/lib/gapic/presenters/enum_value_presenter.rb +4 -1
- data/lib/gapic/presenters/field_presenter.rb +78 -21
- data/lib/gapic/presenters/gem_presenter.rb +140 -34
- data/lib/gapic/presenters/{service_config_presenter.rb → grpc_service_config_presenter.rb} +1 -1
- data/lib/gapic/presenters/message_presenter.rb +15 -0
- data/lib/gapic/presenters/method/http_binding_presenter.rb +128 -0
- data/lib/gapic/presenters/method/rest_pagination_info.rb +25 -16
- data/lib/gapic/presenters/method_presenter.rb +149 -35
- data/lib/gapic/presenters/method_rest_presenter.rb +79 -168
- data/lib/gapic/presenters/package_presenter.rb +63 -18
- data/lib/gapic/presenters/resource_presenter.rb +9 -3
- data/lib/gapic/presenters/service/lro_client_presenter.rb +90 -0
- data/lib/gapic/presenters/service/mixin_client_presenter.rb +89 -0
- data/lib/gapic/presenters/service/sub_client_presenter.rb +84 -0
- data/lib/gapic/presenters/service_presenter.rb +361 -27
- data/lib/gapic/presenters/service_rest_presenter.rb +247 -13
- data/lib/gapic/presenters/snippet/client_call_presenter.rb +82 -0
- data/lib/gapic/presenters/snippet/client_initialization_presenter.rb +87 -0
- data/lib/gapic/presenters/snippet/declaration_presenter.rb +91 -0
- data/lib/gapic/presenters/snippet/expression_presenter.rb +135 -0
- data/lib/gapic/presenters/snippet/iteration_presenter.rb +118 -0
- data/lib/gapic/presenters/snippet/parameter_presenter.rb +67 -0
- data/lib/gapic/presenters/snippet/request_initialization_presenters.rb +202 -0
- data/lib/gapic/presenters/snippet/response_handling_presenters.rb +329 -0
- data/lib/gapic/presenters/snippet/statement_presenter.rb +134 -0
- data/lib/gapic/presenters/snippet/type_presenter.rb +98 -0
- data/lib/gapic/presenters/snippet_presenter.rb +199 -9
- data/lib/gapic/presenters.rb +5 -1
- data/lib/gapic/runner.rb +1 -1
- data/lib/gapic/schema/api.rb +105 -5
- data/lib/gapic/schema/loader.rb +69 -21
- data/lib/gapic/schema/parameter_schema.rb +8 -8
- data/lib/gapic/schema/proto_tools.rb +193 -0
- data/lib/gapic/schema/request_param_parser.rb +5 -7
- data/lib/gapic/schema/service_config_parser.rb +152 -0
- data/lib/gapic/schema/wrappers.rb +309 -25
- data/lib/gapic/uri_template/parser.rb +15 -7
- data/lib/google/cloud/tools/snippetgen/configlanguage/v1/snippet_config_language_pb.rb +104 -0
- data/lib/google/cloud/tools/snippetgen/snippetindex/v1/snippet_index_pb.rb +58 -0
- data/lib/google/protobuf/compiler/plugin_pb.rb +47 -0
- data/templates/default/binding_override.text.erb +6 -0
- data/templates/default/gem/gemfile.text.erb +12 -0
- data/templates/default/gem/{gemspec.erb → gemspec.text.erb} +3 -11
- data/templates/default/gem/{readme.erb → readme.text.erb} +10 -6
- data/templates/default/gem/{rubocop.erb → rubocop.text.erb} +3 -0
- data/templates/default/gem/{test_helper.erb → test_helper.text.erb} +4 -2
- data/templates/default/gem/toys.text.erb +12 -0
- data/templates/default/gem/{yardopts.erb → yardopts.text.erb} +1 -1
- data/templates/default/helpers/default_helper.rb +33 -1
- data/templates/default/lib/_binding_override.text.erb +49 -0
- data/templates/default/lib/{_package.erb → _package.text.erb} +7 -6
- data/templates/default/lib/_package_rest.text.erb +24 -0
- data/templates/default/lib/{_service.erb → _service.text.erb} +14 -20
- data/templates/default/lib/package/_self_configure.text.erb +16 -0
- data/templates/default/lib/package/_self_configure_defaults.text.erb +13 -0
- data/templates/default/lib/package/self_configure/_binding_default.text.erb +15 -0
- data/templates/default/lib/rest/_rest.text.erb +46 -0
- data/templates/default/package_rest.text.erb +6 -0
- data/templates/default/proto_docs/_deprecated.text.erb +9 -0
- data/templates/default/proto_docs/{_enum.erb → _enum.text.erb} +1 -0
- data/templates/default/proto_docs/{_message.erb → _message.text.erb} +2 -0
- data/templates/default/service/client/{_client.erb → _client.text.erb} +77 -17
- data/templates/default/service/client/{_config.erb → _config.text.erb} +39 -8
- data/templates/default/service/client/_nonstandard_lro.text.erb +57 -0
- data/templates/default/service/client/{_operations.erb → _operations.text.erb} +24 -3
- data/templates/default/service/client/{_self_configure_defaults.erb → _self_configure_defaults.text.erb} +2 -2
- data/templates/default/service/client/method/{_def.erb → _def.text.erb} +2 -2
- data/templates/default/service/client/method/def/{_options_defaults.erb → _options_defaults.text.erb} +3 -9
- data/templates/default/service/client/method/def/_request_normal.text.erb +18 -0
- data/templates/default/service/client/method/def/_request_streaming.text.erb +23 -0
- data/templates/default/service/client/method/def/_response.text.erb +10 -0
- data/templates/default/service/client/method/def/_response_nonstandard_lro.text.erb +23 -0
- data/templates/default/service/client/method/def/_response_normal.text.erb +4 -0
- data/templates/default/service/client/method/def/{_response_normal.erb → _response_normal_lro.text.erb} +1 -3
- data/templates/default/service/client/method/def/{_response_paged.erb → _response_paged.text.erb} +1 -1
- data/templates/default/service/client/method/def/_routing_params.text.erb +36 -0
- data/templates/default/service/client/method/docs/{_request_normal.erb → _request_normal.text.erb} +1 -1
- data/templates/default/service/client/method/docs/_snippets.text.erb +6 -0
- data/templates/default/service/client/resource/_def.text.erb +7 -0
- data/templates/default/service/nonstandard_lro.text.erb +6 -0
- data/templates/default/service/rest/client/_client.text.erb +202 -0
- data/templates/default/service/rest/client/_config.text.erb +178 -0
- data/templates/default/service/rest/client/_operations.text.erb +124 -0
- data/templates/default/service/rest/client/method/{_def.erb → _def.text.erb} +7 -1
- data/templates/default/service/rest/client/method/def/{_options_defaults.erb → _options_defaults.text.erb} +8 -3
- data/templates/default/service/rest/client/method/def/_response.text.erb +12 -0
- data/templates/default/service/rest/client/method/def/_response_nonstandard_lro.text.erb +24 -0
- data/templates/default/service/rest/client/method/def/_response_normal.text.erb +5 -0
- data/templates/default/service/rest/client/method/def/_response_normal_lro.text.erb +7 -0
- data/templates/default/service/rest/client/method/def/_response_paged.text.erb +7 -0
- data/templates/default/service/rest/client/method/def/_response_server_streaming.text.erb +11 -0
- data/templates/default/service/rest/client/method/docs/{_request.erb → _request.text.erb} +1 -3
- data/templates/default/service/rest/client/method/docs/_result.text.erb +10 -0
- data/templates/default/service/rest/client/method/docs/_snippets.text.erb +6 -0
- data/templates/default/service/rest/nonstandard_lro.text.erb +6 -0
- data/templates/default/service/rest/operations.text.erb +6 -0
- data/templates/default/service/rest/service_stub/_service_stub.text.erb +63 -0
- data/templates/default/service/rest/service_stub/grpc_transcoding_method/_def.text.erb +37 -0
- data/templates/default/service/rest/service_stub/method/_def.text.erb +35 -0
- data/templates/default/service/rest/service_stub/method/def/_response.text.erb +37 -0
- data/templates/default/service/rest/test/{client.erb → client.text.erb} +3 -3
- data/templates/default/service/rest/test/method/_assert_response.text.erb +2 -0
- data/templates/default/service/rest/test/method/{_configure.erb → _configure.text.erb} +3 -2
- data/templates/default/service/rest/test/method/_normal.text.erb +60 -0
- data/templates/default/service/rest/test/method/_server.text.erb +60 -0
- data/templates/default/service/rest/test/method/{_setup.erb → _setup.text.erb} +26 -10
- data/templates/default/service/test/{_resource.erb → _resource.text.erb} +1 -1
- data/templates/default/service/test/{client.erb → client.text.erb} +3 -2
- data/templates/default/service/test/client_paths.text.erb +33 -0
- data/templates/default/service/test/method/{_assert_response.erb → _assert_response.text.erb} +3 -0
- data/templates/default/service/test/method/{_bidi.erb → _bidi.text.erb} +1 -1
- data/templates/default/service/test/method/{_client.erb → _client.text.erb} +1 -1
- data/templates/default/service/test/method/{_configure.erb → _configure.text.erb} +2 -1
- data/templates/default/service/test/method/{_normal.erb → _normal.text.erb} +1 -1
- data/templates/default/service/test/method/{_server.erb → _server.text.erb} +1 -1
- data/templates/default/service/test/method/{_setup.erb → _setup.text.erb} +19 -2
- data/templates/default/snippets/{gemfile.erb → gemfile.text.erb} +2 -2
- data/templates/default/snippets/snippet/_body.text.erb +24 -0
- data/templates/default/snippets/snippet/_inline.text.erb +11 -0
- data/templates/default/snippets/snippet/_standalone.text.erb +25 -0
- data/templates/default/snippets/{standalone.erb → standalone.text.erb} +1 -1
- metadata +209 -230
- data/lib/google/api/annotations.pb.rb +0 -39
- data/lib/google/api/client.pb.rb +0 -43
- data/lib/google/api/field_behavior.pb.rb +0 -51
- data/lib/google/api/http.pb.rb +0 -60
- data/lib/google/api/resource.pb.rb +0 -80
- data/lib/google/longrunning/operations.pb.rb +0 -115
- data/lib/google/protobuf/any.pb.rb +0 -40
- data/lib/google/protobuf/compiler/plugin.pb.rb +0 -79
- data/lib/google/protobuf/descriptor.pb.rb +0 -360
- data/lib/google/protobuf/empty.pb.rb +0 -36
- data/lib/google/rpc/status.pb.rb +0 -46
- data/templates/default/gem/gemfile.erb +0 -4
- data/templates/default/lib/rest/_rest.erb +0 -9
- data/templates/default/service/client/method/def/_request_normal.erb +0 -4
- data/templates/default/service/client/method/def/_request_streaming.erb +0 -9
- data/templates/default/service/client/method/def/_response.erb +0 -6
- data/templates/default/service/client/method/docs/_deprecated.erb +0 -5
- data/templates/default/service/client/method/docs/_snippets.erb +0 -6
- data/templates/default/service/client/resource/_def.erb +0 -6
- data/templates/default/service/rest/client/_client.erb +0 -106
- data/templates/default/service/rest/client/_config.erb +0 -122
- data/templates/default/service/rest/client/method/def/_response.erb +0 -8
- data/templates/default/service/rest/client/method/def/_response_lro.erb +0 -7
- data/templates/default/service/rest/client/method/def/_response_normal.erb +0 -6
- data/templates/default/service/rest/client/method/def/_response_paged.erb +0 -7
- data/templates/default/service/rest/client/method/docs/_result.erb +0 -6
- data/templates/default/service/rest/service_stub/_service_stub.erb +0 -25
- data/templates/default/service/rest/service_stub/grpc_transcoding_method/_def.erb +0 -24
- data/templates/default/service/rest/service_stub/method/_def.erb +0 -20
- data/templates/default/service/rest/service_stub/method/def/_response.erb +0 -17
- data/templates/default/service/rest/test/method/_assert_response.erb +0 -2
- data/templates/default/service/rest/test/method/_normal.erb +0 -71
- data/templates/default/service/test/client_paths.erb +0 -15
- data/templates/default/snippets/snippet/_structure.erb +0 -71
- /data/gem_templates/{binary.erb → binary.text.erb} +0 -0
- /data/gem_templates/{dockerfile.erb → dockerfile.text.erb} +0 -0
- /data/gem_templates/{entrypoint.erb → entrypoint.text.erb} +0 -0
- /data/gem_templates/{gapic_sh.erb → gapic_sh.text.erb} +0 -0
- /data/gem_templates/{gemfile.erb → gemfile.text.erb} +0 -0
- /data/gem_templates/{gemspec.erb → gemspec.text.erb} +0 -0
- /data/gem_templates/{generator.erb → generator.text.erb} +0 -0
- /data/gem_templates/{gitignore.erb → gitignore.text.erb} +0 -0
- /data/gem_templates/{rakefile.erb → rakefile.text.erb} +0 -0
- /data/gem_templates/{readme.erb → readme.text.erb} +0 -0
- /data/gem_templates/{rubocop.erb → rubocop.text.erb} +0 -0
- /data/gem_templates/shared/{_header.erb → _header.text.erb} +0 -0
- /data/gem_templates/shared/{_license.erb → _license.text.erb} +0 -0
- /data/gem_templates/shared/{_warning.erb → _warning.text.erb} +0 -0
- /data/gem_templates/{test_generator.erb → test_generator.text.erb} +0 -0
- /data/gem_templates/{test_helper.erb → test_helper.text.erb} +0 -0
- /data/gem_templates/{version.erb → version.text.erb} +0 -0
- /data/templates/default/gem/{_version.erb → _version.text.erb} +0 -0
- /data/templates/default/gem/{changelog.erb → changelog.text.erb} +0 -0
- /data/templates/default/gem/{entrypoint.erb → entrypoint.text.erb} +0 -0
- /data/templates/default/gem/{gapic_metadata_json.erb → gapic_metadata_json.text.erb} +0 -0
- /data/templates/default/gem/{gitignore.erb → gitignore.text.erb} +0 -0
- /data/templates/default/gem/{license.erb → license.text.erb} +0 -0
- /data/templates/default/gem/{rakefile.erb → rakefile.text.erb} +0 -0
- /data/templates/default/gem/{version.erb → version.text.erb} +0 -0
- /data/templates/default/layouts/{_ruby.erb → _ruby.text.erb} +0 -0
- /data/templates/default/{package.erb → package.text.erb} +0 -0
- /data/templates/default/proto_docs/{_proto_file.erb → _proto_file.text.erb} +0 -0
- /data/templates/default/proto_docs/{proto_file.erb → proto_file.text.erb} +0 -0
- /data/templates/default/proto_docs/{readme.erb → readme.text.erb} +0 -0
- /data/templates/default/service/{_helpers.erb → _helpers.text.erb} +0 -0
- /data/templates/default/service/client/{_credentials.erb → _credentials.text.erb} +0 -0
- /data/templates/default/service/client/{_paths.erb → _paths.text.erb} +0 -0
- /data/templates/default/service/client/{_requires.erb → _requires.text.erb} +0 -0
- /data/templates/default/service/client/{_resource.erb → _resource.text.erb} +0 -0
- /data/templates/default/service/client/{_self_configure.erb → _self_configure.text.erb} +0 -0
- /data/templates/default/service/client/method/def/{_request.erb → _request.text.erb} +0 -0
- /data/templates/default/service/client/method/def/{_rescue.erb → _rescue.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/{_error.erb → _error.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/{_request.erb → _request.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/{_request_field.erb → _request_field.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/{_request_streaming.erb → _request_streaming.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/{_response.erb → _response.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/{_sample.erb → _sample.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/{_sample_response.erb → _sample_response.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/{_samples.erb → _samples.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/request_field/{_arg.erb → _arg.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/request_field/{_hash.erb → _hash.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/sample_response/{_comment.erb → _comment.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/sample_response/{_define.erb → _define.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/sample_response/{_loop.erb → _loop.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/sample_response/{_print.erb → _print.text.erb} +0 -0
- /data/templates/default/service/client/method/docs/sample_response/{_write_file.erb → _write_file.text.erb} +0 -0
- /data/templates/default/service/client/resource/{_doc.erb → _doc.text.erb} +0 -0
- /data/templates/default/service/client/resource/{_multi.erb → _multi.text.erb} +0 -0
- /data/templates/default/service/client/resource/{_single.erb → _single.text.erb} +0 -0
- /data/templates/default/service/{client.erb → client.text.erb} +0 -0
- /data/templates/default/service/{credentials.erb → credentials.text.erb} +0 -0
- /data/templates/default/service/{operations.erb → operations.text.erb} +0 -0
- /data/templates/default/service/{paths.erb → paths.text.erb} +0 -0
- /data/templates/default/service/rest/client/method/def/{_rescue.erb → _rescue.text.erb} +0 -0
- /data/templates/default/service/rest/client/method/docs/{_error.erb → _error.text.erb} +0 -0
- /data/templates/default/service/rest/{client.erb → client.text.erb} +0 -0
- /data/templates/default/service/rest/{grpc_transcoding.erb → grpc_transcoding.text.erb} +0 -0
- /data/templates/default/service/rest/service_stub/grpc_transcoding_method/def/{_query_string_param.erb → _query_string_param.text.erb} +0 -0
- /data/templates/default/service/rest/service_stub/method/def/{_request.erb → _request.text.erb} +0 -0
- /data/templates/default/service/rest/{service_stub.erb → service_stub.text.erb} +0 -0
- /data/templates/default/service/{rest.erb → rest.text.erb} +0 -0
- /data/templates/default/service/test/{client_operations.erb → client_operations.text.erb} +0 -0
- /data/templates/default/service/test/{smoke.erb → smoke.text.erb} +0 -0
- /data/templates/default/{service.erb → service.text.erb} +0 -0
- /data/templates/default/shared/{_header.erb → _header.text.erb} +0 -0
- /data/templates/default/shared/{_license.erb → _license.text.erb} +0 -0
- /data/templates/default/shared/{_warning.erb → _warning.text.erb} +0 -0
@@ -16,6 +16,9 @@
|
|
16
16
|
|
17
17
|
require "gapic/formatting_utils"
|
18
18
|
require "gapic/path_pattern"
|
19
|
+
require "gapic/schema/proto_tools"
|
20
|
+
|
21
|
+
require "google/cloud/tools/snippetgen/configlanguage/v1/snippet_config_language_pb"
|
19
22
|
|
20
23
|
module Gapic
|
21
24
|
module Schema
|
@@ -98,6 +101,7 @@ module Gapic
|
|
98
101
|
@descriptor = descriptor
|
99
102
|
@address = address
|
100
103
|
@docs = docs
|
104
|
+
@options_extensions = nil
|
101
105
|
end
|
102
106
|
|
103
107
|
# Returns the "root" of this schema.
|
@@ -118,18 +122,51 @@ module Gapic
|
|
118
122
|
# @param disable_xrefs [Boolean] (default is `false`) Disable linking to
|
119
123
|
# cross-references, and render them simply as text. This can be used if
|
120
124
|
# it is known that the targets are not present in the current library.
|
125
|
+
# @param transport [:rest,:grpc] The transport for client classes.
|
126
|
+
# Optional; falls back to the default transport if not given.
|
121
127
|
# @return [String]
|
122
128
|
#
|
123
|
-
def docs_leading_comments disable_xrefs: false
|
129
|
+
def docs_leading_comments disable_xrefs: false, transport: nil
|
124
130
|
return nil if @docs.nil?
|
125
131
|
return nil if @docs.leading_comments.empty?
|
126
132
|
|
133
|
+
transport ||= containing_api.default_transport
|
127
134
|
lines = @docs.leading_comments.each_line.to_a
|
128
|
-
lines.map! { |line| line.start_with?(" ") ? line[1
|
129
|
-
lines = FormattingUtils.format_doc_lines containing_api, lines,
|
135
|
+
lines.map! { |line| line.start_with?(" ") ? line[1..] : line }
|
136
|
+
lines = FormattingUtils.format_doc_lines containing_api, lines,
|
137
|
+
disable_xrefs: disable_xrefs,
|
138
|
+
transport: transport
|
130
139
|
lines.join
|
131
140
|
end
|
132
141
|
|
142
|
+
##
|
143
|
+
# Return the options. This method must be overridden by a subclass.
|
144
|
+
#
|
145
|
+
def options
|
146
|
+
raise UnimplementedError
|
147
|
+
end
|
148
|
+
|
149
|
+
##
|
150
|
+
# Return a configuration of supported option extensions.
|
151
|
+
# This method should be overridden by a subclass.
|
152
|
+
#
|
153
|
+
def option_extension_names
|
154
|
+
{}
|
155
|
+
end
|
156
|
+
|
157
|
+
##
|
158
|
+
# Return the value of the named option, or nil if not found.
|
159
|
+
#
|
160
|
+
def option_named name
|
161
|
+
return nil unless options
|
162
|
+
result = options[name]
|
163
|
+
return result unless result.nil?
|
164
|
+
name = option_extension_names.keys.find { |key| key.end_with? ".#{name}" } unless name.include? "."
|
165
|
+
return nil unless name
|
166
|
+
@options_extensions ||= ProtoTools.parse_options_extensions options, option_extension_names
|
167
|
+
@options_extensions[name]
|
168
|
+
end
|
169
|
+
|
133
170
|
# @!method path
|
134
171
|
# @return [Array<Integer>]
|
135
172
|
# Identifies which part of the FileDescriptorProto was defined at
|
@@ -249,16 +286,34 @@ module Gapic
|
|
249
286
|
@methods.each { |m| m.parent = self }
|
250
287
|
end
|
251
288
|
|
289
|
+
OPTION_EXTENSION_NAMES = {
|
290
|
+
"google.api.default_host" => [1049, :string],
|
291
|
+
"google.api.oauth_scopes" => [1050, :string],
|
292
|
+
"google.api.api_version" => [525_000_001, :string]
|
293
|
+
}.freeze
|
294
|
+
|
295
|
+
##
|
296
|
+
# Return a configuration of supported option extensions.
|
297
|
+
#
|
298
|
+
def option_extension_names
|
299
|
+
OPTION_EXTENSION_NAMES
|
300
|
+
end
|
301
|
+
|
252
302
|
# @return [String] The hostname for this service
|
253
303
|
# (e.g. "foo.googleapis.com"). This should be specified with no
|
254
304
|
# prefix.
|
255
305
|
def host
|
256
|
-
|
306
|
+
option_named "google.api.default_host"
|
257
307
|
end
|
258
308
|
|
259
309
|
# @return [Array<String>] The OAuth scopes information for the client.
|
260
310
|
def scopes
|
261
|
-
String(
|
311
|
+
String(option_named("google.api.oauth_scopes")).split ","
|
312
|
+
end
|
313
|
+
|
314
|
+
# @return [String] The API version for this service.
|
315
|
+
def api_version
|
316
|
+
option_named "google.api.api_version"
|
262
317
|
end
|
263
318
|
|
264
319
|
# @return [String] Ruby Package
|
@@ -269,9 +324,9 @@ module Gapic
|
|
269
324
|
end
|
270
325
|
|
271
326
|
# @return [Boolean] True if this service is marked as deprecated, false
|
272
|
-
#
|
327
|
+
# otherwise.
|
273
328
|
def is_deprecated?
|
274
|
-
|
329
|
+
option_named "deprecated"
|
275
330
|
end
|
276
331
|
|
277
332
|
# @return [Array<Google::Api::ResourceDescriptor>] A representation of the resource.
|
@@ -283,6 +338,15 @@ module Gapic
|
|
283
338
|
@resources ||= Gapic::ResourceLookup.for_service self
|
284
339
|
end
|
285
340
|
|
341
|
+
# @return [String] The full name for this service
|
342
|
+
# (e.g. `google.example.Service`).
|
343
|
+
# Useful when matching against other pieces of information
|
344
|
+
# which also reference full proto name, e.g. Service Config
|
345
|
+
# or Grpc Service Config
|
346
|
+
def full_name
|
347
|
+
@address.join "."
|
348
|
+
end
|
349
|
+
|
286
350
|
# @!method name
|
287
351
|
# @return [String] the unqualified name of the service.
|
288
352
|
# @!method options
|
@@ -322,12 +386,28 @@ module Gapic
|
|
322
386
|
@output = output
|
323
387
|
end
|
324
388
|
|
389
|
+
OPTION_EXTENSION_NAMES = {
|
390
|
+
"google.api.method_signature" => [1050, :string, :repeated],
|
391
|
+
"google.api.http" => [72_295_728, ::Google::Api::HttpRule],
|
392
|
+
"google.api.routing" => [72_295_729, ::Google::Api::RoutingRule],
|
393
|
+
"google.cloud.operation_polling_method" => [1250, :bool],
|
394
|
+
"google.cloud.operation_service" => [1249, :string],
|
395
|
+
"google.longrunning.operation_info" => [1049, ::Google::Longrunning::OperationInfo]
|
396
|
+
}.freeze
|
397
|
+
|
398
|
+
##
|
399
|
+
# Return a configuration of supported option extensions.
|
400
|
+
#
|
401
|
+
def option_extension_names
|
402
|
+
OPTION_EXTENSION_NAMES
|
403
|
+
end
|
404
|
+
|
325
405
|
# @return [Array<Array<String>>] The parameter lists
|
326
406
|
# defined for this method. See `google/api/client.proto`.
|
327
407
|
def signatures
|
328
408
|
return [] if options.nil?
|
329
409
|
|
330
|
-
Array(
|
410
|
+
Array(option_named("google.api.method_signature")).map do |sig|
|
331
411
|
String(sig).split ","
|
332
412
|
end
|
333
413
|
end
|
@@ -339,19 +419,48 @@ module Gapic
|
|
339
419
|
# Required for methods that return `google.longrunning.Operation`;
|
340
420
|
# invalid otherwise.
|
341
421
|
def operation_info
|
342
|
-
|
422
|
+
option_named "google.longrunning.operation_info"
|
343
423
|
end
|
344
424
|
|
345
425
|
# @return [Boolean] True if this method is marked as deprecated, false
|
346
|
-
#
|
426
|
+
# otherwise.
|
347
427
|
def is_deprecated?
|
348
|
-
|
428
|
+
option_named("deprecated") == true
|
349
429
|
end
|
350
430
|
|
351
431
|
# @return [Google::Api::HttpRule] The HTTP bindings for this method. See
|
352
432
|
# `google/api/http.proto`.
|
353
433
|
def http
|
354
|
-
|
434
|
+
option_named "google.api.http"
|
435
|
+
end
|
436
|
+
|
437
|
+
# @return [Google::Api::RoutingRule] The Routing bindings for this method. See
|
438
|
+
# `google/api/routing.proto`.
|
439
|
+
def routing
|
440
|
+
option_named "google.api.routing"
|
441
|
+
end
|
442
|
+
|
443
|
+
# @return [String] The full name for this method
|
444
|
+
# (e.g. `google.example.Service.Rpc`).
|
445
|
+
# Useful when matching against other pieces of information
|
446
|
+
# which also reference full proto name.
|
447
|
+
def full_name
|
448
|
+
@address.join "."
|
449
|
+
end
|
450
|
+
|
451
|
+
# Nonstandard LRO annotation.
|
452
|
+
# @return [String] Name of the nonstandard LRO service
|
453
|
+
# that should be used for polling the operation object
|
454
|
+
# that this method returns
|
455
|
+
def operation_service
|
456
|
+
option_named "google.cloud.operation_service"
|
457
|
+
end
|
458
|
+
|
459
|
+
# Nonstandard LRO annotation.
|
460
|
+
# @return [Boolean] Whether this method is a polling method
|
461
|
+
# for a nonstandard LRO service
|
462
|
+
def polling_method
|
463
|
+
option_named "google.cloud.operation_polling_method"
|
355
464
|
end
|
356
465
|
|
357
466
|
# @!method name
|
@@ -441,7 +550,7 @@ module Gapic
|
|
441
550
|
|
442
551
|
# @return [String] Ruby Package
|
443
552
|
def ruby_package
|
444
|
-
|
553
|
+
option_named "ruby_package"
|
445
554
|
end
|
446
555
|
|
447
556
|
# @!method name
|
@@ -488,6 +597,12 @@ module Gapic
|
|
488
597
|
@values.each { |v| v.parent = self }
|
489
598
|
end
|
490
599
|
|
600
|
+
# @return [Boolean] True if this enum is marked as deprecated, false
|
601
|
+
# otherwise.
|
602
|
+
def is_deprecated?
|
603
|
+
option_named "deprecated"
|
604
|
+
end
|
605
|
+
|
491
606
|
# @!method name
|
492
607
|
# @return [String] the unqualified name of the Enum.
|
493
608
|
# @!method options
|
@@ -571,11 +686,36 @@ module Gapic
|
|
571
686
|
@resource.parent = self if @resource
|
572
687
|
end
|
573
688
|
|
689
|
+
OPTION_EXTENSION_NAMES = {
|
690
|
+
"google.api.resource" => [1053, ::Google::Api::ResourceDescriptor]
|
691
|
+
}.freeze
|
692
|
+
|
693
|
+
##
|
694
|
+
# Return a configuration of supported option extensions.
|
695
|
+
#
|
696
|
+
def option_extension_names
|
697
|
+
OPTION_EXTENSION_NAMES
|
698
|
+
end
|
699
|
+
|
574
700
|
# @return [Boolean] whether this type is a map entry
|
575
701
|
def map_entry?
|
576
702
|
descriptor.options&.map_entry
|
577
703
|
end
|
578
704
|
|
705
|
+
# @return [String] The full name for this message
|
706
|
+
# (e.g. `google.example.Message`).
|
707
|
+
# Useful when matching against other pieces of information
|
708
|
+
# which also reference full proto name.
|
709
|
+
def full_name
|
710
|
+
@address.join "."
|
711
|
+
end
|
712
|
+
|
713
|
+
# @return [Boolean] True if this message is marked as deprecated, false
|
714
|
+
# otherwise.
|
715
|
+
def is_deprecated?
|
716
|
+
option_named "deprecated"
|
717
|
+
end
|
718
|
+
|
579
719
|
# @!method name
|
580
720
|
# @return [String] the unqualified name of the message.
|
581
721
|
# @!method oneof_decl
|
@@ -621,6 +761,22 @@ module Gapic
|
|
621
761
|
super descriptor, address, docs
|
622
762
|
@message = message
|
623
763
|
@enum = enum
|
764
|
+
@oneof_siblings = nil
|
765
|
+
end
|
766
|
+
|
767
|
+
OPTION_EXTENSION_NAMES = {
|
768
|
+
"google.api.field_behavior" => [1052, :enum, :repeated],
|
769
|
+
"google.api.resource_reference" => [1055, ::Google::Api::ResourceReference],
|
770
|
+
"google.cloud.operation_field" => [1149, :enum],
|
771
|
+
"google.cloud.operation_request_field" => [1150, :string],
|
772
|
+
"google.cloud.operation_response_field" => [1151, :string]
|
773
|
+
}.freeze
|
774
|
+
|
775
|
+
##
|
776
|
+
# Return a configuration of supported option extensions.
|
777
|
+
#
|
778
|
+
def option_extension_names
|
779
|
+
OPTION_EXTENSION_NAMES
|
624
780
|
end
|
625
781
|
|
626
782
|
# Whether this field is a message.
|
@@ -634,7 +790,7 @@ module Gapic
|
|
634
790
|
# Whether this field is a repeated field.
|
635
791
|
# @return [Boolean]
|
636
792
|
def repeated?
|
637
|
-
label ==
|
793
|
+
label == :LABEL_REPEATED
|
638
794
|
end
|
639
795
|
|
640
796
|
# Whether this field is an enum.
|
@@ -670,23 +826,98 @@ module Gapic
|
|
670
826
|
# @return [String] A reference to another resource message or resource
|
671
827
|
# definition. See `google/api/resource.proto`.
|
672
828
|
def resource_reference
|
673
|
-
|
829
|
+
option_named "google.api.resource_reference"
|
674
830
|
end
|
675
831
|
|
676
832
|
# @return [Array<Google::Api::FieldBehavior>] A designation of a
|
677
833
|
# specific field behavior (required, output only, etc.) in protobuf
|
678
834
|
# messages.
|
679
835
|
def field_behavior
|
680
|
-
|
836
|
+
option_named("google.api.field_behavior") || []
|
837
|
+
end
|
838
|
+
|
839
|
+
# @return [String] The full name for this field
|
840
|
+
# (e.g. `google.example.Message.field`).
|
841
|
+
# Useful when matching against other pieces of information
|
842
|
+
# which also reference full proto name.
|
843
|
+
def full_name
|
844
|
+
@address.join "."
|
845
|
+
end
|
846
|
+
|
847
|
+
# Nonstandard LRO annotation.
|
848
|
+
# This annotation goes on the field of the request message of the method
|
849
|
+
# that intiates a non-standard LRO.
|
850
|
+
#
|
851
|
+
# This annotation contains a field name of the request message
|
852
|
+
# of the LRO polling method. (e.g. `GetRegionOperationRequest`)
|
853
|
+
# (let's call it a 'referenced field')
|
854
|
+
#
|
855
|
+
# When the this method is called, this value should be saved.
|
856
|
+
# Later, when when polling for a nonstandard LRO, this saved value should
|
857
|
+
# be copied to the referenced field.
|
858
|
+
#
|
859
|
+
# This typically would be used for something that a caller method knows,
|
860
|
+
# but an Operation object might not have, e.g. a 'region_id'.
|
861
|
+
#
|
862
|
+
# So if this field is `region_id` and the annotation is
|
863
|
+
# `(google.cloud.operation_request_field) = "region"`, then:
|
864
|
+
#
|
865
|
+
# `get_region_operation_request.region = this_message.region_id`
|
866
|
+
#
|
867
|
+
# In contrast to the `operation_response_field`, this field
|
868
|
+
# - goes onto the fields of the input message of the method that
|
869
|
+
# initiates the LRO
|
870
|
+
# - semantically annotates a 'push': the value of this field gets
|
871
|
+
# 'pushed' into every LRO poll request.
|
872
|
+
#
|
873
|
+
# @return [String]
|
874
|
+
def operation_request_field
|
875
|
+
option_named "google.cloud.operation_request_field"
|
876
|
+
end
|
877
|
+
|
878
|
+
# Nonstandard LRO annotation.
|
879
|
+
# This annotation goes on the field of the request message of the method
|
880
|
+
# that polls for a non-standard LRO.
|
881
|
+
#
|
882
|
+
# This annotation contains a field name of the LRO object (typically 'Operation')
|
883
|
+
# (let's call it a 'referenced field')
|
884
|
+
#
|
885
|
+
# When polling for a nonstandard LRO, the value of the field
|
886
|
+
# that this annotation is on should be copied from the referenced field.
|
887
|
+
#
|
888
|
+
# This typically would get used for something that is named differently in the
|
889
|
+
# operation polling request message vs in the Operation object, e.g. operation's name
|
890
|
+
#
|
891
|
+
# So if this field is `operation` and the annotation is
|
892
|
+
# `(google.cloud.operation_response_field) = "name"`, then:
|
893
|
+
#
|
894
|
+
# `get_region_operation_request.operation = operation.name`
|
895
|
+
#
|
896
|
+
# In contrast to the `operation_request_field`, this field
|
897
|
+
# - goes onto the fields of the LRO polling method's input message
|
898
|
+
# - semantically annotates a 'pull', the value of the referenced field gets
|
899
|
+
# 'pulled' into this one.
|
900
|
+
#
|
901
|
+
# @return [String]
|
902
|
+
def operation_response_field
|
903
|
+
option_named "google.cloud.operation_response_field"
|
904
|
+
end
|
681
905
|
|
682
|
-
|
906
|
+
# Nonstandard LRO annotation.
|
907
|
+
# This annotation goes on the fields of the nonstandard Operation message
|
908
|
+
# Is value can be either `NAME`, `STATUS`, `ERROR_MESSAGE`, or `ERROR_CODE`
|
909
|
+
# and the field encodes a corresponding aspect of the LRO behaviour.
|
910
|
+
#
|
911
|
+
# @return [Integer]
|
912
|
+
def operation_field
|
913
|
+
option_named "google.cloud.operation_field"
|
683
914
|
end
|
684
915
|
|
685
916
|
# Specifically denotes a field as optional. While all fields in protocol
|
686
917
|
# buffers are optional, this may be specified for emphasis if
|
687
918
|
# appropriate.
|
688
919
|
def optional?
|
689
|
-
field_behavior
|
920
|
+
field_behavior&.include? Google::Api::FieldBehavior::OPTIONAL
|
690
921
|
end
|
691
922
|
|
692
923
|
# Denotes a field as a part of oneof.
|
@@ -695,14 +926,14 @@ module Gapic
|
|
695
926
|
# but since the indexes in the message's oneof table start with 0 as well
|
696
927
|
# we need this to determine whether the field is a part of the oneof
|
697
928
|
def oneof?
|
698
|
-
@descriptor.
|
929
|
+
@descriptor.has_oneof_index?
|
699
930
|
end
|
700
931
|
|
701
932
|
# Denotes a field as required. This indicates that the field **must** be
|
702
933
|
# provided as part of the request, and failure to do so will cause an
|
703
934
|
# error (usually `INVALID_ARGUMENT`).
|
704
935
|
def required?
|
705
|
-
field_behavior
|
936
|
+
field_behavior&.include? Google::Api::FieldBehavior::REQUIRED
|
706
937
|
end
|
707
938
|
|
708
939
|
# Denotes a field as output only. This indicates that the field is
|
@@ -710,21 +941,56 @@ module Gapic
|
|
710
941
|
# nothing (the server *must* ignore it and *must not* throw an error as
|
711
942
|
# a result of the field's presence).
|
712
943
|
def output_only?
|
713
|
-
field_behavior
|
944
|
+
field_behavior&.include? Google::Api::FieldBehavior::OUTPUT_ONLY
|
714
945
|
end
|
715
946
|
|
716
947
|
# Denotes a field as input only. This indicates that the field is
|
717
948
|
# provided in requests, and the corresponding field is not included in
|
718
949
|
# output.
|
719
950
|
def input_only?
|
720
|
-
field_behavior
|
951
|
+
field_behavior&.include? Google::Api::FieldBehavior::INPUT_ONLY
|
721
952
|
end
|
722
953
|
|
723
954
|
# Denotes a field as immutable. This indicates that the field may be set
|
724
955
|
# once in a request to create a resource, but may not be changed
|
725
956
|
# thereafter.
|
726
957
|
def immutable?
|
727
|
-
field_behavior
|
958
|
+
field_behavior&.include? Google::Api::FieldBehavior::IMMUTABLE
|
959
|
+
end
|
960
|
+
|
961
|
+
# Denotes a field as proto3 optional
|
962
|
+
def proto3_optional?
|
963
|
+
@descriptor.proto3_optional
|
964
|
+
end
|
965
|
+
|
966
|
+
# @return [Boolean] True if this field is marked as deprecated, false
|
967
|
+
# otherwise.
|
968
|
+
def is_deprecated?
|
969
|
+
option_named "deprecated"
|
970
|
+
end
|
971
|
+
|
972
|
+
# @private
|
973
|
+
# Populate the oneof_siblings array. This is nil if this field is not part
|
974
|
+
# of a oneof, otherwise it's an array of fields that are members of the
|
975
|
+
# oneof, with the first element being the current field.
|
976
|
+
def populate_oneof_siblings! all_fields
|
977
|
+
return unless oneof?
|
978
|
+
@oneof_siblings = [self]
|
979
|
+
all_fields.each do |field|
|
980
|
+
@oneof_siblings << field if field != self && field.oneof? && field.oneof_index == oneof_index
|
981
|
+
end
|
982
|
+
end
|
983
|
+
|
984
|
+
# @private
|
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
|
988
|
+
return str unless @oneof_siblings && @oneof_siblings.size > 1
|
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."
|
993
|
+
str ? "#{str.strip}\n\n#{note}" : note
|
728
994
|
end
|
729
995
|
|
730
996
|
# @!method name
|
@@ -774,8 +1040,7 @@ module Gapic
|
|
774
1040
|
:default_value,
|
775
1041
|
:oneof_index,
|
776
1042
|
:json_name,
|
777
|
-
:options
|
778
|
-
:proto3_optional?
|
1043
|
+
:options
|
779
1044
|
)
|
780
1045
|
end
|
781
1046
|
|
@@ -868,3 +1133,22 @@ module Gapic
|
|
868
1133
|
end
|
869
1134
|
end
|
870
1135
|
end
|
1136
|
+
|
1137
|
+
module Google
|
1138
|
+
module Cloud
|
1139
|
+
module Tools
|
1140
|
+
module SnippetGen
|
1141
|
+
module ConfigLanguage
|
1142
|
+
module V1
|
1143
|
+
##
|
1144
|
+
# Additions to the SnippetConfig message
|
1145
|
+
#
|
1146
|
+
class SnippetConfig
|
1147
|
+
attr_accessor :json_representation
|
1148
|
+
end
|
1149
|
+
end
|
1150
|
+
end
|
1151
|
+
end
|
1152
|
+
end
|
1153
|
+
end
|
1154
|
+
end
|
@@ -14,15 +14,12 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
+
require "gapic/path_pattern"
|
18
|
+
|
17
19
|
module Gapic
|
18
20
|
module UriTemplate
|
19
21
|
# A URI template parser.
|
20
22
|
# see https://tools.ietf.org/html/rfc6570 URI Template
|
21
|
-
#
|
22
|
-
# @!attribute [r] path_pattern
|
23
|
-
# @return [String] The path pattern to be parsed.
|
24
|
-
# @!attribute [r] segments
|
25
|
-
# @return [Array<Segment|String>] The segments of the parsed path pattern.
|
26
23
|
module Parser
|
27
24
|
# @private
|
28
25
|
# `/(?<positional>\*\*?)|{(?<name>[^\/]+?)(?:=(?<template>.+?))?}/`
|
@@ -30,14 +27,25 @@ module Gapic
|
|
30
27
|
(?<positional>\*\*?)
|
31
28
|
|
|
32
29
|
{(?<name>[^/]+?)(?:=(?<template>.+?))?}
|
33
|
-
}x
|
30
|
+
}x
|
34
31
|
|
32
|
+
##
|
33
|
+
# Parses the arguments out of URI template
|
34
|
+
# with their corresponding patterns
|
35
|
+
#
|
36
|
+
# @param [String] The uri template to be parsed.
|
37
|
+
# @return [Array<Array<String>] The arguments and their corresponding patterns
|
38
|
+
#
|
35
39
|
def self.parse_arguments uri_template
|
36
40
|
arguments = []
|
37
41
|
|
38
42
|
while (match = URI_TEMPLATE.match uri_template)
|
39
43
|
# The String before the match needs to be added to the segments
|
40
|
-
|
44
|
+
if match[:name]
|
45
|
+
name = match[:name]
|
46
|
+
template = match[:template] || ""
|
47
|
+
arguments << [name, template]
|
48
|
+
end
|
41
49
|
uri_template = match.post_match
|
42
50
|
end
|
43
51
|
|