Class: Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client
- Inherits:
-
Object
- Object
- Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client
- Includes:
- Paths
- Defined in:
- lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb
Overview
Client for the DocumentProcessorService service.
Service to call Cloud DocumentAI to process documents according to the processor's definition. Processors are built using state-of-the-art Google AI such as natural language, computer vision, and translation to extract structured information from unstructured or semi-structured documents.
Defined Under Namespace
Classes: Configuration
Instance Attribute Summary collapse
-
#operations_client ⇒ ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Operations
readonly
Get the associated client for long-running operations.
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Client::Configuration
Configure the DocumentProcessorService Client class.
Instance Method Summary collapse
-
#batch_process_documents(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::Operation
LRO endpoint to batch process many documents.
-
#configure {|config| ... } ⇒ Client::Configuration
Configure the DocumentProcessorService Client instance.
-
#create_processor(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::DocumentAI::V1beta3::Processor
Creates a processor from the type processor that the user chose.
-
#delete_processor(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::Operation
Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.
-
#disable_processor(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::Operation
Disables a processor.
-
#enable_processor(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::Operation
Enables a processor.
-
#fetch_processor_types(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse
Fetches processor types.
-
#initialize {|config| ... } ⇒ Client
constructor
Create a new DocumentProcessorService client object.
-
#list_processors(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::Processor>
Lists all processors which belong to this project.
-
#process_document(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::DocumentAI::V1beta3::ProcessResponse
Processes a single document.
-
#review_document(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::Operation
Send a document for Human Review.
Methods included from Paths
#human_review_config_path, #location_path, #processor_path
Constructor Details
#initialize {|config| ... } ⇒ Client
Create a new DocumentProcessorService client object.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb', line 127 def initialize # These require statements are intentionally placed here to initialize # the gRPC module only when it's required. # See https://github.com/googleapis/toolkit/issues/446 require "gapic/grpc" require "google/cloud/documentai/v1beta3/document_processor_service_services_pb" # Create the configuration object @config = Configuration.new Client.configure # Yield the configuration if needed yield @config if block_given? # Create credentials credentials = @config.credentials # Use self-signed JWT if the endpoint is unchanged from default, # but only if the default endpoint does not have a region prefix. enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint && !@config.endpoint.split(".").first.include?("-") credentials ||= Credentials.default scope: @config.scope, enable_self_signed_jwt: enable_self_signed_jwt if credentials.is_a?(::String) || credentials.is_a?(::Hash) credentials = Credentials.new credentials, scope: @config.scope end @quota_project_id = @config.quota_project @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id @operations_client = Operations.new do |config| config.credentials = credentials config.quota_project = @quota_project_id config.endpoint = @config.endpoint end @document_processor_service_stub = ::Gapic::ServiceStub.new( ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Stub, credentials: credentials, endpoint: @config.endpoint, channel_args: @config.channel_args, interceptors: @config.interceptors ) end |
Instance Attribute Details
#operations_client ⇒ ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Operations (readonly)
Get the associated client for long-running operations.
174 175 176 |
# File 'lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb', line 174 def operations_client @operations_client end |
Class Method Details
.configure {|config| ... } ⇒ Client::Configuration
Configure the DocumentProcessorService Client class.
See Configuration for a description of the configuration fields.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb', line 59 def self.configure @configure ||= begin namespace = ["Google", "Cloud", "DocumentAI", "V1beta3"] parent_config = while namespace.any? parent_name = namespace.join "::" parent_const = const_get parent_name break parent_const.configure if parent_const.respond_to? :configure namespace.pop end default_config = Client::Configuration.new parent_config default_config.rpcs.process_document.timeout = 120.0 default_config.rpcs.process_document.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14] } default_config.rpcs.batch_process_documents.timeout = 120.0 default_config.rpcs.batch_process_documents.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14] } default_config.rpcs.review_document.timeout = 120.0 default_config.rpcs.review_document.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14] } default_config end yield @configure if block_given? @configure end |
Instance Method Details
#batch_process_documents(request, options = nil) ⇒ ::Gapic::Operation #batch_process_documents(name: nil, input_configs: nil, output_config: nil, input_documents: nil, document_output_config: nil, skip_human_review: nil) ⇒ ::Gapic::Operation
LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb', line 335 def batch_process_documents request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::BatchProcessRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.batch_process_documents..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.name header_params["name"] = request.name end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.batch_process_documents.timeout, metadata: , retry_policy: @config.rpcs.batch_process_documents.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @document_processor_service_stub.call_rpc :batch_process_documents, request, options: do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#configure {|config| ... } ⇒ Client::Configuration
Configure the DocumentProcessorService Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.
See Configuration for a description of the configuration fields.
106 107 108 109 |
# File 'lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb', line 106 def configure yield @config if block_given? @config end |
#create_processor(request, options = nil) ⇒ ::Google::Cloud::DocumentAI::V1beta3::Processor #create_processor(parent: nil, processor: nil) ⇒ ::Google::Cloud::DocumentAI::V1beta3::Processor
Creates a processor from the type processor that the user chose. The processor will be at "ENABLED" state by default after its creation.
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 |
# File 'lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb', line 612 def create_processor request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::CreateProcessorRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.create_processor..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.parent header_params["parent"] = request.parent end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.create_processor.timeout, metadata: , retry_policy: @config.rpcs.create_processor.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @document_processor_service_stub.call_rpc :create_processor, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#delete_processor(request, options = nil) ⇒ ::Gapic::Operation #delete_processor(name: nil) ⇒ ::Gapic::Operation
Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
# File 'lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb', line 705 def delete_processor request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::DeleteProcessorRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.delete_processor..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.name header_params["name"] = request.name end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.delete_processor.timeout, metadata: , retry_policy: @config.rpcs.delete_processor.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @document_processor_service_stub.call_rpc :delete_processor, request, options: do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#disable_processor(request, options = nil) ⇒ ::Gapic::Operation #disable_processor(name: nil) ⇒ ::Gapic::Operation
Disables a processor
891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 |
# File 'lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb', line 891 def disable_processor request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::DisableProcessorRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.disable_processor..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.name header_params["name"] = request.name end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.disable_processor.timeout, metadata: , retry_policy: @config.rpcs.disable_processor.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @document_processor_service_stub.call_rpc :disable_processor, request, options: do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#enable_processor(request, options = nil) ⇒ ::Gapic::Operation #enable_processor(name: nil) ⇒ ::Gapic::Operation
Enables a processor
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 |
# File 'lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb', line 798 def enable_processor request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::EnableProcessorRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.enable_processor..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.name header_params["name"] = request.name end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.enable_processor.timeout, metadata: , retry_policy: @config.rpcs.enable_processor.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @document_processor_service_stub.call_rpc :enable_processor, request, options: do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#fetch_processor_types(request, options = nil) ⇒ ::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse #fetch_processor_types(parent: nil) ⇒ ::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse
Fetches processor types.
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
# File 'lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb', line 422 def fetch_processor_types request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.fetch_processor_types..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.parent header_params["parent"] = request.parent end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.fetch_processor_types.timeout, metadata: , retry_policy: @config.rpcs.fetch_processor_types.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @document_processor_service_stub.call_rpc :fetch_processor_types, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#list_processors(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::Processor> #list_processors(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::Processor>
Lists all processors which belong to this project.
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
# File 'lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb', line 521 def list_processors request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::ListProcessorsRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.list_processors..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.parent header_params["parent"] = request.parent end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.list_processors.timeout, metadata: , retry_policy: @config.rpcs.list_processors.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @document_processor_service_stub.call_rpc :list_processors, request, options: do |response, operation| response = ::Gapic::PagedEnumerable.new @document_processor_service_stub, :list_processors, request, response, operation, yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#process_document(request, options = nil) ⇒ ::Google::Cloud::DocumentAI::V1beta3::ProcessResponse #process_document(inline_document: nil, raw_document: nil, name: nil, document: nil, skip_human_review: nil) ⇒ ::Google::Cloud::DocumentAI::V1beta3::ProcessResponse
Processes a single document.
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb', line 231 def process_document request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::ProcessRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.process_document..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.name header_params["name"] = request.name end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.process_document.timeout, metadata: , retry_policy: @config.rpcs.process_document.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @document_processor_service_stub.call_rpc :process_document, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#review_document(request, options = nil) ⇒ ::Gapic::Operation #review_document(inline_document: nil, human_review_config: nil, document: nil, enable_schema_validation: nil, priority: nil) ⇒ ::Gapic::Operation
Send a document for Human Review. The input document should be processed by the specified processor.
994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 |
# File 'lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb', line 994 def review_document request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::ReviewDocumentRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.review_document..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.human_review_config header_params["human_review_config"] = request.human_review_config end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.review_document.timeout, metadata: , retry_policy: @config.rpcs.review_document.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @document_processor_service_stub.call_rpc :review_document, request, options: do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |