gapic-generator 0.10.1 → 0.11.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 +4 -4
- data/CHANGELOG.md +34 -0
- data/lib/gapic/generator/version.rb +1 -1
- data/lib/gapic/generators/default_generator.rb +2 -0
- data/lib/gapic/generators/default_generator_parameters.rb +3 -1
- data/lib/gapic/grpc_service_config/{service_config.rb → config.rb} +2 -2
- data/lib/gapic/grpc_service_config/parser.rb +8 -8
- data/lib/gapic/model/method/http_annotation.rb +123 -0
- data/lib/gapic/model/method/lro.rb +160 -0
- data/lib/gapic/model/method/routing.rb +263 -0
- data/lib/gapic/model/mixins.rb +181 -0
- data/lib/gapic/model/model_error.rb +26 -0
- data/lib/gapic/model/service/nonstandard_lro_provider.rb +293 -0
- data/lib/gapic/model.rb +22 -0
- data/lib/gapic/path_pattern/pattern.rb +46 -0
- data/lib/gapic/path_pattern/segment.rb +97 -9
- data/lib/gapic/presenters/gem_presenter.rb +34 -2
- data/lib/gapic/presenters/{service_config_presenter.rb → grpc_service_config_presenter.rb} +1 -1
- data/lib/gapic/presenters/method_presenter.rb +43 -3
- data/lib/gapic/presenters/method_rest_presenter.rb +33 -55
- data/lib/gapic/presenters/service/lro_client_presenter.rb +90 -0
- data/lib/gapic/presenters/service_presenter.rb +185 -3
- data/lib/gapic/presenters/service_rest_presenter.rb +81 -0
- data/lib/gapic/presenters/snippet_presenter.rb +1 -0
- data/lib/gapic/presenters.rb +3 -1
- data/lib/gapic/schema/api.rb +56 -2
- data/lib/gapic/schema/loader.rb +4 -1
- data/lib/gapic/schema/service_config_parser.rb +118 -0
- data/lib/gapic/schema/wrappers.rb +124 -1
- data/lib/google/api/auth.pb.rb +75 -0
- data/lib/google/api/backend.pb.rb +59 -0
- data/lib/google/api/billing.pb.rb +53 -0
- data/lib/google/api/context.pb.rb +47 -0
- data/lib/google/api/control.pb.rb +38 -0
- data/lib/google/api/documentation.pb.rb +56 -0
- data/lib/google/api/endpoint.pb.rb +42 -0
- data/lib/google/api/label.pb.rb +49 -0
- data/lib/google/api/launch_stage.pb.rb +37 -0
- data/lib/google/api/log.pb.rb +47 -0
- data/lib/google/api/logging.pb.rb +48 -0
- data/lib/google/api/metric.pb.rb +90 -0
- data/lib/google/api/monitored_resource.pb.rb +68 -0
- data/lib/google/api/monitoring.pb.rb +48 -0
- data/lib/google/api/quota.pb.rb +63 -0
- data/lib/google/api/routing.pb.rb +58 -0
- data/lib/google/api/service.pb.rb +90 -0
- data/lib/google/api/source_info.pb.rb +44 -0
- data/lib/google/api/system_parameter.pb.rb +51 -0
- data/lib/google/api/usage.pb.rb +47 -0
- data/lib/google/cloud/extended_operations.pb.rb +57 -0
- data/lib/google/protobuf/any.pb.rb +1 -1
- data/lib/google/protobuf/api.pb.rb +69 -0
- data/lib/google/protobuf/descriptor.pb.rb +1 -1
- data/lib/google/protobuf/duration.pb.rb +41 -0
- data/lib/google/protobuf/source_context.pb.rb +39 -0
- data/lib/google/protobuf/struct.pb.rb +65 -0
- data/lib/google/protobuf/type.pb.rb +128 -0
- data/lib/google/protobuf/wrappers.pb.rb +80 -0
- data/templates/default/gem/yardopts.erb +1 -1
- data/templates/default/lib/_package.erb +4 -0
- data/templates/default/lib/_service.erb +6 -0
- data/templates/default/service/client/_client.erb +20 -8
- data/templates/default/service/client/_nonstandard_lro.erb +57 -0
- data/templates/default/service/client/_self_configure_defaults.erb +2 -2
- data/templates/default/service/client/method/def/_options_defaults.erb +1 -8
- data/templates/default/service/client/method/def/_response.erb +2 -0
- data/templates/default/service/client/method/def/_response_nonstandard_lro.erb +23 -0
- data/templates/default/service/client/method/def/_routing_params.erb +36 -0
- data/templates/default/service/nonstandard_lro.erb +6 -0
- data/templates/default/service/rest/client/_client.erb +32 -5
- data/templates/default/service/rest/client/method/def/_response.erb +2 -2
- data/templates/default/service/rest/client/method/def/_response_nonstandard_lro.erb +23 -0
- data/templates/default/service/test/method/_assert_response.erb +3 -0
- metadata +61 -7
- data/templates/default/service/rest/client/method/def/_response_lro.erb +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a8baa3144f849b60f36cb51b7c7bed258165e9b3a646816aad586912001e4ddc
|
|
4
|
+
data.tar.gz: f1dc6fb877e18c0eed6c461bf6937d3756409da0bb259484149c377244953a70
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 90b475c396bcdd3ecdadec8fb27e3e8089e6c8525ad75d2f83142525684b898a38765ebde17d22262e2acaac56b8452e6d77b6a6f2ccc4fab4c21ad3997c9019
|
|
7
|
+
data.tar.gz: 84b4aab4d800b042c4be22f3159ca77fa1cc3489a903b79844d239202c56ffb0c02db39957afa7c0bee28b168547ff1e5afda93d373450f5f8a0e14feb969147
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Release History for gapic-generator
|
|
2
2
|
|
|
3
|
+
### 0.11.0 / 2022-03-01
|
|
4
|
+
|
|
5
|
+
* New: Added generation of nonstandard LRO wrapper calls (currently used for Compute)
|
|
6
|
+
* Fixed: Examples in the doc comments for modules are now generated with `@example` tags
|
|
7
|
+
* Fixed: proto files without a proto service can again be generated
|
|
8
|
+
* Ruby prebuilt binaries used in Bazel rules updated to Ruby 2.6.6
|
|
9
|
+
|
|
10
|
+
### 0.10.6 / 2022-02-02
|
|
11
|
+
|
|
12
|
+
* Point default documentation URL to rubydoc.info.
|
|
13
|
+
|
|
14
|
+
### 0.10.5 / 2022-01-20
|
|
15
|
+
|
|
16
|
+
* No significant changes
|
|
17
|
+
|
|
18
|
+
### 0.10.4 / 2022-01-07
|
|
19
|
+
|
|
20
|
+
* Fixed: Set quota_project_id correctly for LRO clients
|
|
21
|
+
* Fixed: Remove old cloud-rad configs and rake tasks
|
|
22
|
+
* Fixed: Properly quote page titles in YARD configs
|
|
23
|
+
|
|
24
|
+
### 0.10.3 / 2021-11-04
|
|
25
|
+
|
|
26
|
+
* New: Enabled snippet-gen by default
|
|
27
|
+
|
|
28
|
+
### 0.10.2 / 2021-11-01
|
|
29
|
+
|
|
30
|
+
* New: Added support for service.yaml
|
|
31
|
+
* New: New mixin implementation
|
|
32
|
+
* New: Parse and generate explicit routing headers
|
|
33
|
+
* New: Preliminary support for extended operations for REST LROs
|
|
34
|
+
* Fixed: Potential failures in generated tests when routing headers reference sub-fields
|
|
35
|
+
* Fixed: Renamed service_config to grpc_service_config
|
|
36
|
+
|
|
3
37
|
### 0.10.1 / 2021-08-27
|
|
4
38
|
|
|
5
39
|
* New: Compute REST libraries are now generated with LRO wrappers
|
|
@@ -59,6 +59,8 @@ module Gapic
|
|
|
59
59
|
files << g("service/credentials.erb", "lib/#{service.credentials_file_path}", service: service) unless gem.generic_endpoint?
|
|
60
60
|
files << g("service/paths.erb", "lib/#{service.paths_file_path}", service: service) if service.paths?
|
|
61
61
|
files << g("service/operations.erb", "lib/#{service.operations_file_path}", service: service) if service.lro? && !@api.generate_rest_clients?
|
|
62
|
+
files << g("service/nonstandard_lro.erb", "lib/#{service.nonstandard_lro_file_path}", service: service) if service.nonstandard_lro_provider? && !service.methods_rest_bindings?
|
|
63
|
+
files << g("service/nonstandard_lro.erb", "lib/#{service.rest.nonstandard_lro_file_path}", service: service) if service.nonstandard_lro_provider? && service.methods_rest_bindings?
|
|
62
64
|
files << g("service/rest/client.erb", "lib/#{service.rest.client_file_path}", service: service) if @api.generate_rest_clients? and service.methods_rest_bindings?
|
|
63
65
|
files << g("service/rest/service_stub.erb", "lib/#{service.rest.service_stub_file_path}", service: service) if @api.generate_rest_clients? and service.methods_rest_bindings?
|
|
64
66
|
files << g("service/rest/test/client.erb", "test/#{service.rest.test_client_file_path}", service: service) if @api.generate_rest_clients? and service.methods_rest_bindings?
|
|
@@ -46,6 +46,7 @@ module Gapic
|
|
|
46
46
|
":gem.:factory_method_suffix",
|
|
47
47
|
":defaults.:service.:default_host",
|
|
48
48
|
"grpc_service_config",
|
|
49
|
+
":service_yaml",
|
|
49
50
|
":overrides.:wrapper_gem_name"
|
|
50
51
|
].freeze
|
|
51
52
|
|
|
@@ -84,7 +85,8 @@ module Gapic
|
|
|
84
85
|
"gem-api-shortname" => ":gem.:api_shortname",
|
|
85
86
|
"gem-factory-method-suffix" => ":gem.:factory_method_suffix",
|
|
86
87
|
"default-service-host" => ":defaults.:service.:default_host",
|
|
87
|
-
"grpc-service-config" => "grpc_service_config"
|
|
88
|
+
"grpc-service-config" => "grpc_service_config",
|
|
89
|
+
"service-yaml" => ":service_yaml"
|
|
88
90
|
}.freeze
|
|
89
91
|
|
|
90
92
|
ARRAY_PARAMETERS_ALIASES = {
|
|
@@ -21,12 +21,12 @@ module Gapic
|
|
|
21
21
|
# applied on the service level (to all the methods) and the configurations
|
|
22
22
|
# applied to the specific methods
|
|
23
23
|
#
|
|
24
|
-
class
|
|
24
|
+
class Config
|
|
25
25
|
attr_reader :service_level_configs
|
|
26
26
|
attr_reader :service_method_level_configs
|
|
27
27
|
|
|
28
28
|
##
|
|
29
|
-
# Create new
|
|
29
|
+
# Create new GrpcServiceConfig.
|
|
30
30
|
#
|
|
31
31
|
# @param service_level_configs [Hash<String, Gapic::GrpcServiceConfig::MethodConfig>] service-level configs
|
|
32
32
|
# in a lookup hash by the service full grpc name
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
# See the License for the specific language governing permissions and
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
|
|
17
|
-
require "gapic/grpc_service_config/
|
|
17
|
+
require "gapic/grpc_service_config/config"
|
|
18
18
|
require "gapic/grpc_service_config/method_config"
|
|
19
19
|
require "gapic/grpc_service_config/retry_policy"
|
|
20
20
|
require "gapic/grpc_service_config/parsing_error"
|
|
@@ -67,18 +67,18 @@ module Gapic
|
|
|
67
67
|
end.freeze
|
|
68
68
|
|
|
69
69
|
##
|
|
70
|
-
# Parses
|
|
70
|
+
# Parses GRPC service configuration from a json
|
|
71
71
|
#
|
|
72
|
-
# @param
|
|
72
|
+
# @param config_json [Hash] a hash that results from JSON.parse
|
|
73
73
|
#
|
|
74
|
-
# @return [Gapic::GrpcServiceConfig::
|
|
74
|
+
# @return [Gapic::GrpcServiceConfig::Config] parsed GrpcServiceConfig
|
|
75
75
|
#
|
|
76
|
-
def self.parse
|
|
76
|
+
def self.parse config_json
|
|
77
77
|
service_level_result = {}
|
|
78
78
|
service_method_level_result = {}
|
|
79
79
|
|
|
80
|
-
if !
|
|
81
|
-
method_configs_json = get
|
|
80
|
+
if !config_json.nil? && key?(config_json, METHOD_CONFIG_JSON_KEY)
|
|
81
|
+
method_configs_json = get config_json, METHOD_CONFIG_JSON_KEY
|
|
82
82
|
|
|
83
83
|
method_configs_json.each do |method_config_json|
|
|
84
84
|
method_config = parse_config method_config_json
|
|
@@ -99,7 +99,7 @@ module Gapic
|
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
Config.new service_level_result, service_method_level_result
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
##
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2021 Google LLC
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
require "gapic/uri_template"
|
|
18
|
+
|
|
19
|
+
module Gapic
|
|
20
|
+
module Model
|
|
21
|
+
module Method
|
|
22
|
+
##
|
|
23
|
+
# The information used in the generation process that
|
|
24
|
+
# can be gathered from the `google.api.http` annotation.
|
|
25
|
+
# `google.api.http` is used in two distinct ways:
|
|
26
|
+
# - the rest libs use it as part of the transcoding to set up the REST call
|
|
27
|
+
# - both rest and grpc libs use it as a source of implicit routing headers
|
|
28
|
+
#
|
|
29
|
+
class HttpAnnotation
|
|
30
|
+
##
|
|
31
|
+
# @param proto_method [Gapic::Schema::Method]
|
|
32
|
+
#
|
|
33
|
+
def initialize proto_method
|
|
34
|
+
@proto_method = proto_method
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
##
|
|
38
|
+
# Whether a http verb is present for this method
|
|
39
|
+
#
|
|
40
|
+
# @return [Boolean]
|
|
41
|
+
def verb?
|
|
42
|
+
!verb.nil?
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# The http verb for this method
|
|
47
|
+
#
|
|
48
|
+
# @return [Symbol, Nil]
|
|
49
|
+
def verb
|
|
50
|
+
return nil if @proto_method.http.nil?
|
|
51
|
+
|
|
52
|
+
method = {
|
|
53
|
+
get: @proto_method.http.get,
|
|
54
|
+
post: @proto_method.http.post,
|
|
55
|
+
put: @proto_method.http.put,
|
|
56
|
+
patch: @proto_method.http.patch,
|
|
57
|
+
delete: @proto_method.http.delete
|
|
58
|
+
}.find { |_, value| !value.empty? }
|
|
59
|
+
|
|
60
|
+
method[0] unless method.nil?
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
##
|
|
64
|
+
# Whether a method path is present and non-empty
|
|
65
|
+
#
|
|
66
|
+
# @return [Boolean]
|
|
67
|
+
def path?
|
|
68
|
+
!path.empty?
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
##
|
|
72
|
+
# A method path or an empty string if not present
|
|
73
|
+
#
|
|
74
|
+
# @return [String]
|
|
75
|
+
def path
|
|
76
|
+
return "" if @proto_method.http.nil?
|
|
77
|
+
|
|
78
|
+
verb_path = [
|
|
79
|
+
@proto_method.http.get, @proto_method.http.post, @proto_method.http.put,
|
|
80
|
+
@proto_method.http.patch, @proto_method.http.delete
|
|
81
|
+
].find { |x| !x.empty? }
|
|
82
|
+
|
|
83
|
+
verb_path || @proto_method.http.custom&.path || ""
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
##
|
|
87
|
+
# Whether any routing params are present
|
|
88
|
+
#
|
|
89
|
+
# @return [Boolean]
|
|
90
|
+
def routing_params?
|
|
91
|
+
routing_params.any?
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
##
|
|
95
|
+
# The segment key names.
|
|
96
|
+
#
|
|
97
|
+
# @return [Array<String>]
|
|
98
|
+
def routing_params
|
|
99
|
+
Gapic::UriTemplate.parse_arguments path
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
##
|
|
103
|
+
# Whether method has body specified in proto
|
|
104
|
+
#
|
|
105
|
+
# @return [Boolean]
|
|
106
|
+
def body?
|
|
107
|
+
return false if @proto_method.http.nil?
|
|
108
|
+
|
|
109
|
+
!@proto_method.http.body.empty?
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
##
|
|
113
|
+
# The body specified for the given method in proto
|
|
114
|
+
# or an empty string if not specified
|
|
115
|
+
#
|
|
116
|
+
# @return [String]
|
|
117
|
+
def body
|
|
118
|
+
@proto_method.http&.body || ""
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2021 Google LLC
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
require "gapic/path_pattern"
|
|
18
|
+
|
|
19
|
+
module Gapic
|
|
20
|
+
module Model
|
|
21
|
+
##
|
|
22
|
+
# Method-level models
|
|
23
|
+
#
|
|
24
|
+
module Method
|
|
25
|
+
##
|
|
26
|
+
# Nonstandard (AIP-151 nonconforming) long-running operation method-level model
|
|
27
|
+
#
|
|
28
|
+
# @!attribute [r] service_full_name
|
|
29
|
+
# @return [String] Full grpc name of the provider service for this method's LRO
|
|
30
|
+
# e.g. `google.example.LroProvider`
|
|
31
|
+
#
|
|
32
|
+
# @!attribute [r] operation_request_fields
|
|
33
|
+
# @return [Map<String, String>] Map of the field names of this method's request message
|
|
34
|
+
# that should be saved and later used when constructing the LRO polling request.
|
|
35
|
+
# The values are the names of the fields in the polling request.
|
|
36
|
+
# The semantics are `from -> to`, e.g. `{"foo" => "bar"}` means that
|
|
37
|
+
# when constructing a polling request, the following assignment should be carried out:
|
|
38
|
+
# `lro_polling_request.bar = this_method_request.foo`.
|
|
39
|
+
#
|
|
40
|
+
class NonStandardLro
|
|
41
|
+
# @return [String]
|
|
42
|
+
attr_reader :service_full_name
|
|
43
|
+
# @return [Map<String, String>]
|
|
44
|
+
attr_reader :operation_request_fields
|
|
45
|
+
|
|
46
|
+
##
|
|
47
|
+
# @param method [Gapic::Schema::Method]
|
|
48
|
+
# @param service_full_name [String] Full grpc name of the provider service for this method's LRO
|
|
49
|
+
def initialize method, service_full_name
|
|
50
|
+
@service_full_name = service_full_name
|
|
51
|
+
|
|
52
|
+
# optionally, there might be things to copy from this method's input object
|
|
53
|
+
# to the LRO service's input object (`operation_request_field` annotation)
|
|
54
|
+
ops_request_fields = method.input.fields.find_all do |f|
|
|
55
|
+
!f.operation_request_field.nil? && !f.operation_request_field.empty?
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
@operation_request_fields = ops_request_fields.map do |field|
|
|
59
|
+
[field.name, field.operation_request_field]
|
|
60
|
+
end.to_h
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
##
|
|
64
|
+
# @return [Boolean] Whether this is a model for the nonstandard LRO
|
|
65
|
+
#
|
|
66
|
+
def nonstandard_lro?
|
|
67
|
+
true
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
##
|
|
71
|
+
# @return [Boolean] Whether this is a model for the AIP-151 LRO
|
|
72
|
+
#
|
|
73
|
+
def aip_lro?
|
|
74
|
+
false
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
##
|
|
79
|
+
# AIP-151 LRO Model
|
|
80
|
+
#
|
|
81
|
+
class AipLro
|
|
82
|
+
include Singleton
|
|
83
|
+
##
|
|
84
|
+
# @return [Boolean] Whether this is a model for the nonstandard LRO
|
|
85
|
+
#
|
|
86
|
+
def nonstandard_lro?
|
|
87
|
+
false
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
##
|
|
91
|
+
# @return [Boolean] Whether this is a model for the AIP-151 LRO
|
|
92
|
+
#
|
|
93
|
+
def aip_lro?
|
|
94
|
+
true
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
##
|
|
99
|
+
# Method does not represent a long-running operation
|
|
100
|
+
#
|
|
101
|
+
class NoLro
|
|
102
|
+
include Singleton
|
|
103
|
+
##
|
|
104
|
+
# @return [Boolean] Whether this is a model for the nonstandard LRO
|
|
105
|
+
#
|
|
106
|
+
def nonstandard_lro?
|
|
107
|
+
false
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
##
|
|
111
|
+
# @return [Boolean] Whether this is a model for the AIP-151 LRO
|
|
112
|
+
#
|
|
113
|
+
def aip_lro?
|
|
114
|
+
false
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
class << self
|
|
119
|
+
##
|
|
120
|
+
# Inspects the method and returns it's long-running operation model
|
|
121
|
+
#
|
|
122
|
+
# @param method [Gapic::Schema::Method]
|
|
123
|
+
# @param api [Gapic::Schema::Api]
|
|
124
|
+
#
|
|
125
|
+
# @raises [Gapic::Model::ModelError]
|
|
126
|
+
#
|
|
127
|
+
# @returns [Gapic::Model::Method::NonStandardLro, Gapic::Model::Method::AipLro, Gapic::Model::Method::NoLro]
|
|
128
|
+
#
|
|
129
|
+
def parse_lro method, api
|
|
130
|
+
is_aip_lro = method.output.full_name == "google.longrunning.Operation"
|
|
131
|
+
return AipLro.instance if is_aip_lro
|
|
132
|
+
|
|
133
|
+
# If a method is annotated with operation_service, this is a nonstandard LRO consumer method
|
|
134
|
+
is_nonstandard_lro = !method.operation_service.nil? && !method.operation_service.empty?
|
|
135
|
+
if is_nonstandard_lro
|
|
136
|
+
# LRO service name is given plain, so it has to be in the same package as this method's service
|
|
137
|
+
service_full_name = (method.address[0..-3] << method.operation_service).join "."
|
|
138
|
+
ops_service_lro = api.nonstandard_lro_model_for service_full_name
|
|
139
|
+
unless ops_service_lro.nonstandard_lro?
|
|
140
|
+
error_text = "A service #{service_full_name} specified as a nonstandard LRO service for " \
|
|
141
|
+
"the method #{method.full_name} was not found."
|
|
142
|
+
raise ModelError, error_text
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
unless method.output.full_name == ops_service_lro.lro_object_full_name
|
|
146
|
+
error_text = "A service #{service_full_name} specified as a nonstandard LRO service for " \
|
|
147
|
+
"the method #{method.full_name} has a different LRO object (#{ops_service_lro.lro_object_full_name}) " \
|
|
148
|
+
"from the method's return type (#{method.output.full_name})."
|
|
149
|
+
raise ModelError, error_text
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
return NonStandardLro.new method, service_full_name
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
NoLro.instance
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|