google-cloud-vision-v1 0.2.5 → 0.6.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.
@@ -34,3 +34,6 @@ module Google
34
34
  end
35
35
  end
36
36
  end
37
+
38
+ helper_path = ::File.join __dir__, "v1", "_helpers.rb"
39
+ require "google/cloud/vision/v1/_helpers" if ::File.file? helper_path
@@ -62,7 +62,7 @@ module Google
62
62
  parent_config = while namespace.any?
63
63
  parent_name = namespace.join "::"
64
64
  parent_const = const_get parent_name
65
- break parent_const.configure if parent_const&.respond_to? :configure
65
+ break parent_const.configure if parent_const.respond_to? :configure
66
66
  namespace.pop
67
67
  end
68
68
  default_config = Client::Configuration.new parent_config
@@ -70,33 +70,33 @@ module Google
70
70
  default_config.rpcs.batch_annotate_images.timeout = 600.0
71
71
  default_config.rpcs.batch_annotate_images.retry_policy = {
72
72
  initial_delay: 0.1,
73
- max_delay: 60.0,
74
- multiplier: 1.3,
75
- retry_codes: [4, 14]
73
+ max_delay: 60.0,
74
+ multiplier: 1.3,
75
+ retry_codes: [4, 14]
76
76
  }
77
77
 
78
78
  default_config.rpcs.batch_annotate_files.timeout = 600.0
79
79
  default_config.rpcs.batch_annotate_files.retry_policy = {
80
80
  initial_delay: 0.1,
81
- max_delay: 60.0,
82
- multiplier: 1.3,
83
- retry_codes: [4, 14]
81
+ max_delay: 60.0,
82
+ multiplier: 1.3,
83
+ retry_codes: [4, 14]
84
84
  }
85
85
 
86
86
  default_config.rpcs.async_batch_annotate_images.timeout = 600.0
87
87
  default_config.rpcs.async_batch_annotate_images.retry_policy = {
88
88
  initial_delay: 0.1,
89
- max_delay: 60.0,
90
- multiplier: 1.3,
91
- retry_codes: [4, 14]
89
+ max_delay: 60.0,
90
+ multiplier: 1.3,
91
+ retry_codes: [4, 14]
92
92
  }
93
93
 
94
94
  default_config.rpcs.async_batch_annotate_files.timeout = 600.0
95
95
  default_config.rpcs.async_batch_annotate_files.retry_policy = {
96
96
  initial_delay: 0.1,
97
- max_delay: 60.0,
98
- multiplier: 1.3,
99
- retry_codes: [4, 14]
97
+ max_delay: 60.0,
98
+ multiplier: 1.3,
99
+ retry_codes: [4, 14]
100
100
  }
101
101
 
102
102
  default_config
@@ -160,7 +160,13 @@ module Google
160
160
 
161
161
  # Create credentials
162
162
  credentials = @config.credentials
163
- credentials ||= Credentials.default scope: @config.scope
163
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
164
+ # but only if the default endpoint does not have a region prefix.
165
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
166
+ @config.endpoint == Client.configure.endpoint &&
167
+ !@config.endpoint.split(".").first.include?("-")
168
+ credentials ||= Credentials.default scope: @config.scope,
169
+ enable_self_signed_jwt: enable_self_signed_jwt
164
170
  if credentials.is_a?(String) || credentials.is_a?(Hash)
165
171
  credentials = Credentials.new credentials, scope: @config.scope
166
172
  end
@@ -288,8 +294,8 @@ module Google
288
294
  # the default parameter values, pass an empty Hash as a request object (see above).
289
295
  #
290
296
  # @param requests [::Array<::Google::Cloud::Vision::V1::AnnotateFileRequest, ::Hash>]
291
- # Required. The list of file annotation requests. Right now we support only one
292
- # AnnotateFileRequest in BatchAnnotateFilesRequest.
297
+ # Required. The list of file annotation requests. Right now we support only
298
+ # one AnnotateFileRequest in BatchAnnotateFilesRequest.
293
299
  # @param parent [::String]
294
300
  # Optional. Target project and location to make a call.
295
301
  #
@@ -598,7 +604,7 @@ module Google
598
604
  config_attr :scope, nil, ::String, ::Array, nil
599
605
  config_attr :lib_name, nil, ::String, nil
600
606
  config_attr :lib_version, nil, ::String, nil
601
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
607
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
602
608
  config_attr :interceptors, nil, ::Array, nil
603
609
  config_attr :timeout, nil, ::Numeric, nil
604
610
  config_attr :metadata, nil, ::Hash, nil
@@ -619,7 +625,7 @@ module Google
619
625
  def rpcs
620
626
  @rpcs ||= begin
621
627
  parent_rpcs = nil
622
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
628
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
623
629
  Rpcs.new parent_rpcs
