google-cloud-vision-v1p4beta1 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -20
- data/lib/google/cloud/vision/v1p4beta1/image_annotator/client.rb +40 -9
- data/lib/google/cloud/vision/v1p4beta1/image_annotator/helpers.rb +0 -12
- data/lib/google/cloud/vision/v1p4beta1/image_annotator/operations.rb +25 -20
- data/lib/google/cloud/vision/v1p4beta1/image_annotator/rest/client.rb +40 -9
- data/lib/google/cloud/vision/v1p4beta1/image_annotator/rest/operations.rb +54 -42
- data/lib/google/cloud/vision/v1p4beta1/image_annotator/rest/service_stub.rb +46 -26
- data/lib/google/cloud/vision/v1p4beta1/image_annotator_services_pb.rb +1 -1
- data/lib/google/cloud/vision/v1p4beta1/product_search/client.rb +74 -39
- data/lib/google/cloud/vision/v1p4beta1/product_search/operations.rb +25 -20
- data/lib/google/cloud/vision/v1p4beta1/product_search/rest/client.rb +74 -39
- data/lib/google/cloud/vision/v1p4beta1/product_search/rest/operations.rb +54 -42
- data/lib/google/cloud/vision/v1p4beta1/product_search/rest/service_stub.rb +166 -116
- data/lib/google/cloud/vision/v1p4beta1/product_search_service_services_pb.rb +1 -1
- data/lib/google/cloud/vision/v1p4beta1/version.rb +1 -1
- data/proto_docs/google/api/client.rb +74 -10
- data/proto_docs/google/api/resource.rb +7 -2
- data/proto_docs/google/longrunning/operations.rb +19 -14
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbe5141ee1c720b8c4436d4b1cf29a8cafa39c0a403bcb876357b673bd00338c
|
4
|
+
data.tar.gz: 9f8af794bcd549e05592cec54228066793cb83ff8d51e10b46e8798bc2cb653e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eccd99882876efaca6b7c7d2aa08009561dadcc76d04556b0b3020e96e46bed21f30f7dab5115243327e26c62098d44f49eb546722acbad8220603cc7048425
|
7
|
+
data.tar.gz: 00fba5fa48d0871f05c67d2ba239858310d4cd4b762b132daddd3cb8972b9ccf5db79a94643f526c87cfe3b15ba320b027f2ec9b7ee01d5d1e6e3b8f91c5cfb4
|
data/README.md
CHANGED
@@ -43,33 +43,43 @@ for class and method documentation.
|
|
43
43
|
See also the [Product Documentation](https://cloud.google.com/vision)
|
44
44
|
for general usage information.
|
45
45
|
|
46
|
-
##
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
46
|
+
## Debug Logging
|
47
|
+
|
48
|
+
This library comes with opt-in Debug Logging that can help you troubleshoot
|
49
|
+
your application's integration with the API. When logging is activated, key
|
50
|
+
events such as requests and responses, along with data payloads and metadata
|
51
|
+
such as headers and client configuration, are logged to the standard error
|
52
|
+
stream.
|
53
|
+
|
54
|
+
**WARNING:** Client Library Debug Logging includes your data payloads in
|
55
|
+
plaintext, which could include sensitive data such as PII for yourself or your
|
56
|
+
customers, private keys, or other security data that could be compromising if
|
57
|
+
leaked. Always practice good data hygiene with your application logs, and follow
|
58
|
+
the principle of least access. Google also recommends that Client Library Debug
|
59
|
+
Logging be enabled only temporarily during active debugging, and not used
|
60
|
+
permanently in production.
|
61
|
+
|
62
|
+
To enable logging, set the environment variable `GOOGLE_SDK_RUBY_LOGGING_GEMS`
|
63
|
+
to the value `all`. Alternatively, you can set the value to a comma-delimited
|
64
|
+
list of client library gem names. This will select the default logging behavior,
|
65
|
+
which writes logs to the standard error stream. On a local workstation, this may
|
66
|
+
result in logs appearing on the console. When running on a Google Cloud hosting
|
67
|
+
service such as [Google Cloud Run](https://cloud.google.com/run), this generally
|
68
|
+
results in logs appearing alongside your application logs in the
|
69
|
+
[Google Cloud Logging](https://cloud.google.com/logging/) service.
|
70
|
+
|
71
|
+
You can customize logging by modifying the `logger` configuration when
|
72
|
+
constructing a client object. For example:
|
55
73
|
|
56
74
|
```ruby
|
75
|
+
require "google/cloud/vision/v1p4beta1"
|
57
76
|
require "logger"
|
58
77
|
|
59
|
-
|
60
|
-
|
61
|
-
def logger
|
62
|
-
LOGGER
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
67
|
-
module GRPC
|
68
|
-
extend MyLogger
|
78
|
+
client = ::Google::Cloud::Vision::V1p4beta1::ProductSearch::Client.new do |config|
|
79
|
+
config.logger = Logger.new "my-app.log"
|
69
80
|
end
|
70
81
|
```
|
71
82
|
|
72
|
-
|
73
83
|
## Google Cloud Samples
|
74
84
|
|
75
85
|
To browse ready to use code samples check [Google Cloud Samples](https://cloud.google.com/docs/samples).
|
@@ -32,6 +32,9 @@ module Google
|
|
32
32
|
# ImageAnnotator service returns detected entities from the images.
|
33
33
|
#
|
34
34
|
class Client
|
35
|
+
# @private
|
36
|
+
API_VERSION = ""
|
37
|
+
|
35
38
|
# @private
|
36
39
|
DEFAULT_ENDPOINT_TEMPLATE = "vision.$UNIVERSE_DOMAIN$"
|
37
40
|
|
@@ -183,8 +186,19 @@ module Google
|
|
183
186
|
universe_domain: @config.universe_domain,
|
184
187
|
channel_args: @config.channel_args,
|
185
188
|
interceptors: @config.interceptors,
|
186
|
-
channel_pool_config: @config.channel_pool
|
189
|
+
channel_pool_config: @config.channel_pool,
|
190
|
+
logger: @config.logger
|
187
191
|
)
|
192
|
+
|
193
|
+
@image_annotator_stub.stub_logger&.info do |entry|
|
194
|
+
entry.set_system_name
|
195
|
+
entry.set_service
|
196
|
+
entry.message = "Created client for #{entry.service}"
|
197
|
+
entry.set_credentials_fields credentials
|
198
|
+
entry.set "customEndpoint", @config.endpoint if @config.endpoint
|
199
|
+
entry.set "defaultTimeout", @config.timeout if @config.timeout
|
200
|
+
entry.set "quotaProject", @quota_project_id if @quota_project_id
|
201
|
+
end
|
188
202
|
end
|
189
203
|
|
190
204
|
##
|
@@ -194,6 +208,15 @@ module Google
|
|
194
208
|
#
|
195
209
|
attr_reader :operations_client
|
196
210
|
|
211
|
+
##
|
212
|
+
# The logger used for request/response debug logging.
|
213
|
+
#
|
214
|
+
# @return [Logger]
|
215
|
+
#
|
216
|
+
def logger
|
217
|
+
@image_annotator_stub.logger
|
218
|
+
end
|
219
|
+
|
197
220
|
# Service calls
|
198
221
|
|
199
222
|
##
|
@@ -251,10 +274,11 @@ module Google
|
|
251
274
|
# Customize the options with defaults
|
252
275
|
metadata = @config.rpcs.batch_annotate_images.metadata.to_h
|
253
276
|
|
254
|
-
# Set x-goog-api-client
|
277
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
255
278
|
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
256
279
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
257
280
|
gapic_version: ::Google::Cloud::Vision::V1p4beta1::VERSION
|
281
|
+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
258
282
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
259
283
|
|
260
284
|
options.apply_defaults timeout: @config.rpcs.batch_annotate_images.timeout,
|
@@ -267,7 +291,6 @@ module Google
|
|
267
291
|
|
268
292
|
@image_annotator_stub.call_rpc :batch_annotate_images, request, options: options do |response, operation|
|
269
293
|
yield response, operation if block_given?
|
270
|
-
return response
|
271
294
|
end
|
272
295
|
rescue ::GRPC::BadStatus => e
|
273
296
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -335,10 +358,11 @@ module Google
|
|
335
358
|
# Customize the options with defaults
|
336
359
|
metadata = @config.rpcs.batch_annotate_files.metadata.to_h
|
337
360
|
|
338
|
-
# Set x-goog-api-client
|
361
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
339
362
|
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
340
363
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
341
364
|
gapic_version: ::Google::Cloud::Vision::V1p4beta1::VERSION
|
365
|
+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
342
366
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
343
367
|
|
344
368
|
options.apply_defaults timeout: @config.rpcs.batch_annotate_files.timeout,
|
@@ -351,7 +375,6 @@ module Google
|
|
351
375
|
|
352
376
|
@image_annotator_stub.call_rpc :batch_annotate_files, request, options: options do |response, operation|
|
353
377
|
yield response, operation if block_given?
|
354
|
-
return response
|
355
378
|
end
|
356
379
|
rescue ::GRPC::BadStatus => e
|
357
380
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -429,10 +452,11 @@ module Google
|
|
429
452
|
# Customize the options with defaults
|
430
453
|
metadata = @config.rpcs.async_batch_annotate_images.metadata.to_h
|
431
454
|
|
432
|
-
# Set x-goog-api-client
|
455
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
433
456
|
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
434
457
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
435
458
|
gapic_version: ::Google::Cloud::Vision::V1p4beta1::VERSION
|
459
|
+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
436
460
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
437
461
|
|
438
462
|
options.apply_defaults timeout: @config.rpcs.async_batch_annotate_images.timeout,
|
@@ -446,7 +470,7 @@ module Google
|
|
446
470
|
@image_annotator_stub.call_rpc :async_batch_annotate_images, request, options: options do |response, operation|
|
447
471
|
response = ::Gapic::Operation.new response, @operations_client, options: options
|
448
472
|
yield response, operation if block_given?
|
449
|
-
|
473
|
+
throw :response, response
|
450
474
|
end
|
451
475
|
rescue ::GRPC::BadStatus => e
|
452
476
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -519,10 +543,11 @@ module Google
|
|
519
543
|
# Customize the options with defaults
|
520
544
|
metadata = @config.rpcs.async_batch_annotate_files.metadata.to_h
|
521
545
|
|
522
|
-
# Set x-goog-api-client
|
546
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
523
547
|
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
524
548
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
525
549
|
gapic_version: ::Google::Cloud::Vision::V1p4beta1::VERSION
|
550
|
+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
526
551
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
527
552
|
|
528
553
|
options.apply_defaults timeout: @config.rpcs.async_batch_annotate_files.timeout,
|
@@ -536,7 +561,7 @@ module Google
|
|
536
561
|
@image_annotator_stub.call_rpc :async_batch_annotate_files, request, options: options do |response, operation|
|
537
562
|
response = ::Gapic::Operation.new response, @operations_client, options: options
|
538
563
|
yield response, operation if block_given?
|
539
|
-
|
564
|
+
throw :response, response
|
540
565
|
end
|
541
566
|
rescue ::GRPC::BadStatus => e
|
542
567
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -625,6 +650,11 @@ module Google
|
|
625
650
|
# default endpoint URL. The default value of nil uses the environment
|
626
651
|
# universe (usually the default "googleapis.com" universe).
|
627
652
|
# @return [::String,nil]
|
653
|
+
# @!attribute [rw] logger
|
654
|
+
# A custom logger to use for request/response debug logging, or the value
|
655
|
+
# `:default` (the default) to construct a default logger, or `nil` to
|
656
|
+
# explicitly disable logging.
|
657
|
+
# @return [::Logger,:default,nil]
|
628
658
|
#
|
629
659
|
class Configuration
|
630
660
|
extend ::Gapic::Config
|
@@ -649,6 +679,7 @@ module Google
|
|
649
679
|
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
650
680
|
config_attr :quota_project, nil, ::String, nil
|
651
681
|
config_attr :universe_domain, nil, ::String, nil
|
682
|
+
config_attr :logger, :default, ::Logger, nil, :default
|
652
683
|
|
653
684
|
# @private
|
654
685
|
def initialize parent_config = nil
|
@@ -81,7 +81,6 @@ module Google
|
|
81
81
|
destination: nil,
|
82
82
|
image_context: nil,
|
83
83
|
&block
|
84
|
-
|
85
84
|
feature = { type: :CROP_HINTS, max_results: max_results }
|
86
85
|
images << image if image
|
87
86
|
formatted_images = images.map do |img|
|
@@ -179,7 +178,6 @@ module Google
|
|
179
178
|
destination: nil,
|
180
179
|
image_context: nil,
|
181
180
|
&block
|
182
|
-
|
183
181
|
feature = { type: :DOCUMENT_TEXT_DETECTION, max_results: max_results }
|
184
182
|
images << image if image
|
185
183
|
formatted_images = images.map do |img|
|
@@ -277,7 +275,6 @@ module Google
|
|
277
275
|
destination: nil,
|
278
276
|
image_context: nil,
|
279
277
|
&block
|
280
|
-
|
281
278
|
feature = { type: :FACE_DETECTION, max_results: max_results }
|
282
279
|
images << image if image
|
283
280
|
formatted_images = images.map do |img|
|
@@ -375,7 +372,6 @@ module Google
|
|
375
372
|
destination: nil,
|
376
373
|
image_context: nil,
|
377
374
|
&block
|
378
|
-
|
379
375
|
feature = { type: :IMAGE_PROPERTIES, max_results: max_results }
|
380
376
|
images << image if image
|
381
377
|
formatted_images = images.map do |img|
|
@@ -473,7 +469,6 @@ module Google
|
|
473
469
|
destination: nil,
|
474
470
|
image_context: nil,
|
475
471
|
&block
|
476
|
-
|
477
472
|
feature = { type: :LABEL_DETECTION, max_results: max_results }
|
478
473
|
images << image if image
|
479
474
|
formatted_images = images.map do |img|
|
@@ -571,7 +566,6 @@ module Google
|
|
571
566
|
destination: nil,
|
572
567
|
image_context: nil,
|
573
568
|
&block
|
574
|
-
|
575
569
|
feature = { type: :LANDMARK_DETECTION, max_results: max_results }
|
576
570
|
images << image if image
|
577
571
|
formatted_images = images.map do |img|
|
@@ -669,7 +663,6 @@ module Google
|
|
669
663
|
destination: nil,
|
670
664
|
image_context: nil,
|
671
665
|
&block
|
672
|
-
|
673
666
|
feature = { type: :LOGO_DETECTION, max_results: max_results }
|
674
667
|
images << image if image
|
675
668
|
formatted_images = images.map do |img|
|
@@ -767,7 +760,6 @@ module Google
|
|
767
760
|
destination: nil,
|
768
761
|
image_context: nil,
|
769
762
|
&block
|
770
|
-
|
771
763
|
feature = { type: :OBJECT_LOCALIZATION, max_results: max_results }
|
772
764
|
images << image if image
|
773
765
|
formatted_images = images.map do |img|
|
@@ -865,7 +857,6 @@ module Google
|
|
865
857
|
destination: nil,
|
866
858
|
image_context: nil,
|
867
859
|
&block
|
868
|
-
|
869
860
|
feature = { type: :PRODUCT_SEARCH, max_results: max_results }
|
870
861
|
images << image if image
|
871
862
|
formatted_images = images.map do |img|
|
@@ -963,7 +954,6 @@ module Google
|
|
963
954
|
destination: nil,
|
964
955
|
image_context: nil,
|
965
956
|
&block
|
966
|
-
|
967
957
|
feature = { type: :SAFE_SEARCH_DETECTION, max_results: max_results }
|
968
958
|
images << image if image
|
969
959
|
formatted_images = images.map do |img|
|
@@ -1061,7 +1051,6 @@ module Google
|
|
1061
1051
|
destination: nil,
|
1062
1052
|
image_context: nil,
|
1063
1053
|
&block
|
1064
|
-
|
1065
1054
|
feature = { type: :TEXT_DETECTION, max_results: max_results }
|
1066
1055
|
images << image if image
|
1067
1056
|
formatted_images = images.map do |img|
|
@@ -1159,7 +1148,6 @@ module Google
|
|
1159
1148
|
destination: nil,
|
1160
1149
|
image_context: nil,
|
1161
1150
|
&block
|
1162
|
-
|
1163
1151
|
feature = { type: :WEB_DETECTION, max_results: max_results }
|
1164
1152
|
images << image if image
|
1165
1153
|
formatted_images = images.map do |img|
|
@@ -26,6 +26,9 @@ module Google
|
|
26
26
|
module ImageAnnotator
|
27
27
|
# Service that implements Longrunning Operations API.
|
28
28
|
class Operations
|
29
|
+
# @private
|
30
|
+
API_VERSION = ""
|
31
|
+
|
29
32
|
# @private
|
30
33
|
DEFAULT_ENDPOINT_TEMPLATE = "vision.$UNIVERSE_DOMAIN$"
|
31
34
|
|
@@ -121,14 +124,6 @@ module Google
|
|
121
124
|
# Lists operations that match the specified filter in the request. If the
|
122
125
|
# server doesn't support this method, it returns `UNIMPLEMENTED`.
|
123
126
|
#
|
124
|
-
# NOTE: the `name` binding allows API services to override the binding
|
125
|
-
# to use different resource name schemes, such as `users/*/operations`. To
|
126
|
-
# override the binding, API services can add a binding such as
|
127
|
-
# `"/v1/{name=users/*}/operations"` to their service configuration.
|
128
|
-
# For backwards compatibility, the default name includes the operations
|
129
|
-
# collection id, however overriding users must ensure the name binding
|
130
|
-
# is the parent resource, without the operations collection id.
|
131
|
-
#
|
132
127
|
# @overload list_operations(request, options = nil)
|
133
128
|
# Pass arguments to `list_operations` via a request object, either of type
|
134
129
|
# {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
|
@@ -191,10 +186,11 @@ module Google
|
|
191
186
|
# Customize the options with defaults
|
192
187
|
metadata = @config.rpcs.list_operations.metadata.to_h
|
193
188
|
|
194
|
-
# Set x-goog-api-client
|
189
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
195
190
|
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
196
191
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
197
192
|
gapic_version: ::Google::Cloud::Vision::V1p4beta1::VERSION
|
193
|
+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
198
194
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
199
195
|
|
200
196
|
header_params = {}
|
@@ -217,7 +213,7 @@ module Google
|
|
217
213
|
wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, @operations_client }
|
218
214
|
response = ::Gapic::PagedEnumerable.new @operations_stub, :list_operations, request, response, operation, options, format_resource: wrap_lro_operation
|
219
215
|
yield response, operation if block_given?
|
220
|
-
|
216
|
+
throw :response, response
|
221
217
|
end
|
222
218
|
rescue ::GRPC::BadStatus => e
|
223
219
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -287,10 +283,11 @@ module Google
|
|
287
283
|
# Customize the options with defaults
|
288
284
|
metadata = @config.rpcs.get_operation.metadata.to_h
|
289
285
|
|
290
|
-
# Set x-goog-api-client
|
286
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
291
287
|
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
292
288
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
293
289
|
gapic_version: ::Google::Cloud::Vision::V1p4beta1::VERSION
|
290
|
+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
294
291
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
295
292
|
|
296
293
|
header_params = {}
|
@@ -312,7 +309,7 @@ module Google
|
|
312
309
|
@operations_stub.call_rpc :get_operation, request, options: options do |response, operation|
|
313
310
|
response = ::Gapic::Operation.new response, @operations_client, options: options
|
314
311
|
yield response, operation if block_given?
|
315
|
-
|
312
|
+
throw :response, response
|
316
313
|
end
|
317
314
|
rescue ::GRPC::BadStatus => e
|
318
315
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -376,10 +373,11 @@ module Google
|
|
376
373
|
# Customize the options with defaults
|
377
374
|
metadata = @config.rpcs.delete_operation.metadata.to_h
|
378
375
|
|
379
|
-
# Set x-goog-api-client
|
376
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
380
377
|
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
381
378
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
382
379
|
gapic_version: ::Google::Cloud::Vision::V1p4beta1::VERSION
|
380
|
+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
383
381
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
384
382
|
|
385
383
|
header_params = {}
|
@@ -400,7 +398,6 @@ module Google
|
|
400
398
|
|
401
399
|
@operations_stub.call_rpc :delete_operation, request, options: options do |response, operation|
|
402
400
|
yield response, operation if block_given?
|
403
|
-
return response
|
404
401
|
end
|
405
402
|
rescue ::GRPC::BadStatus => e
|
406
403
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -415,8 +412,9 @@ module Google
|
|
415
412
|
# other methods to check whether the cancellation succeeded or whether the
|
416
413
|
# operation completed despite cancellation. On successful cancellation,
|
417
414
|
# the operation is not deleted; instead, it becomes an operation with
|
418
|
-
# an {::Google::Longrunning::Operation#error Operation.error} value with a
|
419
|
-
# corresponding to
|
415
|
+
# an {::Google::Longrunning::Operation#error Operation.error} value with a
|
416
|
+
# {::Google::Rpc::Status#code google.rpc.Status.code} of `1`, corresponding to
|
417
|
+
# `Code.CANCELLED`.
|
420
418
|
#
|
421
419
|
# @overload cancel_operation(request, options = nil)
|
422
420
|
# Pass arguments to `cancel_operation` via a request object, either of type
|
@@ -470,10 +468,11 @@ module Google
|
|
470
468
|
# Customize the options with defaults
|
471
469
|
metadata = @config.rpcs.cancel_operation.metadata.to_h
|
472
470
|
|
473
|
-
# Set x-goog-api-client
|
471
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
474
472
|
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
475
473
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
476
474
|
gapic_version: ::Google::Cloud::Vision::V1p4beta1::VERSION
|
475
|
+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
477
476
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
478
477
|
|
479
478
|
header_params = {}
|
@@ -494,7 +493,6 @@ module Google
|
|
494
493
|
|
495
494
|
@operations_stub.call_rpc :cancel_operation, request, options: options do |response, operation|
|
496
495
|
yield response, operation if block_given?
|
497
|
-
return response
|
498
496
|
end
|
499
497
|
rescue ::GRPC::BadStatus => e
|
500
498
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -574,10 +572,11 @@ module Google
|
|
574
572
|
# Customize the options with defaults
|
575
573
|
metadata = @config.rpcs.wait_operation.metadata.to_h
|
576
574
|
|
577
|
-
# Set x-goog-api-client
|
575
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
578
576
|
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
579
577
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
580
578
|
gapic_version: ::Google::Cloud::Vision::V1p4beta1::VERSION
|
579
|
+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
581
580
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
582
581
|
|
583
582
|
options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
|
@@ -591,7 +590,7 @@ module Google
|
|
591
590
|
@operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
|
592
591
|
response = ::Gapic::Operation.new response, @operations_client, options: options
|
593
592
|
yield response, operation if block_given?
|
594
|
-
|
593
|
+
throw :response, response
|
595
594
|
end
|
596
595
|
rescue ::GRPC::BadStatus => e
|
597
596
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -680,6 +679,11 @@ module Google
|
|
680
679
|
# default endpoint URL. The default value of nil uses the environment
|
681
680
|
# universe (usually the default "googleapis.com" universe).
|
682
681
|
# @return [::String,nil]
|
682
|
+
# @!attribute [rw] logger
|
683
|
+
# A custom logger to use for request/response debug logging, or the value
|
684
|
+
# `:default` (the default) to construct a default logger, or `nil` to
|
685
|
+
# explicitly disable logging.
|
686
|
+
# @return [::Logger,:default,nil]
|
683
687
|
#
|
684
688
|
class Configuration
|
685
689
|
extend ::Gapic::Config
|
@@ -704,6 +708,7 @@ module Google
|
|
704
708
|
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
705
709
|
config_attr :quota_project, nil, ::String, nil
|
706
710
|
config_attr :universe_domain, nil, ::String, nil
|
711
|
+
config_attr :logger, :default, ::Logger, nil, :default
|
707
712
|
|
708
713
|
# @private
|
709
714
|
def initialize parent_config = nil
|
@@ -34,6 +34,9 @@ module Google
|
|
34
34
|
# ImageAnnotator service returns detected entities from the images.
|
35
35
|
#
|
36
36
|
class Client
|
37
|
+
# @private
|
38
|
+
API_VERSION = ""
|
39
|
+
|
37
40
|
# @private
|
38
41
|
DEFAULT_ENDPOINT_TEMPLATE = "vision.$UNIVERSE_DOMAIN$"
|
39
42
|
|
@@ -176,8 +179,19 @@ module Google
|
|
176
179
|
endpoint: @config.endpoint,
|
177
180
|
endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
|
178
181
|
universe_domain: @config.universe_domain,
|
179
|
-
credentials: credentials
|
182
|
+
credentials: credentials,
|
183
|
+
logger: @config.logger
|
180
184
|
)
|
185
|
+
|
186
|
+
@image_annotator_stub.logger(stub: true)&.info do |entry|
|
187
|
+
entry.set_system_name
|
188
|
+
entry.set_service
|
189
|
+
entry.message = "Created client for #{entry.service}"
|
190
|
+
entry.set_credentials_fields credentials
|
191
|
+
entry.set "customEndpoint", @config.endpoint if @config.endpoint
|
192
|
+
entry.set "defaultTimeout", @config.timeout if @config.timeout
|
193
|
+
entry.set "quotaProject", @quota_project_id if @quota_project_id
|
194
|
+
end
|
181
195
|
end
|
182
196
|
|
183
197
|
##
|
@@ -187,6 +201,15 @@ module Google
|
|
187
201
|
#
|
188
202
|
attr_reader :operations_client
|
189
203
|
|
204
|
+
##
|
205
|
+
# The logger used for request/response debug logging.
|
206
|
+
#
|
207
|
+
# @return [Logger]
|
208
|
+
#
|
209
|
+
def logger
|
210
|
+
@image_annotator_stub.logger
|
211
|
+
end
|
212
|
+
|
190
213
|
# Service calls
|
191
214
|
|
192
215
|
##
|
@@ -243,12 +266,13 @@ module Google
|
|
243
266
|
# Customize the options with defaults
|
244
267
|
call_metadata = @config.rpcs.batch_annotate_images.metadata.to_h
|
245
268
|
|
246
|
-
# Set x-goog-api-client
|
269
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
247
270
|
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
248
271
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
249
272
|
gapic_version: ::Google::Cloud::Vision::V1p4beta1::VERSION,
|
250
273
|
transports_version_send: [:rest]
|
251
274
|
|
275
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
252
276
|
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
253
277
|
|
254
278
|
options.apply_defaults timeout: @config.rpcs.batch_annotate_images.timeout,
|
@@ -261,7 +285,6 @@ module Google
|
|
261
285
|
|
262
286
|
@image_annotator_stub.batch_annotate_images request, options do |result, operation|
|
263
287
|
yield result, operation if block_given?
|
264
|
-
return result
|
265
288
|
end
|
266
289
|
rescue ::Gapic::Rest::Error => e
|
267
290
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -328,12 +351,13 @@ module Google
|
|
328
351
|
# Customize the options with defaults
|
329
352
|
call_metadata = @config.rpcs.batch_annotate_files.metadata.to_h
|
330
353
|
|
331
|
-
# Set x-goog-api-client
|
354
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
332
355
|
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
333
356
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
334
357
|
gapic_version: ::Google::Cloud::Vision::V1p4beta1::VERSION,
|
335
358
|
transports_version_send: [:rest]
|
336
359
|
|
360
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
337
361
|
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
338
362
|
|
339
363
|
options.apply_defaults timeout: @config.rpcs.batch_annotate_files.timeout,
|
@@ -346,7 +370,6 @@ module Google
|
|
346
370
|
|
347
371
|
@image_annotator_stub.batch_annotate_files request, options do |result, operation|
|
348
372
|
yield result, operation if block_given?
|
349
|
-
return result
|
350
373
|
end
|
351
374
|
rescue ::Gapic::Rest::Error => e
|
352
375
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -423,12 +446,13 @@ module Google
|
|
423
446
|
# Customize the options with defaults
|
424
447
|
call_metadata = @config.rpcs.async_batch_annotate_images.metadata.to_h
|
425
448
|
|
426
|
-
# Set x-goog-api-client
|
449
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
427
450
|
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
428
451
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
429
452
|
gapic_version: ::Google::Cloud::Vision::V1p4beta1::VERSION,
|
430
453
|
transports_version_send: [:rest]
|
431
454
|
|
455
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
432
456
|
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
433
457
|
|
434
458
|
options.apply_defaults timeout: @config.rpcs.async_batch_annotate_images.timeout,
|
@@ -442,7 +466,7 @@ module Google
|
|
442
466
|
@image_annotator_stub.async_batch_annotate_images request, options do |result, operation|
|
443
467
|
result = ::Gapic::Operation.new result, @operations_client, options: options
|
444
468
|
yield result, operation if block_given?
|
445
|
-
|
469
|
+
throw :response, result
|
446
470
|
end
|
447
471
|
rescue ::Gapic::Rest::Error => e
|
448
472
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -514,12 +538,13 @@ module Google
|
|
514
538
|
# Customize the options with defaults
|
515
539
|
call_metadata = @config.rpcs.async_batch_annotate_files.metadata.to_h
|
516
540
|
|
517
|
-
# Set x-goog-api-client
|
541
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
518
542
|
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
519
543
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
520
544
|
gapic_version: ::Google::Cloud::Vision::V1p4beta1::VERSION,
|
521
545
|
transports_version_send: [:rest]
|
522
546
|
|
547
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
523
548
|
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
524
549
|
|
525
550
|
options.apply_defaults timeout: @config.rpcs.async_batch_annotate_files.timeout,
|
@@ -533,7 +558,7 @@ module Google
|
|
533
558
|
@image_annotator_stub.async_batch_annotate_files request, options do |result, operation|
|
534
559
|
result = ::Gapic::Operation.new result, @operations_client, options: options
|
535
560
|
yield result, operation if block_given?
|
536
|
-
|
561
|
+
throw :response, result
|
537
562
|
end
|
538
563
|
rescue ::Gapic::Rest::Error => e
|
539
564
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -613,6 +638,11 @@ module Google
|
|
613
638
|
# default endpoint URL. The default value of nil uses the environment
|
614
639
|
# universe (usually the default "googleapis.com" universe).
|
615
640
|
# @return [::String,nil]
|
641
|
+
# @!attribute [rw] logger
|
642
|
+
# A custom logger to use for request/response debug logging, or the value
|
643
|
+
# `:default` (the default) to construct a default logger, or `nil` to
|
644
|
+
# explicitly disable logging.
|
645
|
+
# @return [::Logger,:default,nil]
|
616
646
|
#
|
617
647
|
class Configuration
|
618
648
|
extend ::Gapic::Config
|
@@ -634,6 +664,7 @@ module Google
|
|
634
664
|
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
635
665
|
config_attr :quota_project, nil, ::String, nil
|
636
666
|
config_attr :universe_domain, nil, ::String, nil
|
667
|
+
config_attr :logger, :default, ::Logger, nil, :default
|
637
668
|
|
638
669
|
# @private
|
639
670
|
def initialize parent_config = nil
|