google-cloud-document_ai-v1beta3 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +203 -0
  5. data/README.md +75 -0
  6. data/lib/google-cloud-document_ai-v1beta3.rb +21 -0
  7. data/lib/google/cloud/document_ai/v1beta3.rb +35 -0
  8. data/lib/google/cloud/document_ai/v1beta3/document_processor_service.rb +53 -0
  9. data/lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb +570 -0
  10. data/lib/google/cloud/document_ai/v1beta3/document_processor_service/credentials.rb +51 -0
  11. data/lib/google/cloud/document_ai/v1beta3/document_processor_service/operations.rb +570 -0
  12. data/lib/google/cloud/document_ai/v1beta3/document_processor_service/paths.rb +71 -0
  13. data/lib/google/cloud/document_ai/v1beta3/version.rb +28 -0
  14. data/lib/google/cloud/documentai/v1beta3/document_pb.rb +303 -0
  15. data/lib/google/cloud/documentai/v1beta3/document_processor_service_pb.rb +106 -0
  16. data/lib/google/cloud/documentai/v1beta3/document_processor_service_services_pb.rb +54 -0
  17. data/lib/google/cloud/documentai/v1beta3/geometry_pb.rb +34 -0
  18. data/proto_docs/README.md +4 -0
  19. data/proto_docs/google/api/field_behavior.rb +59 -0
  20. data/proto_docs/google/api/resource.rb +283 -0
  21. data/proto_docs/google/cloud/documentai/v1beta3/document.rb +816 -0
  22. data/proto_docs/google/cloud/documentai/v1beta3/document_processor_service.rb +235 -0
  23. data/proto_docs/google/cloud/documentai/v1beta3/geometry.rb +65 -0
  24. data/proto_docs/google/longrunning/operations.rb +150 -0
  25. data/proto_docs/google/protobuf/any.rb +138 -0
  26. data/proto_docs/google/protobuf/duration.rb +98 -0
  27. data/proto_docs/google/protobuf/empty.rb +36 -0
  28. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  29. data/proto_docs/google/protobuf/timestamp.rb +120 -0
  30. data/proto_docs/google/protobuf/wrappers.rb +121 -0
  31. data/proto_docs/google/rpc/status.rb +46 -0
  32. data/proto_docs/google/type/color.rb +168 -0
  33. data/proto_docs/google/type/date.rb +50 -0
  34. data/proto_docs/google/type/datetime.rb +91 -0
  35. data/proto_docs/google/type/money.rb +43 -0
  36. data/proto_docs/google/type/postal_address.rb +135 -0
  37. metadata +219 -0
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ # This gem does not autoload during Bundler.require. To load this gem,
20
+ # issue explicit require statements for the packages desired, e.g.:
21
+ # require "google/cloud/document_ai/v1beta3"
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/document_ai/v1beta3/document_processor_service"
20
+ require "google/cloud/document_ai/v1beta3/version"
21
+
22
+ module Google
23
+ module Cloud
24
+ module DocumentAI
25
+ ##
26
+ # To load this package, including all its services, and instantiate a client:
27
+ #
28
+ # require "google/cloud/document_ai/v1beta3"
29
+ # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new
30
+ #
31
+ module V1beta3
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/document_ai/v1beta3/version"
24
+
25
+ require "google/cloud/document_ai/v1beta3/document_processor_service/credentials"
26
+ require "google/cloud/document_ai/v1beta3/document_processor_service/paths"
27
+ require "google/cloud/document_ai/v1beta3/document_processor_service/operations"
28
+ require "google/cloud/document_ai/v1beta3/document_processor_service/client"
29
+
30
+ module Google
31
+ module Cloud
32
+ module DocumentAI
33
+ module V1beta3
34
+ ##
35
+ # Service to call Cloud DocumentAI to process documents according to the
36
+ # processor's definition. Processors are built using state-of-the-art Google
37
+ # AI such as natural language, computer vision, and translation to extract
38
+ # structured information from unstructured or semi-structured documents.
39
+ #
40
+ # To load this service and instantiate a client:
41
+ #
42
+ # require "google/cloud/document_ai/v1beta3/document_processor_service"
43
+ # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new
44
+ #
45
+ module DocumentProcessorService
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ helper_path = ::File.join __dir__, "document_processor_service", "helpers.rb"
53
+ require "google/cloud/document_ai/v1beta3/document_processor_service/helpers" if ::File.file? helper_path
@@ -0,0 +1,570 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/documentai/v1beta3/document_processor_service_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module DocumentAI
25
+ module V1beta3
26
+ module DocumentProcessorService
27
+ ##
28
+ # Client for the DocumentProcessorService service.
29
+ #
30
+ # Service to call Cloud DocumentAI to process documents according to the
31
+ # processor's definition. Processors are built using state-of-the-art Google
32
+ # AI such as natural language, computer vision, and translation to extract
33
+ # structured information from unstructured or semi-structured documents.
34
+ #
35
+ class Client
36
+ include Paths
37
+
38
+ # @private
39
+ attr_reader :document_processor_service_stub
40
+
41
+ ##
42
+ # Configure the DocumentProcessorService Client class.
43
+ #
44
+ # See {::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # ## Example
48
+ #
49
+ # To modify the configuration for all DocumentProcessorService clients:
50
+ #
51
+ # ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.configure do |config|
52
+ # config.timeout = 10.0
53
+ # end
54
+ #
55
+ # @yield [config] Configure the Client client.
56
+ # @yieldparam config [Client::Configuration]
57
+ #
58
+ # @return [Client::Configuration]
59
+ #
60
+ def self.configure
61
+ @configure ||= begin
62
+ namespace = ["Google", "Cloud", "DocumentAI", "V1beta3"]
63
+ parent_config = while namespace.any?
64
+ parent_name = namespace.join "::"
65
+ parent_const = const_get parent_name
66
+ break parent_const.configure if parent_const&.respond_to? :configure
67
+ namespace.pop
68
+ end
69
+ default_config = Client::Configuration.new parent_config
70
+
71
+ default_config.rpcs.process_document.timeout = 120.0
72
+ default_config.rpcs.process_document.retry_policy = {
73
+ initial_delay: 0.1,
74
+ max_delay: 60.0,
75
+ multiplier: 1.3,
76
+ retry_codes: [4, 14]
77
+ }
78
+
79
+ default_config.rpcs.batch_process_documents.timeout = 120.0
80
+ default_config.rpcs.batch_process_documents.retry_policy = {
81
+ initial_delay: 0.1,
82
+ max_delay: 60.0,
83
+ multiplier: 1.3,
84
+ retry_codes: [4, 14]
85
+ }
86
+
87
+ default_config.rpcs.review_document.timeout = 120.0
88
+ default_config.rpcs.review_document.retry_policy = {
89
+ initial_delay: 0.1,
90
+ max_delay: 60.0,
91
+ multiplier: 1.3,
92
+ retry_codes: [4, 14]
93
+ }
94
+
95
+ default_config
96
+ end
97
+ yield @configure if block_given?
98
+ @configure
99
+ end
100
+
101
+ ##
102
+ # Configure the DocumentProcessorService Client instance.
103
+ #
104
+ # The configuration is set to the derived mode, meaning that values can be changed,
105
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
106
+ # should be made on {Client.configure}.
107
+ #
108
+ # See {::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client::Configuration}
109
+ # for a description of the configuration fields.
110
+ #
111
+ # @yield [config] Configure the Client client.
112
+ # @yieldparam config [Client::Configuration]
113
+ #
114
+ # @return [Client::Configuration]
115
+ #
116
+ def configure
117
+ yield @config if block_given?
118
+ @config
119
+ end
120
+
121
+ ##
122
+ # Create a new DocumentProcessorService client object.
123
+ #
124
+ # ## Examples
125
+ #
126
+ # To create a new DocumentProcessorService client with the default
127
+ # configuration:
128
+ #
129
+ # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new
130
+ #
131
+ # To create a new DocumentProcessorService client with a custom
132
+ # configuration:
133
+ #
134
+ # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new do |config|
135
+ # config.timeout = 10.0
136
+ # end
137
+ #
138
+ # @yield [config] Configure the DocumentProcessorService client.
139
+ # @yieldparam config [Client::Configuration]
140
+ #
141
+ def initialize
142
+ # These require statements are intentionally placed here to initialize
143
+ # the gRPC module only when it's required.
144
+ # See https://github.com/googleapis/toolkit/issues/446
145
+ require "gapic/grpc"
146
+ require "google/cloud/documentai/v1beta3/document_processor_service_services_pb"
147
+
148
+ # Create the configuration object
149
+ @config = Configuration.new Client.configure
150
+
151
+ # Yield the configuration if needed
152
+ yield @config if block_given?
153
+
154
+ # Create credentials
155
+ credentials = @config.credentials
156
+ credentials ||= Credentials.default scope: @config.scope
157
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
158
+ credentials = Credentials.new credentials, scope: @config.scope
159
+ end
160
+ @quota_project_id = @config.quota_project
161
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
162
+
163
+ @operations_client = Operations.new do |config|
164
+ config.credentials = credentials
165
+ config.endpoint = @config.endpoint
166
+ end
167
+
168
+ @document_processor_service_stub = ::Gapic::ServiceStub.new(
169
+ ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Stub,
170
+ credentials: credentials,
171
+ endpoint: @config.endpoint,
172
+ channel_args: @config.channel_args,
173
+ interceptors: @config.interceptors
174
+ )
175
+ end
176
+
177
+ ##
178
+ # Get the associated client for long-running operations.
179
+ #
180
+ # @return [::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Operations]
181
+ #
182
+ attr_reader :operations_client
183
+
184
+ # Service calls
185
+
186
+ ##
187
+ # Processes a single document.
188
+ #
189
+ # @overload process_document(request, options = nil)
190
+ # Pass arguments to `process_document` via a request object, either of type
191
+ # {::Google::Cloud::DocumentAI::V1beta3::ProcessRequest} or an equivalent Hash.
192
+ #
193
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::ProcessRequest, ::Hash]
194
+ # A request object representing the call parameters. Required. To specify no
195
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
196
+ # @param options [::Gapic::CallOptions, ::Hash]
197
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
198
+ #
199
+ # @overload process_document(name: nil, document: nil, skip_human_review: nil)
200
+ # Pass arguments to `process_document` via keyword arguments. Note that at
201
+ # least one keyword argument is required. To specify no parameters, or to keep all
202
+ # the default parameter values, pass an empty Hash as a request object (see above).
203
+ #
204
+ # @param name [::String]
205
+ # Required. The processor resource name.
206
+ # @param document [::Google::Cloud::DocumentAI::V1beta3::Document, ::Hash]
207
+ # The document payload, the [content] and [mime_type] fields must be set.
208
+ # @param skip_human_review [::Boolean]
209
+ # Whether Human Review feature should be skipped for this request. Default to
210
+ # false.
211
+ #
212
+ # @yield [response, operation] Access the result along with the RPC operation
213
+ # @yieldparam response [::Google::Cloud::DocumentAI::V1beta3::ProcessResponse]
214
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
215
+ #
216
+ # @return [::Google::Cloud::DocumentAI::V1beta3::ProcessResponse]
217
+ #
218
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
219
+ #
220
+ def process_document request, options = nil
221
+ raise ::ArgumentError, "request must be provided" if request.nil?
222
+
223
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::ProcessRequest
224
+
225
+ # Converts hash and nil to an options object
226
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
227
+
228
+ # Customize the options with defaults
229
+ metadata = @config.rpcs.process_document.metadata.to_h
230
+
231
+ # Set x-goog-api-client and x-goog-user-project headers
232
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
233
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
234
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
235
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
236
+
237
+ header_params = {
238
+ "name" => request.name
239
+ }
240
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
241
+ metadata[:"x-goog-request-params"] ||= request_params_header
242
+
243
+ options.apply_defaults timeout: @config.rpcs.process_document.timeout,
244
+ metadata: metadata,
245
+ retry_policy: @config.rpcs.process_document.retry_policy
246
+ options.apply_defaults metadata: @config.metadata,
247
+ retry_policy: @config.retry_policy
248
+
249
+ @document_processor_service_stub.call_rpc :process_document, request, options: options do |response, operation|
250
+ yield response, operation if block_given?
251
+ return response
252
+ end
253
+ rescue ::GRPC::BadStatus => e
254
+ raise ::Google::Cloud::Error.from_error(e)
255
+ end
256
+
257
+ ##
258
+ # LRO endpoint to batch process many documents. The output is written
259
+ # to Cloud Storage as JSON in the [Document] format.
260
+ #
261
+ # @overload batch_process_documents(request, options = nil)
262
+ # Pass arguments to `batch_process_documents` via a request object, either of type
263
+ # {::Google::Cloud::DocumentAI::V1beta3::BatchProcessRequest} or an equivalent Hash.
264
+ #
265
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::BatchProcessRequest, ::Hash]
266
+ # A request object representing the call parameters. Required. To specify no
267
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
268
+ # @param options [::Gapic::CallOptions, ::Hash]
269
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
270
+ #
271
+ # @overload batch_process_documents(name: nil, input_configs: nil, output_config: nil)
272
+ # Pass arguments to `batch_process_documents` via keyword arguments. Note that at
273
+ # least one keyword argument is required. To specify no parameters, or to keep all
274
+ # the default parameter values, pass an empty Hash as a request object (see above).
275
+ #
276
+ # @param name [::String]
277
+ # Required. The processor resource name.
278
+ # @param input_configs [::Array<::Google::Cloud::DocumentAI::V1beta3::BatchProcessRequest::BatchInputConfig, ::Hash>]
279
+ # The input config for each single document in the batch process.
280
+ # @param output_config [::Google::Cloud::DocumentAI::V1beta3::BatchProcessRequest::BatchOutputConfig, ::Hash]
281
+ # The overall output config for batch process.
282
+ #
283
+ # @yield [response, operation] Access the result along with the RPC operation
284
+ # @yieldparam response [::Gapic::Operation]
285
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
286
+ #
287
+ # @return [::Gapic::Operation]
288
+ #
289
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
290
+ #
291
+ def batch_process_documents request, options = nil
292
+ raise ::ArgumentError, "request must be provided" if request.nil?
293
+
294
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::BatchProcessRequest
295
+
296
+ # Converts hash and nil to an options object
297
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
298
+
299
+ # Customize the options with defaults
300
+ metadata = @config.rpcs.batch_process_documents.metadata.to_h
301
+
302
+ # Set x-goog-api-client and x-goog-user-project headers
303
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
304
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
305
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
306
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
307
+
308
+ header_params = {
309
+ "name" => request.name
310
+ }
311
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
312
+ metadata[:"x-goog-request-params"] ||= request_params_header
313
+
314
+ options.apply_defaults timeout: @config.rpcs.batch_process_documents.timeout,
315
+ metadata: metadata,
316
+ retry_policy: @config.rpcs.batch_process_documents.retry_policy
317
+ options.apply_defaults metadata: @config.metadata,
318
+ retry_policy: @config.retry_policy
319
+
320
+ @document_processor_service_stub.call_rpc :batch_process_documents, request, options: options do |response, operation|
321
+ response = ::Gapic::Operation.new response, @operations_client, options: options
322
+ yield response, operation if block_given?
323
+ return response
324
+ end
325
+ rescue ::GRPC::BadStatus => e
326
+ raise ::Google::Cloud::Error.from_error(e)
327
+ end
328
+
329
+ ##
330
+ # Send a document for Human Review. The input document should be processed by
331
+ # the specified processor.
332
+ #
333
+ # @overload review_document(request, options = nil)
334
+ # Pass arguments to `review_document` via a request object, either of type
335
+ # {::Google::Cloud::DocumentAI::V1beta3::ReviewDocumentRequest} or an equivalent Hash.
336
+ #
337
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::ReviewDocumentRequest, ::Hash]
338
+ # A request object representing the call parameters. Required. To specify no
339
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
340
+ # @param options [::Gapic::CallOptions, ::Hash]
341
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
342
+ #
343
+ # @overload review_document(human_review_config: nil, document: nil)
344
+ # Pass arguments to `review_document` via keyword arguments. Note that at
345
+ # least one keyword argument is required. To specify no parameters, or to keep all
346
+ # the default parameter values, pass an empty Hash as a request object (see above).
347
+ #
348
+ # @param human_review_config [::String]
349
+ # Required. The resource name of the HumanReviewConfig that the document will be
350
+ # reviewed with.
351
+ # @param document [::Google::Cloud::DocumentAI::V1beta3::Document, ::Hash]
352
+ # The document that needs human review.
353
+ #
354
+ # @yield [response, operation] Access the result along with the RPC operation
355
+ # @yieldparam response [::Gapic::Operation]
356
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
357
+ #
358
+ # @return [::Gapic::Operation]
359
+ #
360
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
361
+ #
362
+ def review_document request, options = nil
363
+ raise ::ArgumentError, "request must be provided" if request.nil?
364
+
365
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::ReviewDocumentRequest
366
+
367
+ # Converts hash and nil to an options object
368
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
369
+
370
+ # Customize the options with defaults
371
+ metadata = @config.rpcs.review_document.metadata.to_h
372
+
373
+ # Set x-goog-api-client and x-goog-user-project headers
374
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
375
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
376
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
377
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
378
+
379
+ header_params = {
380
+ "human_review_config" => request.human_review_config
381
+ }
382
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
383
+ metadata[:"x-goog-request-params"] ||= request_params_header
384
+
385
+ options.apply_defaults timeout: @config.rpcs.review_document.timeout,
386
+ metadata: metadata,
387
+ retry_policy: @config.rpcs.review_document.retry_policy
388
+ options.apply_defaults metadata: @config.metadata,
389
+ retry_policy: @config.retry_policy
390
+
391
+ @document_processor_service_stub.call_rpc :review_document, request, options: options do |response, operation|
392
+ response = ::Gapic::Operation.new response, @operations_client, options: options
393
+ yield response, operation if block_given?
394
+ return response
395
+ end
396
+ rescue ::GRPC::BadStatus => e
397
+ raise ::Google::Cloud::Error.from_error(e)
398
+ end
399
+
400
+ ##
401
+ # Configuration class for the DocumentProcessorService API.
402
+ #
403
+ # This class represents the configuration for DocumentProcessorService,
404
+ # providing control over timeouts, retry behavior, logging, transport
405
+ # parameters, and other low-level controls. Certain parameters can also be
406
+ # applied individually to specific RPCs. See
407
+ # {::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client::Configuration::Rpcs}
408
+ # for a list of RPCs that can be configured independently.
409
+ #
410
+ # Configuration can be applied globally to all clients, or to a single client
411
+ # on construction.
412
+ #
413
+ # # Examples
414
+ #
415
+ # To modify the global config, setting the timeout for process_document
416
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
417
+ #
418
+ # ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.configure do |config|
419
+ # config.timeout = 10.0
420
+ # config.rpcs.process_document.timeout = 20.0
421
+ # end
422
+ #
423
+ # To apply the above configuration only to a new client:
424
+ #
425
+ # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new do |config|
426
+ # config.timeout = 10.0
427
+ # config.rpcs.process_document.timeout = 20.0
428
+ # end
429
+ #
430
+ # @!attribute [rw] endpoint
431
+ # The hostname or hostname:port of the service endpoint.
432
+ # Defaults to `"us-documentai.googleapis.com"`.
433
+ # @return [::String]
434
+ # @!attribute [rw] credentials
435
+ # Credentials to send with calls. You may provide any of the following types:
436
+ # * (`String`) The path to a service account key file in JSON format
437
+ # * (`Hash`) A service account key as a Hash
438
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
439
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
440
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
441
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
442
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
443
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
444
+ # * (`nil`) indicating no credentials
445
+ # @return [::Object]
446
+ # @!attribute [rw] scope
447
+ # The OAuth scopes
448
+ # @return [::Array<::String>]
449
+ # @!attribute [rw] lib_name
450
+ # The library name as recorded in instrumentation and logging
451
+ # @return [::String]
452
+ # @!attribute [rw] lib_version
453
+ # The library version as recorded in instrumentation and logging
454
+ # @return [::String]
455
+ # @!attribute [rw] channel_args
456
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
457
+ # `GRPC::Core::Channel` object is provided as the credential.
458
+ # @return [::Hash]
459
+ # @!attribute [rw] interceptors
460
+ # An array of interceptors that are run before calls are executed.
461
+ # @return [::Array<::GRPC::ClientInterceptor>]
462
+ # @!attribute [rw] timeout
463
+ # The call timeout in seconds.
464
+ # @return [::Numeric]
465
+ # @!attribute [rw] metadata
466
+ # Additional gRPC headers to be sent with the call.
467
+ # @return [::Hash{::Symbol=>::String}]
468
+ # @!attribute [rw] retry_policy
469
+ # The retry policy. The value is a hash with the following keys:
470
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
471
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
472
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
473
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
474
+ # trigger a retry.
475
+ # @return [::Hash]
476
+ # @!attribute [rw] quota_project
477
+ # A separate project against which to charge quota.
478
+ # @return [::String]
479
+ #
480
+ class Configuration
481
+ extend ::Gapic::Config
482
+
483
+ config_attr :endpoint, "us-documentai.googleapis.com", ::String
484
+ config_attr :credentials, nil do |value|
485
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
486
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
487
+ allowed.any? { |klass| klass === value }
488
+ end
489
+ config_attr :scope, nil, ::String, ::Array, nil
490
+ config_attr :lib_name, nil, ::String, nil
491
+ config_attr :lib_version, nil, ::String, nil
492
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
493
+ config_attr :interceptors, nil, ::Array, nil
494
+ config_attr :timeout, nil, ::Numeric, nil
495
+ config_attr :metadata, nil, ::Hash, nil
496
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
497
+ config_attr :quota_project, nil, ::String, nil
498
+
499
+ # @private
500
+ def initialize parent_config = nil
501
+ @parent_config = parent_config unless parent_config.nil?
502
+
503
+ yield self if block_given?
504
+ end
505
+
506
+ ##
507
+ # Configurations for individual RPCs
508
+ # @return [Rpcs]
509
+ #
510
+ def rpcs
511
+ @rpcs ||= begin
512
+ parent_rpcs = nil
513
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
514
+ Rpcs.new parent_rpcs
515
+ end
516
+ end
517
+
518
+ ##
519
+ # Configuration RPC class for the DocumentProcessorService API.
520
+ #
521
+ # Includes fields providing the configuration for each RPC in this service.
522
+ # Each configuration object is of type `Gapic::Config::Method` and includes
523
+ # the following configuration fields:
524
+ #
525
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
526
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
527
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
528
+ # include the following keys:
529
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
530
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
531
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
532
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
533
+ # trigger a retry.
534
+ #
535
+ class Rpcs
536
+ ##
537
+ # RPC-specific configuration for `process_document`
538
+ # @return [::Gapic::Config::Method]
539
+ #
540
+ attr_reader :process_document
541
+ ##
542
+ # RPC-specific configuration for `batch_process_documents`
543
+ # @return [::Gapic::Config::Method]
544
+ #
545
+ attr_reader :batch_process_documents
546
+ ##
547
+ # RPC-specific configuration for `review_document`
548
+ # @return [::Gapic::Config::Method]
549
+ #
550
+ attr_reader :review_document
551
+
552
+ # @private
553
+ def initialize parent_rpcs = nil
554
+ process_document_config = parent_rpcs&.process_document if parent_rpcs&.respond_to? :process_document
555
+ @process_document = ::Gapic::Config::Method.new process_document_config
556
+ batch_process_documents_config = parent_rpcs&.batch_process_documents if parent_rpcs&.respond_to? :batch_process_documents
557
+ @batch_process_documents = ::Gapic::Config::Method.new batch_process_documents_config
558
+ review_document_config = parent_rpcs&.review_document if parent_rpcs&.respond_to? :review_document
559
+ @review_document = ::Gapic::Config::Method.new review_document_config
560
+
561
+ yield self if block_given?
562
+ end
563
+ end
564
+ end
565
+ end
566
+ end
567
+ end
568
+ end
569
+ end
570
+ end