624
630
  end
625
631
  end
@@ -631,7 +637,7 @@ module Google
631
637
  # Each configuration object is of type `Gapic::Config::Method` and includes
632
638
  # the following configuration fields:
633
639
  #
634
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
640
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
635
641
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
636
642
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
637
643
  # include the following keys:
@@ -665,13 +671,13 @@ module Google
665
671
 
666
672
  # @private
667
673
  def initialize parent_rpcs = nil
668
- batch_annotate_images_config = parent_rpcs&.batch_annotate_images if parent_rpcs&.respond_to? :batch_annotate_images
674
+ batch_annotate_images_config = parent_rpcs.batch_annotate_images if parent_rpcs.respond_to? :batch_annotate_images
669
675
  @batch_annotate_images = ::Gapic::Config::Method.new batch_annotate_images_config
670
- batch_annotate_files_config = parent_rpcs&.batch_annotate_files if parent_rpcs&.respond_to? :batch_annotate_files
676
+ batch_annotate_files_config = parent_rpcs.batch_annotate_files if parent_rpcs.respond_to? :batch_annotate_files
671
677
  @batch_annotate_files = ::Gapic::Config::Method.new batch_annotate_files_config
672
- async_batch_annotate_images_config = parent_rpcs&.async_batch_annotate_images if parent_rpcs&.respond_to? :async_batch_annotate_images
678
+ async_batch_annotate_images_config = parent_rpcs.async_batch_annotate_images if parent_rpcs.respond_to? :async_batch_annotate_images
673
679
  @async_batch_annotate_images = ::Gapic::Config::Method.new async_batch_annotate_images_config
674
- async_batch_annotate_files_config = parent_rpcs&.async_batch_annotate_files if parent_rpcs&.respond_to? :async_batch_annotate_files
680
+ async_batch_annotate_files_config = parent_rpcs.async_batch_annotate_files if parent_rpcs.respond_to? :async_batch_annotate_files
675
681
  @async_batch_annotate_files = ::Gapic::Config::Method.new async_batch_annotate_files_config
676
682
 
677
683
  yield self if block_given?
@@ -103,8 +103,13 @@ module Google
103
103
  # Lists operations that match the specified filter in the request. If the
104
104
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
105
105
  #
106
- # NOTE: the `name` binding below allows API services to override the binding
107
- # to use different resource name schemes, such as `users/*/operations`.
106
+ # NOTE: the `name` binding allows API services to override the binding
107
+ # to use different resource name schemes, such as `users/*/operations`. To
108
+ # override the binding, API services can add a binding such as
109
+ # `"/v1/{name=users/*}/operations"` to their service configuration.
110
+ # For backwards compatibility, the default name includes the operations
111
+ # collection id, however overriding users must ensure the name binding
112
+ # is the parent resource, without the operations collection id.
108
113
  #
109
114
  # @overload list_operations(request, options = nil)
110
115
  # Pass arguments to `list_operations` via a request object, either of type
@@ -122,7 +127,7 @@ module Google
122
127
  # the default parameter values, pass an empty Hash as a request object (see above).
123
128
  #
124
129
  # @param name [::String]
125
- # The name of the operation collection.
130
+ # The name of the operation's parent resource.
126
131
  # @param filter [::String]
127
132
  # The standard list filter.
128
133
  # @param page_size [::Integer]
@@ -390,6 +395,79 @@ module Google
390
395
  raise ::Google::Cloud::Error.from_error(e)
391
396
  end
392
397
 
