google-cloud-vision-v1 0.3.1 → 0.6.2

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.
@@ -62,41 +62,29 @@ 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
69
69
 
70
70
  default_config.rpcs.batch_annotate_images.timeout = 600.0
71
71
  default_config.rpcs.batch_annotate_images.retry_policy = {
72
- initial_delay: 0.1,
73
- max_delay: 60.0,
74
- multiplier: 1.3,
75
- retry_codes: [4, 14]
72
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
76
73
  }
77
74
 
78
75
  default_config.rpcs.batch_annotate_files.timeout = 600.0
79
76
  default_config.rpcs.batch_annotate_files.retry_policy = {
80
- initial_delay: 0.1,
81
- max_delay: 60.0,
82
- multiplier: 1.3,
83
- retry_codes: [4, 14]
77
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
84
78
  }
85
79
 
86
80
  default_config.rpcs.async_batch_annotate_images.timeout = 600.0
87
81
  default_config.rpcs.async_batch_annotate_images.retry_policy = {
88
- initial_delay: 0.1,
89
- max_delay: 60.0,
90
- multiplier: 1.3,
91
- retry_codes: [4, 14]
82
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
92
83
  }
93
84
 
94
85
  default_config.rpcs.async_batch_annotate_files.timeout = 600.0
95
86
  default_config.rpcs.async_batch_annotate_files.retry_policy = {
96
- initial_delay: 0.1,
97
- max_delay: 60.0,
98
- multiplier: 1.3,
99
- retry_codes: [4, 14]
87
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
100
88
  }
101
89
 
102
90
  default_config
@@ -160,8 +148,14 @@ module Google
160
148
 
161
149
  # Create credentials
162
150
  credentials = @config.credentials
163
- credentials ||= Credentials.default scope: @config.scope
164
- if credentials.is_a?(String) || credentials.is_a?(Hash)
151
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
152
+ # but only if the default endpoint does not have a region prefix.
153
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
154
+ @config.endpoint == Client.configure.endpoint &&
155
+ !@config.endpoint.split(".").first.include?("-")
156
+ credentials ||= Credentials.default scope: @config.scope,
157
+ enable_self_signed_jwt: enable_self_signed_jwt
158
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
165
159
  credentials = Credentials.new credentials, scope: @config.scope
166
160
  end
167
161
  @quota_project_id = @config.quota_project
@@ -288,8 +282,8 @@ module Google
288
282
  # the default parameter values, pass an empty Hash as a request object (see above).
289
283
  #
290
284
  # @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.
285
+ # Required. The list of file annotation requests. Right now we support only
286
+ # one AnnotateFileRequest in BatchAnnotateFilesRequest.
293
287
  # @param parent [::String]
294
288
  # Optional. Target project and location to make a call.
295
289
  #
@@ -598,7 +592,7 @@ module Google
598
592
  config_attr :scope, nil, ::String, ::Array, nil
599
593
  config_attr :lib_name, nil, ::String, nil
600
594
  config_attr :lib_version, nil, ::String, nil
601
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
595
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
602
596
  config_attr :interceptors, nil, ::Array, nil
603
597
  config_attr :timeout, nil, ::Numeric, nil
604
598
  config_attr :metadata, nil, ::Hash, nil
@@ -619,7 +613,7 @@ module Google
619
613
  def rpcs
620
614
  @rpcs ||= begin
621
615
  parent_rpcs = nil
622
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
616
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
623
617
  Rpcs.new parent_rpcs
624
618
  end
625
619
  end
@@ -665,13 +659,13 @@ module Google
665
659
 
666
660
  # @private
667
661
  def initialize parent_rpcs = nil
668
- batch_annotate_images_config = parent_rpcs&.batch_annotate_images if parent_rpcs&.respond_to? :batch_annotate_images
662
+ batch_annotate_images_config = parent_rpcs.batch_annotate_images if parent_rpcs.respond_to? :batch_annotate_images
669
663
  @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
664
+ batch_annotate_files_config = parent_rpcs.batch_annotate_files if parent_rpcs.respond_to? :batch_annotate_files
671
665
  @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
666
+ async_batch_annotate_images_config = parent_rpcs.async_batch_annotate_images if parent_rpcs.respond_to? :async_batch_annotate_images
673
667
  @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
668
+ async_batch_annotate_files_config = parent_rpcs.async_batch_annotate_files if parent_rpcs.respond_to? :async_batch_annotate_files
675
669
  @async_batch_annotate_files = ::Gapic::Config::Method.new async_batch_annotate_files_config
676
670
 
677
671
  yield self if block_given?
@@ -82,7 +82,7 @@ module Google
82
82
  # Create credentials
83
83
  credentials = @config.credentials
84
84
  credentials ||= Credentials.default scope: @config.scope
85
- if credentials.is_a?(String) || credentials.is_a?(Hash)
85
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
86
86
  credentials = Credentials.new credentials, scope: @config.scope
87
87
  end
88
88
  @quota_project_id = @config.quota_project
@@ -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 until the specified long-running operation is done or reaches at most
400
+ # a specified timeout, returning the latest state. If the operation is
401
+ # 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
@@ -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"
@@ -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'
@@ -73,161 +73,104 @@ 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
80
80
 
81
81
  default_config.rpcs.create_product_set.timeout = 600.0
82
82
  default_config.rpcs.create_product_set.retry_policy = {
83
- initial_delay: 0.1,
84
- max_delay: 60.0,
85
- multiplier: 1.3,
86
- retry_codes: []
83
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: []
87
84
  }
88
85
 
89
86
  default_config.rpcs.list_product_sets.timeout = 600.0
90
87
  default_config.rpcs.list_product_sets.retry_policy = {
91
- initial_delay: 0.1,
92
- max_delay: 60.0,
93
- multiplier: 1.3,
94
- retry_codes: [4, 14]
88
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
95
89
  }
96
90
 
97
91
  default_config.rpcs.get_product_set.timeout = 600.0
98
92
  default_config.rpcs.get_product_set.retry_policy = {
99
- initial_delay: 0.1,
100
- max_delay: 60.0,
101
- multiplier: 1.3,
102
- retry_codes: [4, 14]
93
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
103
94
  }
104
95
 
105
96
  default_config.rpcs.update_product_set.timeout = 600.0
106
97
  default_config.rpcs.update_product_set.retry_policy = {
107
- initial_delay: 0.1,
108
- max_delay: 60.0,
109
- multiplier: 1.3,
110
- retry_codes: [4, 14]
98
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
111
99
  }
112
100
 
113
101
  default_config.rpcs.delete_product_set.timeout = 600.0
114
102
  default_config.rpcs.delete_product_set.retry_policy = {
115
- initial_delay: 0.1,
116
- max_delay: 60.0,
117
- multiplier: 1.3,
118
- retry_codes: [4, 14]
103
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
119
104
  }
120
105
 
121
106
  default_config.rpcs.create_product.timeout = 600.0
122
107
  default_config.rpcs.create_product.retry_policy = {
123
- initial_delay: 0.1,
124
- max_delay: 60.0,
125
- multiplier: 1.3,
126
- retry_codes: []
108
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: []
127
109
  }
128
110
 
129
111
  default_config.rpcs.list_products.timeout = 600.0
130
112
  default_config.rpcs.list_products.retry_policy = {
131
- initial_delay: 0.1,
132
- max_delay: 60.0,
133
- multiplier: 1.3,
134
- retry_codes: [4, 14]
113
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
135
114
  }
136
115
 
137
116
  default_config.rpcs.get_product.timeout = 600.0
138
117
  default_config.rpcs.get_product.retry_policy = {
139
- initial_delay: 0.1,
140
- max_delay: 60.0,
141
- multiplier: 1.3,
142
- retry_codes: [4, 14]
118
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
143
119
  }
144
120
 
145
121
  default_config.rpcs.update_product.timeout = 600.0
146
122
  default_config.rpcs.update_product.retry_policy = {
147
- initial_delay: 0.1,
148
- max_delay: 60.0,
149
- multiplier: 1.3,
150
- retry_codes: [4, 14]
123
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
151
124
  }
152
125
 
153
126
  default_config.rpcs.delete_product.timeout = 600.0
154
127
  default_config.rpcs.delete_product.retry_policy = {
155
- initial_delay: 0.1,
156
- max_delay: 60.0,
157
- multiplier: 1.3,
158
- retry_codes: [4, 14]
128
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
159
129
  }
160
130
 
161
131
  default_config.rpcs.create_reference_image.timeout = 600.0
162
132
  default_config.rpcs.create_reference_image.retry_policy = {
163
- initial_delay: 0.1,
164
- max_delay: 60.0,
165
- multiplier: 1.3,
166
- retry_codes: []
133
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: []
167
134
  }
168
135
 
169
136
  default_config.rpcs.delete_reference_image.timeout = 600.0
170
137
  default_config.rpcs.delete_reference_image.retry_policy = {
171
- initial_delay: 0.1,
172
- max_delay: 60.0,
173
- multiplier: 1.3,
174
- retry_codes: [4, 14]
138
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
175
139
  }