398
+ ##
399
+ # Waits for the specified long-running operation until it is done or reaches
400
+ # at most a specified timeout, returning the latest state. If the operation
401
+ # is already done, the latest state is immediately returned. If the timeout
402
+ # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
403
+ # timeout is used. If the server does not support this method, it returns
404
+ # `google.rpc.Code.UNIMPLEMENTED`.
405
+ # Note that this method is on a best-effort basis. It may return the latest
406
+ # state before the specified timeout (including immediately), meaning even an
407
+ # immediate response is no guarantee that the operation is done.
408
+ #
409
+ # @overload wait_operation(request, options = nil)
410
+ # Pass arguments to `wait_operation` via a request object, either of type
411
+ # {::Google::Longrunning::WaitOperationRequest} or an equivalent Hash.
412
+ #
413
+ # @param request [::Google::Longrunning::WaitOperationRequest, ::Hash]
414
+ # A request object representing the call parameters. Required. To specify no
415
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
416
+ # @param options [::Gapic::CallOptions, ::Hash]
417
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
418
+ #
419
+ # @overload wait_operation(name: nil, timeout: nil)
420
+ # Pass arguments to `wait_operation` via keyword arguments. Note that at
421
+ # least one keyword argument is required. To specify no parameters, or to keep all
422
+ # the default parameter values, pass an empty Hash as a request object (see above).
423
+ #
424
+ # @param name [::String]
425
+ # The name of the operation resource to wait on.
426
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
427
+ # The maximum duration to wait before timing out. If left blank, the wait
428
+ # will be at most the time permitted by the underlying HTTP/RPC protocol.
429
+ # If RPC context deadline is also specified, the shorter one will be used.
430
+ #
431
+ # @yield [response, operation] Access the result along with the RPC operation
432
+ # @yieldparam response [::Gapic::Operation]
433
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
434
+ #
435
+ # @return [::Gapic::Operation]
436
+ #
437
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
438
+ #
439
+ def wait_operation request, options = nil
440
+ raise ::ArgumentError, "request must be provided" if request.nil?
441
+
442
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::WaitOperationRequest
443
+
444
+ # Converts hash and nil to an options object
445
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
446
+
447
+ # Customize the options with defaults
448
+ metadata = @config.rpcs.wait_operation.metadata.to_h
449
+
450
+ # Set x-goog-api-client and x-goog-user-project headers
451
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
452
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
453
+ gapic_version: ::Google::Cloud::Vision::V1::VERSION
454
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
455
+
456
+ options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
457
+ metadata: metadata,
458
+ retry_policy: @config.rpcs.wait_operation.retry_policy
459
+ options.apply_defaults metadata: @config.metadata,
460
+ retry_policy: @config.retry_policy
461
+
462
+ @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
463
+ response = ::Gapic::Operation.new response, @operations_client, options: options
464
+ yield response, operation if block_given?
465
+ return response
466
+ end
467
+ rescue ::GRPC::BadStatus => e
468
+ raise ::Google::Cloud::Error.from_error(e)
469
+ end
470
+
393
471
  ##
394
472
  # Configuration class for the Operations API.
395
473
  #
@@ -482,7 +560,7 @@ module Google
482
560
  config_attr :scope, nil, ::String, ::Array, nil
483
561
  config_attr :lib_name, nil, ::String, nil
484
562
  config_attr :lib_version, nil, ::String, nil
485
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
563
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
486
564
  config_attr :interceptors, nil, ::Array, nil
487
565
  config_attr :timeout, nil, ::Numeric, nil
488
566
  config_attr :metadata, nil, ::Hash, nil
@@ -503,7 +581,7 @@ module Google
503
581
  def rpcs
504
582
  @rpcs ||= begin
505
583
  parent_rpcs = nil
506
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
584
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
507
585
  Rpcs.new parent_rpcs
508
586
  end
509
587
  end
@@ -515,7 +593,7 @@ module Google
515
593
  # Each configuration object is of type `Gapic::Config::Method` and includes
516
594
  # the following configuration fields:
517
595
  #
518
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
596
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
519
597
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
520
598
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
521
599
  # include the following keys:
@@ -546,17 +624,24 @@ module Google
546
624
  # @return [::Gapic::Config::Method]
547
625
  #
548
626
  attr_reader :cancel_operation
627
+ ##
628
+ # RPC-specific configuration for `wait_operation`
629
+ # @return [::Gapic::Config::Method]
630
+ #
631
+ attr_reader :wait_operation
549
632
 
550
633
  # @private
551
634
  def initialize parent_rpcs = nil
552
- list_operations_config = parent_rpcs&.list_operations if parent_rpcs&.respond_to? :list_operations
635
+ list_operations_config = parent_rpcs.list_operations if parent_rpcs.respond_to? :list_operations
553
636
  @list_operations = ::Gapic::Config::Method.new list_operations_config
554
- get_operation_config = parent_rpcs&.get_operation if parent_rpcs&.respond_to? :get_operation
637
+ get_operation_config = parent_rpcs.get_operation if parent_rpcs.respond_to? :get_operation
555
638
  @get_operation = ::Gapic::Config::Method.new get_operation_config
556
- delete_operation_config = parent_rpcs&.delete_operation if parent_rpcs&.respond_to? :delete_operation
639
+ delete_operation_config = parent_rpcs.delete_operation if parent_rpcs.respond_to? :delete_operation
557
640
  @delete_operation = ::Gapic::Config::Method.new delete_operation_config
558
- cancel_operation_config = parent_rpcs&.cancel_operation if parent_rpcs&.respond_to? :cancel_operation
641
+ cancel_operation_config = parent_rpcs.cancel_operation if parent_rpcs.respond_to? :cancel_operation
559
642
  @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
643
+ wait_operation_config = parent_rpcs.wait_operation if parent_rpcs.respond_to? :wait_operation
644
+ @wait_operation = ::Gapic::Config::Method.new wait_operation_config
560
645
 
561
646
  yield self if block_given?
562
647
  end