176
140
 
177
141
  default_config.rpcs.list_reference_images.timeout = 600.0
178
142
  default_config.rpcs.list_reference_images.retry_policy = {
179
- initial_delay: 0.1,
180
- max_delay: 60.0,
181
- multiplier: 1.3,
182
- retry_codes: [4, 14]
143
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
183
144
  }
184
145
 
185
146
  default_config.rpcs.get_reference_image.timeout = 600.0
186
147
  default_config.rpcs.get_reference_image.retry_policy = {
187
- initial_delay: 0.1,
188
- max_delay: 60.0,
189
- multiplier: 1.3,
190
- retry_codes: [4, 14]
148
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
191
149
  }
192
150
 
193
151
  default_config.rpcs.add_product_to_product_set.timeout = 600.0
194
152
  default_config.rpcs.add_product_to_product_set.retry_policy = {
195
- initial_delay: 0.1,
196
- max_delay: 60.0,
197
- multiplier: 1.3,
198
- retry_codes: [4, 14]
153
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
199
154
  }
200
155
 
201
156
  default_config.rpcs.remove_product_from_product_set.timeout = 600.0
202
157
  default_config.rpcs.remove_product_from_product_set.retry_policy = {
203
- initial_delay: 0.1,
204
- max_delay: 60.0,
205
- multiplier: 1.3,
206
- retry_codes: [4, 14]
158
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
207
159
  }
208
160
 
209
161
  default_config.rpcs.list_products_in_product_set.timeout = 600.0
210
162
  default_config.rpcs.list_products_in_product_set.retry_policy = {
211
- initial_delay: 0.1,
212
- max_delay: 60.0,
213
- multiplier: 1.3,
214
- retry_codes: [4, 14]
163
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
215
164
  }
216
165
 
217
166
  default_config.rpcs.import_product_sets.timeout = 600.0
218
167
  default_config.rpcs.import_product_sets.retry_policy = {
219
- initial_delay: 0.1,
220
- max_delay: 60.0,
221
- multiplier: 1.3,
222
- retry_codes: []
168
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: []
223
169
  }
224
170
 
225
171
  default_config.rpcs.purge_products.timeout = 600.0
226
172
  default_config.rpcs.purge_products.retry_policy = {
227
- initial_delay: 0.1,
228
- max_delay: 60.0,
229
- multiplier: 1.3,
230
- retry_codes: []
173
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: []
231
174
  }
232
175
 
233
176
  default_config
@@ -291,8 +234,14 @@ module Google
291
234
 
292
235
  # Create credentials
293
236
  credentials = @config.credentials
294
- credentials ||= Credentials.default scope: @config.scope
295
- if credentials.is_a?(String) || credentials.is_a?(Hash)
237
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
238
+ # but only if the default endpoint does not have a region prefix.
239
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
240
+ @config.endpoint == Client.configure.endpoint &&
241
+ !@config.endpoint.split(".").first.include?("-")
242
+ credentials ||= Credentials.default scope: @config.scope,
243
+ enable_self_signed_jwt: enable_self_signed_jwt
244
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
296
245
  credentials = Credentials.new credentials, scope: @config.scope
297
246
  end
298
247
  @quota_project_id = @config.quota_project
@@ -505,7 +454,7 @@ module Google
505
454
  # Required. Resource name of the ProductSet to get.
506
455
  #
507
456
  # Format is:
508
- # `projects/PROJECT_ID/locations/LOG_ID/productSets/PRODUCT_SET_ID`
457
+ # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
509
458
  #
510
459
  # @yield [response, operation] Access the result along with the RPC operation
511
460
  # @yieldparam response [::Google::Cloud::Vision::V1::ProductSet]
@@ -1219,7 +1168,6 @@ module Google
1219
1168
  # Required. The resource name of the reference image to delete.
1220
1169
  #
1221
1170
  # Format is:
1222
- #
1223
1171
  # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`
1224
1172
  #
1225
1173
  # @yield [response, operation] Access the result along with the RPC operation
@@ -1376,7 +1324,6 @@ module Google
1376
1324
  # Required. The resource name of the ReferenceImage to get.
1377
1325
  #
1378
1326
  # Format is:
1379
- #
1380
1327
  # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`.
1381
1328
  #
1382
1329
  # @yield [response, operation] Access the result along with the RPC operation
@@ -1932,7 +1879,7 @@ module Google
1932
1879
  config_attr :scope, nil, ::String, ::Array, nil