@@ -103,6 +103,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
103
103
  value :CHIN_GNATHION, 32
104
104
  value :CHIN_LEFT_GONION, 33
105
105
  value :CHIN_RIGHT_GONION, 34
106
+ value :LEFT_CHEEK_CENTER, 35
107
+ value :RIGHT_CHEEK_CENTER, 36
106
108
  end
107
109
  add_message "google.cloud.vision.v1.LocationInfo" do
108
110
  optional :lat_lng, :message, 1, "google.type.LatLng"
@@ -172,12 +174,16 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
172
174
  add_message "google.cloud.vision.v1.WebDetectionParams" do
173
175
  optional :include_geo_results, :bool, 2
174
176
  end
177
+ add_message "google.cloud.vision.v1.TextDetectionParams" do
178
+ optional :enable_text_detection_confidence_score, :bool, 9
179
+ end
175
180
  add_message "google.cloud.vision.v1.ImageContext" do
176
181
  optional :lat_long_rect, :message, 1, "google.cloud.vision.v1.LatLongRect"
177
182
  repeated :language_hints, :string, 2
178
183
  optional :crop_hints_params, :message, 4, "google.cloud.vision.v1.CropHintsParams"
179
184
  optional :product_search_params, :message, 5, "google.cloud.vision.v1.ProductSearchParams"
180
185
  optional :web_detection_params, :message, 6, "google.cloud.vision.v1.WebDetectionParams"
186
+ optional :text_detection_params, :message, 12, "google.cloud.vision.v1.TextDetectionParams"
181
187
  end
182
188
  add_message "google.cloud.vision.v1.AnnotateImageRequest" do
183
189
  optional :image, :message, 1, "google.cloud.vision.v1.Image"
@@ -316,6 +322,7 @@ module Google
316
322
  CropHintsAnnotation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.vision.v1.CropHintsAnnotation").msgclass
317
323
  CropHintsParams = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.vision.v1.CropHintsParams").msgclass
318
324
  WebDetectionParams = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.vision.v1.WebDetectionParams").msgclass
325
+ TextDetectionParams = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.vision.v1.TextDetectionParams").msgclass
319
326
  ImageContext = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.vision.v1.ImageContext").msgclass
320
327
  AnnotateImageRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.vision.v1.AnnotateImageRequest").msgclass
321
328
  ImageAnnotationContext = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.vision.v1.ImageAnnotationContext").msgclass
@@ -1,7 +1,7 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # Source: google/cloud/vision/v1/image_annotator.proto for package 'google.cloud.vision.v1'
3
3
  # Original file comments:
4
- # Copyright 2019 Google LLC.
4
+ # Copyright 2020 Google LLC
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- #
19
18
 
20
19
  require 'grpc'
21
20
  require 'google/cloud/vision/v1/image_annotator_pb'
@@ -37,7 +36,7 @@ module Google
37
36
  self.service_name = 'google.cloud.vision.v1.ImageAnnotator'
38
37
 
39
38
  # Run image detection and annotation for a batch of images.
40
- rpc :BatchAnnotateImages, Google::Cloud::Vision::V1::BatchAnnotateImagesRequest, Google::Cloud::Vision::V1::BatchAnnotateImagesResponse
39
+ rpc :BatchAnnotateImages, ::Google::Cloud::Vision::V1::BatchAnnotateImagesRequest, ::Google::Cloud::Vision::V1::BatchAnnotateImagesResponse
41
40
  # Service that performs image detection and annotation for a batch of files.
42
41
  # Now only "application/pdf", "image/tiff" and "image/gif" are supported.
43
42
  #
@@ -45,7 +44,7 @@ module Google
45
44
  # AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each
46
45
  # file provided and perform detection and annotation for each image
47
46
  # extracted.
48
- rpc :BatchAnnotateFiles, Google::Cloud::Vision::V1::BatchAnnotateFilesRequest, Google::Cloud::Vision::V1::BatchAnnotateFilesResponse
47
+ rpc :BatchAnnotateFiles, ::Google::Cloud::Vision::V1::BatchAnnotateFilesRequest, ::Google::Cloud::Vision::V1::BatchAnnotateFilesResponse
49
48
  # Run asynchronous image detection and annotation for a list of images.
50
49
  #
51
50
  # Progress and results can be retrieved through the
@@ -55,14 +54,14 @@ module Google
55
54
  #
56
55
  # This service will write image annotation outputs to json files in customer
57
56
  # GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
58
- rpc :AsyncBatchAnnotateImages, Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesRequest, Google::Longrunning::Operation
57
+ rpc :AsyncBatchAnnotateImages, ::Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesRequest, ::Google::Longrunning::Operation
59
58
  # Run asynchronous image detection and annotation for a list of generic
60
59
  # files, such as PDF files, which may contain multiple pages and multiple
61
60
  # images per page. Progress and results can be retrieved through the
62
61
  # `google.longrunning.Operations` interface.
63
62
  # `Operation.metadata` contains `OperationMetadata` (metadata).
64
63
  # `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
65
- rpc :AsyncBatchAnnotateFiles, Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesRequest, Google::Longrunning::Operation
64
+ rpc :AsyncBatchAnnotateFiles, ::Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesRequest, ::Google::Longrunning::Operation
66
65
  end
67
66
 
68
67
  Stub = Service.rpc_stub_class
@@ -73,7 +73,7 @@ module Google
73
73
  parent_config = while namespace.any?
74
74
  parent_name = namespace.join "::"
75
75
  parent_const = const_get parent_name
76
- break parent_const.configure if parent_const&.respond_to? :configure
76
+ break parent_const.configure if parent_const.respond_to? :configure
77
77
  namespace.pop
78
78
  end
79
79
  default_config = Client::Configuration.new parent_config
@@ -81,153 +81,153 @@ module Google
81
81
  default_config.rpcs.create_product_set.timeout = 600.0
82
82
  default_config.rpcs.create_product_set.retry_policy = {
83
83
  initial_delay: 0.1,
84
- max_delay: 60.0,
85
- multiplier: 1.3,
86
- retry_codes: []
84
+ max_delay: 60.0,
85
+ multiplier: 1.3,
86
+ retry_codes: []
87
87
  }
88
88
 
89
89
  default_config.rpcs.list_product_sets.timeout = 600.0
90
90
  default_config.rpcs.list_product_sets.retry_policy = {
91
91
  initial_delay: 0.1,
92
- max_delay: 60.0,
93
- multiplier: 1.3,
94
- retry_codes: [4, 14]
92
+ max_delay: 60.0,
93
+ multiplier: 1.3,
94
+ retry_codes: [4, 14]
95
95
  }
96
96
 
97
97
  default_config.rpcs.get_product_set.timeout = 600.0
98
98
  default_config.rpcs.get_product_set.retry_policy = {
99
99
  initial_delay: 0.1,
100
- max_delay: 60.0,
101
- multiplier: 1.3,
102
- retry_codes: [4, 14]
100
+ max_delay: 60.0,
101
+ multiplier: 1.3,
102
+ retry_codes: [4, 14]
103
103
  }
104
104
 
105
105
  default_config.rpcs.update_product_set.timeout = 600.0
106
106
  default_config.rpcs.update_product_set.retry_policy = {
107
107
  initial_delay: 0.1,
108
- max_delay: 60.0,
109
- multiplier: 1.3,
110
- retry_codes: [4, 14]
108
+ max_delay: 60.0,
109
+ multiplier: 1.3,
110
+ retry_codes: [4, 14]
111
111
  }
112
112
 
113
113
  default_config.rpcs.delete_product_set.timeout = 600.0
114
114
  default_config.rpcs.delete_product_set.retry_policy = {
115
115
  initial_delay: 0.1,
116
- max_delay: 60.0,
117
- multiplier: 1.3,
118
- retry_codes: [4, 14]
116
+ max_delay: 60.0,
117
+ multiplier: 1.3,
118
+ retry_codes: [4, 14]
119
119
  }
120
120
 
121
121
  default_config.rpcs.create_product.timeout = 600.0
122
122
  default_config.rpcs.create_product.retry_policy = {
123
123
  initial_delay: 0.1,
124
- max_delay: 60.0,
125
- multiplier: 1.3,
126
- retry_codes: []
124
+ max_delay: 60.0,
125
+ multiplier: 1.3,
126
+ retry_codes: []
127
127
  }
128
128
 
129
129
  default_config.rpcs.list_products.timeout = 600.0
130
130
  default_config.rpcs.list_products.retry_policy = {
131
131
  initial_delay: 0.1,
132
- max_delay: 60.0,
133
- multiplier: 1.3,
134
- retry_codes: [4, 14]
132
+ max_delay: 60.0,
133
+ multiplier: 1.3,
134
+ retry_codes: [4, 14]
135
135
  }
136
136
 
137
137
  default_config.rpcs.get_product.timeout = 600.0
138
138
  default_config.rpcs.get_product.retry_policy = {
139
139
  initial_delay: 0.1,
140
- max_delay: 60.0,
141
- multiplier: 1.3,
142
- retry_codes: [4, 14]
140
+ max_delay: 60.0,
141
+ multiplier: 1.3,
142
+ retry_codes: [4, 14]
143
143
  }
144
144
 
145
145
  default_config.rpcs.update_product.timeout = 600.0
146
146
  default_config.rpcs.update_product.retry_policy = {
147
147
  initial_delay: 0.1,
148
- max_delay: 60.0,
149
- multiplier: 1.3,
150
- retry_codes: [4, 14]
148
+ max_delay: 60.0,
149
+ multiplier: 1.3,
150
+ retry_codes: [4, 14]
151
151
  }