1933
1880
  config_attr :lib_name, nil, ::String, nil
1934
1881
  config_attr :lib_version, nil, ::String, nil
1935
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
1882
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
1936
1883
  config_attr :interceptors, nil, ::Array, nil
1937
1884
  config_attr :timeout, nil, ::Numeric, nil
1938
1885
  config_attr :metadata, nil, ::Hash, nil
@@ -1953,7 +1900,7 @@ module Google
1953
1900
  def rpcs
1954
1901
  @rpcs ||= begin
1955
1902
  parent_rpcs = nil
1956
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
1903
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1957
1904
  Rpcs.new parent_rpcs
1958
1905
  end
1959
1906
  end
@@ -2074,43 +2021,43 @@ module Google
2074
2021
 
2075
2022
  # @private
2076
2023
  def initialize parent_rpcs = nil
2077
- create_product_set_config = parent_rpcs&.create_product_set if parent_rpcs&.respond_to? :create_product_set
2024
+ create_product_set_config = parent_rpcs.create_product_set if parent_rpcs.respond_to? :create_product_set
2078
2025
  @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
2026
+ list_product_sets_config = parent_rpcs.list_product_sets if parent_rpcs.respond_to? :list_product_sets
2080
2027
  @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
2028
+ get_product_set_config = parent_rpcs.get_product_set if parent_rpcs.respond_to? :get_product_set
2082
2029
  @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
2030
+ update_product_set_config = parent_rpcs.update_product_set if parent_rpcs.respond_to? :update_product_set
2084
2031
  @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
2032
+ delete_product_set_config = parent_rpcs.delete_product_set if parent_rpcs.respond_to? :delete_product_set
2086
2033
  @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
2034
+ create_product_config = parent_rpcs.create_product if parent_rpcs.respond_to? :create_product
2088
2035
  @create_product = ::Gapic::Config::Method.new create_product_config
2089
- list_products_config = parent_rpcs&.list_products if parent_rpcs&.respond_to? :list_products
2036
+ list_products_config = parent_rpcs.list_products if parent_rpcs.respond_to? :list_products
2090
2037
  @list_products = ::Gapic::Config::Method.new list_products_config
2091
- get_product_config = parent_rpcs&.get_product if parent_rpcs&.respond_to? :get_product
2038
+ get_product_config = parent_rpcs.get_product if parent_rpcs.respond_to? :get_product
2092
2039
  @get_product = ::Gapic::Config::Method.new get_product_config
2093
- update_product_config = parent_rpcs&.update_product if parent_rpcs&.respond_to? :update_product
2040
+ update_product_config = parent_rpcs.update_product if parent_rpcs.respond_to? :update_product
2094
2041
  @update_product = ::Gapic::Config::Method.new update_product_config
2095
- delete_product_config = parent_rpcs&.delete_product if parent_rpcs&.respond_to? :delete_product
2042
+ delete_product_config = parent_rpcs.delete_product if parent_rpcs.respond_to? :delete_product
2096
2043
  @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
2044
+ create_reference_image_config = parent_rpcs.create_reference_image if parent_rpcs.respond_to? :create_reference_image
2098
2045
  @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
2046
+ delete_reference_image_config = parent_rpcs.delete_reference_image if parent_rpcs.respond_to? :delete_reference_image
2100
2047
  @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
2048
+ list_reference_images_config = parent_rpcs.list_reference_images if parent_rpcs.respond_to? :list_reference_images
2102
2049
  @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
2050
+ get_reference_image_config = parent_rpcs.get_reference_image if parent_rpcs.respond_to? :get_reference_image
2104
2051
  @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
2052
+ add_product_to_product_set_config = parent_rpcs.add_product_to_product_set if parent_rpcs.respond_to? :add_product_to_product_set
2106
2053
  @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
2054
+ remove_product_from_product_set_config = parent_rpcs.remove_product_from_product_set if parent_rpcs.respond_to? :remove_product_from_product_set
2108
2055
  @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
2056
+ list_products_in_product_set_config = parent_rpcs.list_products_in_product_set if parent_rpcs.respond_to? :list_products_in_product_set
2110
2057
  @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
2058
+ import_product_sets_config = parent_rpcs.import_product_sets if parent_rpcs.respond_to? :import_product_sets
2112
2059
  @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
2060
+ purge_products_config = parent_rpcs.purge_products if parent_rpcs.respond_to? :purge_products
2114
2061
  @purge_products = ::Gapic::Config::Method.new purge_products_config
2115
2062
 
2116
2063
  yield self if block_given?