152
152
 
153
153
  default_config.rpcs.delete_product.timeout = 600.0
154
154
  default_config.rpcs.delete_product.retry_policy = {
155
155
  initial_delay: 0.1,
156
- max_delay: 60.0,
157
- multiplier: 1.3,
158
- retry_codes: [4, 14]
156
+ max_delay: 60.0,
157
+ multiplier: 1.3,
158
+ retry_codes: [4, 14]
159
159
  }
160
160
 
161
161
  default_config.rpcs.create_reference_image.timeout = 600.0
162
162
  default_config.rpcs.create_reference_image.retry_policy = {
163
163
  initial_delay: 0.1,
164
- max_delay: 60.0,
165
- multiplier: 1.3,
166
- retry_codes: []
164
+ max_delay: 60.0,
165
+ multiplier: 1.3,
166
+ retry_codes: []
167
167
  }
168
168
 
169
169
  default_config.rpcs.delete_reference_image.timeout = 600.0
170
170
  default_config.rpcs.delete_reference_image.retry_policy = {
171
171
  initial_delay: 0.1,
172
- max_delay: 60.0,
173
- multiplier: 1.3,
174
- retry_codes: [4, 14]
172
+ max_delay: 60.0,
173
+ multiplier: 1.3,
174
+ retry_codes: [4, 14]
175
175
  }
176
176
 
177
177
  default_config.rpcs.list_reference_images.timeout = 600.0
178
178
  default_config.rpcs.list_reference_images.retry_policy = {
179
179
  initial_delay: 0.1,
180
- max_delay: 60.0,
181
- multiplier: 1.3,
182
- retry_codes: [4, 14]
180
+ max_delay: 60.0,
181
+ multiplier: 1.3,
182
+ retry_codes: [4, 14]
183
183
  }
184
184
 
185
185
  default_config.rpcs.get_reference_image.timeout = 600.0
186
186
  default_config.rpcs.get_reference_image.retry_policy = {
187
187
  initial_delay: 0.1,
188
- max_delay: 60.0,
189
- multiplier: 1.3,
190
- retry_codes: [4, 14]
188
+ max_delay: 60.0,
189
+ multiplier: 1.3,
190
+ retry_codes: [4, 14]
191
191
  }
192
192
 
193
193
  default_config.rpcs.add_product_to_product_set.timeout = 600.0
194
194
  default_config.rpcs.add_product_to_product_set.retry_policy = {
195
195
  initial_delay: 0.1,
196
- max_delay: 60.0,
197
- multiplier: 1.3,
198
- retry_codes: [4, 14]
196
+ max_delay: 60.0,
197
+ multiplier: 1.3,
198
+ retry_codes: [4, 14]
199
199
  }
200
200
 
201
201
  default_config.rpcs.remove_product_from_product_set.timeout = 600.0
202
202
  default_config.rpcs.remove_product_from_product_set.retry_policy = {
203
203
  initial_delay: 0.1,
204
- max_delay: 60.0,
205
- multiplier: 1.3,
206
- retry_codes: [4, 14]
204
+ max_delay: 60.0,
205
+ multiplier: 1.3,
206
+ retry_codes: [4, 14]
207
207
  }
208
208
 
209
209
  default_config.rpcs.list_products_in_product_set.timeout = 600.0
210
210
  default_config.rpcs.list_products_in_product_set.retry_policy = {
211
211
  initial_delay: 0.1,
212
- max_delay: 60.0,
213
- multiplier: 1.3,
214
- retry_codes: [4, 14]
212
+ max_delay: 60.0,
213
+ multiplier: 1.3,
214
+ retry_codes: [4, 14]
215
215
  }
216
216
 
217
217
  default_config.rpcs.import_product_sets.timeout = 600.0
218
218
  default_config.rpcs.import_product_sets.retry_policy = {
219
219
  initial_delay: 0.1,
220
- max_delay: 60.0,
221
- multiplier: 1.3,
222
- retry_codes: []
220
+ max_delay: 60.0,
221
+ multiplier: 1.3,
222
+ retry_codes: []
223
223
  }
224
224
 
225
225
  default_config.rpcs.purge_products.timeout = 600.0
226
226
  default_config.rpcs.purge_products.retry_policy = {
227
227
  initial_delay: 0.1,
228
- max_delay: 60.0,
229
- multiplier: 1.3,
230
- retry_codes: []
228
+ max_delay: 60.0,
229
+ multiplier: 1.3,
230
+ retry_codes: []
231
231
  }
232
232
 
233
233
  default_config
@@ -291,7 +291,13 @@ module Google
291
291
 
292
292
  # Create credentials
293
293
  credentials = @config.credentials
294
- credentials ||= Credentials.default scope: @config.scope
294
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
295
+ # but only if the default endpoint does not have a region prefix.
296
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
297
+ @config.endpoint == Client.configure.endpoint &&
298
+ !@config.endpoint.split(".").first.include?("-")
299
+ credentials ||= Credentials.default scope: @config.scope,
300
+ enable_self_signed_jwt: enable_self_signed_jwt
295
301
  if credentials.is_a?(String) || credentials.is_a?(Hash)
296
302
  credentials = Credentials.new credentials, scope: @config.scope
297
303
  end
@@ -505,7 +511,7 @@ module Google
505
511
  # Required. Resource name of the ProductSet to get.
506
512
  #
507
513
  # Format is:
508
- # `projects/PROJECT_ID/locations/LOG_ID/productSets/PRODUCT_SET_ID`
514
+ # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
509
515
  #
510
516
  # @yield [response, operation] Access the result along with the RPC operation
511
517
  # @yieldparam response [::Google::Cloud::Vision::V1::ProductSet]
@@ -1219,7 +1225,6 @@ module Google
1219
1225
  # Required. The resource name of the reference image to delete.
1220
1226
  #
1221
1227
  # Format is:
1222
- #
1223
1228
  # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`
1224
1229
  #
1225
1230
  # @yield [response, operation] Access the result along with the RPC operation
@@ -1376,7 +1381,6 @@ module Google
1376
1381
  # Required. The resource name of the ReferenceImage to get.
1377
1382
  #
1378
1383
  # Format is:
1379
- #
1380
1384
  # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`.
1381
1385
  #
1382
1386
  # @yield [response, operation] Access the result along with the RPC operation
@@ -1932,7 +1936,7 @@ module Google
1932
1936
  config_attr :scope, nil, ::String, ::Array, nil
1933
1937
  config_attr :lib_name, nil, ::String, nil
1934
1938
  config_attr :lib_version, nil, ::String, nil
1935
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
1939
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
1936
1940
  config_attr :interceptors, nil, ::Array, nil
1937
1941
  config_attr :timeout, nil, ::Numeric, nil
1938
1942
  config_attr :metadata, nil, ::Hash, nil
@@ -1953,7 +1957,7 @@ module Google
1953
1957
  def rpcs
1954
1958
  @rpcs ||= begin
1955
1959
  parent_rpcs = nil
1956
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
1960
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1957
1961
  Rpcs.new parent_rpcs
1958
1962
  end
1959
1963
  end
@@ -1965,7 +1969,7 @@ module Google
1965
1969
  # Each configuration object is of type `Gapic::Config::Method` and includes
1966
1970
  # the following configuration fields:
1967
1971
  #
1968
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
1972
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1969
1973
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
1970
1974
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1971
1975
  # include the following keys:
@@ -2074,43 +2078,43 @@ module Google
2074
2078
 
2075
2079
  # @private
2076
2080
  def initialize parent_rpcs = nil
2077
- create_product_set_config = parent_rpcs&.create_product_set if parent_rpcs&.respond_to? :create_product_set
2081
+ create_product_set_config = parent_rpcs.create_product_set if parent_rpcs.respond_to? :create_product_set
2078
2082
  @create_product_set = ::Gapic::Config::Method.new create_product_set_config
2079
- list_product_sets_config = parent_rpcs&.list_product_sets if parent_rpcs&.respond_to? :list_product_sets
2083
+ list_product_sets_config = parent_rpcs.list_product_sets if parent_rpcs.respond_to? :list_product_sets
2080
2084
  @list_product_sets = ::Gapic::Config::Method.new list_product_sets_config
2081
- get_product_set_config = parent_rpcs&.get_product_set if parent_rpcs&.respond_to? :get_product_set
2085
+ get_product_set_config = parent_rpcs.get_product_set if parent_rpcs.respond_to? :get_product_set
2082
2086
  @get_product_set = ::Gapic::Config::Method.new get_product_set_config
2083
- update_product_set_config = parent_rpcs&.update_product_set if parent_rpcs&.respond_to? :update_product_set
2087
+ update_product_set_config = parent_rpcs.update_product_set if parent_rpcs.respond_to? :update_product_set
2084
2088
  @update_product_set = ::Gapic::Config::Method.new update_product_set_config
2085
- delete_product_set_config = parent_rpcs&.delete_product_set if parent_rpcs&.respond_to? :delete_product_set
2089
+ delete_product_set_config = parent_rpcs.delete_product_set if parent_rpcs.respond_to? :delete_product_set
2086
2090
  @delete_product_set = ::Gapic::Config::Method.new delete_product_set_config
2087
- create_product_config = parent_rpcs&.create_product if parent_rpcs&.respond_to? :create_product
2091
+ create_product_config = parent_rpcs.create_product if parent_rpcs.respond_to? :create_product
2088
2092
  @create_product = ::Gapic::Config::Method.new create_product_config
2089
- list_products_config = parent_rpcs&.list_products if parent_rpcs&.respond_to? :list_products
2093
+ list_products_config = parent_rpcs.list_products if parent_rpcs.respond_to? :list_products
2090
2094
  @list_products = ::Gapic::Config::Method.new list_products_config
2091
- get_product_config = parent_rpcs&.get_product if parent_rpcs&.respond_to? :get_product
2095
+ get_product_config = parent_rpcs.get_product if parent_rpcs.respond_to? :get_product
2092
2096
  @get_product = ::Gapic::Config::Method.new get_product_config
2093
- update_product_config = parent_rpcs&.update_product if parent_rpcs&.respond_to? :update_product
2097
+ update_product_config = parent_rpcs.update_product if parent_rpcs.respond_to? :update_product
2094
2098
  @update_product = ::Gapic::Config::Method.new update_product_config
2095
- delete_product_config = parent_rpcs&.delete_product if parent_rpcs&.respond_to? :delete_product
2099
+ delete_product_config = parent_rpcs.delete_product if parent_rpcs.respond_to? :delete_product
2096
2100
  @delete_product = ::Gapic::Config::Method.new delete_product_config
2097
- create_reference_image_config = parent_rpcs&.create_reference_image if parent_rpcs&.respond_to? :create_reference_image
2101
+ create_reference_image_config = parent_rpcs.create_reference_image if parent_rpcs.respond_to? :create_reference_image
2098
2102
  @create_reference_image = ::Gapic::Config::Method.new create_reference_image_config
2099
- delete_reference_image_config = parent_rpcs&.delete_reference_image if parent_rpcs&.respond_to? :delete_reference_image
2103
+ delete_reference_image_config = parent_rpcs.delete_reference_image if parent_rpcs.respond_to? :delete_reference_image
2100
2104
  @delete_reference_image = ::Gapic::Config::Method.new delete_reference_image_config
2101
- list_reference_images_config = parent_rpcs&.list_reference_images if parent_rpcs&.respond_to? :list_reference_images
2105
+ list_reference_images_config = parent_rpcs.list_reference_images if parent_rpcs.respond_to? :list_reference_images
2102
2106
  @list_reference_images = ::Gapic::Config::Method.new list_reference_images_config
2103
- get_reference_image_config = parent_rpcs&.get_reference_image if parent_rpcs&.respond_to? :get_reference_image
2107
+ get_reference_image_config = parent_rpcs.get_reference_image if parent_rpcs.respond_to? :get_reference_image
2104
2108
  @get_reference_image = ::Gapic::Config::Method.new get_reference_image_config
2105
- add_product_to_product_set_config = parent_rpcs&.add_product_to_product_set if parent_rpcs&.respond_to? :add_product_to_product_set
2109
+ add_product_to_product_set_config = parent_rpcs.add_product_to_product_set if parent_rpcs.respond_to? :add_product_to_product_set
2106
2110
  @add_product_to_product_set = ::Gapic::Config::Method.new add_product_to_product_set_config
2107
- remove_product_from_product_set_config = parent_rpcs&.remove_product_from_product_set if parent_rpcs&.respond_to? :remove_product_from_product_set
2111
+ remove_product_from_product_set_config = parent_rpcs.remove_product_from_product_set if parent_rpcs.respond_to? :remove_product_from_product_set
2108
2112
  @remove_product_from_product_set = ::Gapic::Config::Method.new remove_product_from_product_set_config
2109
- list_products_in_product_set_config = parent_rpcs&.list_products_in_product_set if parent_rpcs&.respond_to? :list_products_in_product_set
2113
+ list_products_in_product_set_config = parent_rpcs.list_products_in_product_set if parent_rpcs.respond_to? :list_products_in_product_set
2110
2114
  @list_products_in_product_set = ::Gapic::Config::Method.new list_products_in_product_set_config
2111
- import_product_sets_config = parent_rpcs&.import_product_sets if parent_rpcs&.respond_to? :import_product_sets
2115
+ import_product_sets_config = parent_rpcs.import_product_sets if parent_rpcs.respond_to? :import_product_sets
2112
2116
  @import_product_sets = ::Gapic::Config::Method.new import_product_sets_config
2113
- purge_products_config = parent_rpcs&.purge_products if parent_rpcs&.respond_to? :purge_products
2117
+ purge_products_config = parent_rpcs.purge_products if parent_rpcs.respond_to? :purge_products
2114
2118
  @purge_products = ::Gapic::Config::Method.new purge_products_config
2115
2119
 
2116
2120
  yield self if block_given?