google-cloud-vision-v1 0.6.0 → 0.6.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cef2b749ad95a501a0d721f0fb86fe5f0c984176df38c2935b455f885bc865a
4
- data.tar.gz: 2d4decdb107d92d53eb7b90a567c2292bac09536c227e4122ec31f311dc25ee6
3
+ metadata.gz: 52910c7b44899ac515511259d2e2f8704b552366f38093ee450a5ca022c0620d
4
+ data.tar.gz: f85f6cc480ca2bd32b3f2ba3797d9425c1ff0b4641bbc113991620c882c8eefd
5
5
  SHA512:
6
- metadata.gz: 77357648c7b0183fecbcb24a516cbf6c9acb013fb8a0c54a0e236db6c8dd5b25d9aea888993ea5fd9f0c7ae4a3b1985a609f6cc6e9323fb012a8eb12427f5b07
7
- data.tar.gz: de32248085f957d85ffca1070e560ce668c07b65a8ba1189e8669e5bf23fb8d3ef9b5b4735cc574f78c2c28994015344f2b241a457a643c3d8e3b67b4a2ee622
6
+ metadata.gz: 92c418b56b69cf0ea77df5f5a7ff9f10f7910f54e01a3424efadd62001fd68516b9b0a6fd2c1d35940da1f5e6dd8ba71ec4852449f6677b90cef6b10a205431a
7
+ data.tar.gz: 3653dac03e49851aa508479463b5f6513324e7c0a8ba42970fb4260262ed75d027db497a5f341c1fc68a357c1c6f4d9ac5e63a67cc6ed1aa64fb2f460f18d9fd
data/.yardopts CHANGED
@@ -1,5 +1,5 @@
1
1
  --no-private
2
- --title=Cloud Vision V1 API
2
+ --title="Cloud Vision V1 API"
3
3
  --exclude _pb\.rb$
4
4
  --markup markdown
5
5
  --markup-provider redcarpet
data/AUTHENTICATION.md CHANGED
@@ -66,11 +66,11 @@ The environment variables that google-cloud-vision-v1
66
66
  checks for credentials are configured on the service Credentials class (such as
67
67
  {::Google::Cloud::Vision::V1::ProductSearch::Credentials}):
68
68
 
69
- 1. `VISION_CREDENTIALS` - Path to JSON file, or JSON contents
70
- 2. `VISION_KEYFILE` - Path to JSON file, or JSON contents
71
- 3. `GOOGLE_CLOUD_CREDENTIALS` - Path to JSON file, or JSON contents
72
- 4. `GOOGLE_CLOUD_KEYFILE` - Path to JSON file, or JSON contents
73
- 5. `GOOGLE_APPLICATION_CREDENTIALS` - Path to JSON file
69
+ * `VISION_CREDENTIALS` - Path to JSON file, or JSON contents
70
+ * `VISION_KEYFILE` - Path to JSON file, or JSON contents
71
+ * `GOOGLE_CLOUD_CREDENTIALS` - Path to JSON file, or JSON contents
72
+ * `GOOGLE_CLOUD_KEYFILE` - Path to JSON file, or JSON contents
73
+ * `GOOGLE_APPLICATION_CREDENTIALS` - Path to JSON file
74
74
 
75
75
  ```ruby
76
76
  require "google/cloud/vision/v1"
@@ -82,8 +82,8 @@ client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new
82
82
 
83
83
  ### Configuration
84
84
 
85
- The **Credentials JSON** can be configured instead of placing them in
86
- environment variables. Either on an individual client initialization:
85
+ The path to the **Credentials JSON** file can be configured instead of storing
86
+ it in an environment variable. Either on an individual client initialization:
87
87
 
88
88
  ```ruby
89
89
  require "google/cloud/vision/v1"
@@ -93,7 +93,7 @@ client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new do |config|
93
93
  end
94
94
  ```
95
95
 
96
- Or configured globally for all clients:
96
+ Or globally for all clients:
97
97
 
98
98
  ```ruby
99
99
  require "google/cloud/vision/v1"
@@ -120,15 +120,6 @@ To configure your system for this, simply:
120
120
  **NOTE:** This is _not_ recommended for running in production. The Cloud SDK
121
121
  *should* only be used during development.
122
122
 
123
- [gce-how-to]: https://cloud.google.com/compute/docs/authentication#using
124
- [dev-console]: https://console.cloud.google.com/project
125
-
126
- [enable-apis]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/enable-apis.png
127
-
128
- [create-new-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account.png
129
- [create-new-service-account-existing-keys]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account-existing-keys.png
130
- [reuse-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/reuse-service-account.png
131
-
132
123
  ## Creating a Service Account
133
124
 
134
125
  Google Cloud requires **Service Account Credentials** to
@@ -139,31 +130,22 @@ If you are not running this client within
139
130
  [Google Cloud Platform environments](#google-cloud-platform-environments), you
140
131
  need a Google Developers service account.
141
132
 
142
- 1. Visit the [Google Developers Console][dev-console].
133
+ 1. Visit the [Google Cloud Console](https://console.cloud.google.com/project).
143
134
  2. Create a new project or click on an existing project.
144
- 3. Activate the slide-out navigation tray and select **API Manager**. From
135
+ 3. Activate the menu in the upper left and select **APIs & Services**. From
145
136
  here, you will enable the APIs that your application requires.
146
137
 
147
- ![Enable the APIs that your application requires][enable-apis]
148
-
149
138
  *Note: You may need to enable billing in order to use these services.*
150
139
 
151
140
  4. Select **Credentials** from the side navigation.
152
141
 
153
- You should see a screen like one of the following.
154
-
155
- ![Create a new service account][create-new-service-account]
156
-
157
- ![Create a new service account With Existing Keys][create-new-service-account-existing-keys]
158
-
159
- Find the "Add credentials" drop down and select "Service account" to be
160
- guided through downloading a new JSON key file.
142
+ Find the "Create credentials" drop down near the top of the page, and select
143
+ "Service account" to be guided through downloading a new JSON key file.
161
144
 
162
145
  If you want to re-use an existing service account, you can easily generate a
163
- new key file. Just select the account you wish to re-use, and click "Generate
164
- new JSON key":
165
-
166
- ![Re-use an existing service account][reuse-service-account]
146
+ new key file. Just select the account you wish to re-use, click the pencil
147
+ tool on the right side to edit the service account, select the **Keys** tab,
148
+ and then select **Add Key**.
167
149
 
168
150
  The key file you download will be used by this library to authenticate API
169
151
  requests and should be stored in a secure location.
data/README.md CHANGED
@@ -33,7 +33,7 @@ In order to use this library, you first need to go through the following steps:
33
33
  require "google/cloud/vision/v1"
34
34
 
35
35
  client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new
36
- request = my_create_request
36
+ request = ::Google::Cloud::Vision::V1::CreateProductSetRequest.new # (request fields as keyword arguments...)
37
37
  response = client.create_product_set request
38
38
  ```
39
39
 
@@ -1,9 +1,9 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/cloud/vision/v1/geometry.proto
3
3
 
4
+ require 'google/api/annotations_pb'
4
5
  require 'google/protobuf'
5
6
 
6
- require 'google/api/annotations_pb'
7
7
  Google::Protobuf::DescriptorPool.generated_pool.build do
8
8
  add_file("google/cloud/vision/v1/geometry.proto", :syntax => :proto3) do
9
9
  add_message "google.cloud.vision.v1.Vertex" do
@@ -43,13 +43,12 @@ module Google
43
43
  # See {::Google::Cloud::Vision::V1::ImageAnnotator::Client::Configuration}
44
44
  # for a description of the configuration fields.
45
45
  #
46
- # ## Example
46
+ # @example
47
47
  #
48
- # To modify the configuration for all ImageAnnotator clients:
49
- #
50
- # ::Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
51
- # config.timeout = 10.0
52
- # end
48
+ # # Modify the configuration for all ImageAnnotator clients
49
+ # ::Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
50
+ # config.timeout = 10.0
51
+ # end
53
52
  #
54
53
  # @yield [config] Configure the Client client.
55
54
  # @yieldparam config [Client::Configuration]
@@ -69,34 +68,22 @@ module Google
69
68
 
70
69
  default_config.rpcs.batch_annotate_images.timeout = 600.0
71
70
  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]
71
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
76
72
  }
77
73
 
78
74
  default_config.rpcs.batch_annotate_files.timeout = 600.0
79
75
  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]
76
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
84
77
  }
85
78
 
86
79
  default_config.rpcs.async_batch_annotate_images.timeout = 600.0
87
80
  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]
81
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
92
82
  }
93
83
 
94
84
  default_config.rpcs.async_batch_annotate_files.timeout = 600.0
95
85
  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]
86
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
100
87
  }
101
88
 
102
89
  default_config
@@ -128,19 +115,15 @@ module Google
128
115
  ##
129
116
  # Create a new ImageAnnotator client object.
130
117
  #
131
- # ## Examples
132
- #
133
- # To create a new ImageAnnotator client with the default
134
- # configuration:
118
+ # @example
135
119
  #
136
- # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new
120
+ # # Create a client using the default configuration
121
+ # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new
137
122
  #
138
- # To create a new ImageAnnotator client with a custom
139
- # configuration:
140
- #
141
- # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new do |config|
142
- # config.timeout = 10.0
143
- # end
123
+ # # Create a client using a custom configuration
124
+ # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new do |config|
125
+ # config.timeout = 10.0
126
+ # end
144
127
  #
145
128
  # @yield [config] Configure the ImageAnnotator client.
146
129
  # @yieldparam config [Client::Configuration]
@@ -160,14 +143,13 @@ module Google
160
143
 
161
144
  # Create credentials
162
145
  credentials = @config.credentials
163
- # Use self-signed JWT if the scope and endpoint are unchanged from default,
146
+ # Use self-signed JWT if the endpoint is unchanged from default,
164
147
  # 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 &&
148
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
167
149
  !@config.endpoint.split(".").first.include?("-")
168
150
  credentials ||= Credentials.default scope: @config.scope,
169
151
  enable_self_signed_jwt: enable_self_signed_jwt
170
- if credentials.is_a?(String) || credentials.is_a?(Hash)
152
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
171
153
  credentials = Credentials.new credentials, scope: @config.scope
172
154
  end
173
155
  @quota_project_id = @config.quota_project
@@ -175,6 +157,7 @@ module Google
175
157
 
176
158
  @operations_client = Operations.new do |config|
177
159
  config.credentials = credentials
160
+ config.quota_project = @quota_project_id
178
161
  config.endpoint = @config.endpoint
179
162
  end
180
163
 
@@ -238,6 +221,21 @@ module Google
238
221
  #
239
222
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
240
223
  #
224
+ # @example Basic example
225
+ # require "google/cloud/vision/v1"
226
+ #
227
+ # # Create a client object. The client can be reused for multiple calls.
228
+ # client = Google::Cloud::Vision::V1::ImageAnnotator::Client.new
229
+ #
230
+ # # Create a request. To set request fields, pass in keyword arguments.
231
+ # request = Google::Cloud::Vision::V1::BatchAnnotateImagesRequest.new
232
+ #
233
+ # # Call the batch_annotate_images method.
234
+ # result = client.batch_annotate_images request
235
+ #
236
+ # # The returned object is of type Google::Cloud::Vision::V1::BatchAnnotateImagesResponse.
237
+ # p result
238
+ #
241
239
  def batch_annotate_images request, options = nil
242
240
  raise ::ArgumentError, "request must be provided" if request.nil?
243
241
 
@@ -258,7 +256,9 @@ module Google
258
256
  options.apply_defaults timeout: @config.rpcs.batch_annotate_images.timeout,
259
257
  metadata: metadata,
260
258
  retry_policy: @config.rpcs.batch_annotate_images.retry_policy
261
- options.apply_defaults metadata: @config.metadata,
259
+
260
+ options.apply_defaults timeout: @config.timeout,
261
+ metadata: @config.metadata,
262
262
  retry_policy: @config.retry_policy
263
263
 
264
264
  @image_annotator_stub.call_rpc :batch_annotate_images, request, options: options do |response, operation|
@@ -318,6 +318,21 @@ module Google
318
318
  #
319
319
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
320
320
  #
321
+ # @example Basic example
322
+ # require "google/cloud/vision/v1"
323
+ #
324
+ # # Create a client object. The client can be reused for multiple calls.
325
+ # client = Google::Cloud::Vision::V1::ImageAnnotator::Client.new
326
+ #
327
+ # # Create a request. To set request fields, pass in keyword arguments.
328
+ # request = Google::Cloud::Vision::V1::BatchAnnotateFilesRequest.new
329
+ #
330
+ # # Call the batch_annotate_files method.
331
+ # result = client.batch_annotate_files request
332
+ #
333
+ # # The returned object is of type Google::Cloud::Vision::V1::BatchAnnotateFilesResponse.
334
+ # p result
335
+ #
321
336
  def batch_annotate_files request, options = nil
322
337
  raise ::ArgumentError, "request must be provided" if request.nil?
323
338
 
@@ -338,7 +353,9 @@ module Google
338
353
  options.apply_defaults timeout: @config.rpcs.batch_annotate_files.timeout,
339
354
  metadata: metadata,
340
355
  retry_policy: @config.rpcs.batch_annotate_files.retry_policy
341
- options.apply_defaults metadata: @config.metadata,
356
+
357
+ options.apply_defaults timeout: @config.timeout,
358
+ metadata: @config.metadata,
342
359
  retry_policy: @config.retry_policy
343
360
 
344
361
  @image_annotator_stub.call_rpc :batch_annotate_files, request, options: options do |response, operation|
@@ -401,6 +418,28 @@ module Google
401
418
  #
402
419
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
403
420
  #
421
+ # @example Basic example
422
+ # require "google/cloud/vision/v1"
423
+ #
424
+ # # Create a client object. The client can be reused for multiple calls.
425
+ # client = Google::Cloud::Vision::V1::ImageAnnotator::Client.new
426
+ #
427
+ # # Create a request. To set request fields, pass in keyword arguments.
428
+ # request = Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesRequest.new
429
+ #
430
+ # # Call the async_batch_annotate_images method.
431
+ # result = client.async_batch_annotate_images request
432
+ #
433
+ # # The returned object is of type Gapic::Operation. You can use this
434
+ # # object to check the status of an operation, cancel it, or wait
435
+ # # for results. Here is how to block until completion:
436
+ # result.wait_until_done! timeout: 60
437
+ # if result.response?
438
+ # p result.response
439
+ # else
440
+ # puts "Error!"
441
+ # end
442
+ #
404
443
  def async_batch_annotate_images request, options = nil
405
444
  raise ::ArgumentError, "request must be provided" if request.nil?
406
445
 
@@ -421,7 +460,9 @@ module Google
421
460
  options.apply_defaults timeout: @config.rpcs.async_batch_annotate_images.timeout,
422
461
  metadata: metadata,
423
462
  retry_policy: @config.rpcs.async_batch_annotate_images.retry_policy
424
- options.apply_defaults metadata: @config.metadata,
463
+
464
+ options.apply_defaults timeout: @config.timeout,
465
+ metadata: @config.metadata,
425
466
  retry_policy: @config.retry_policy
426
467
 
427
468
  @image_annotator_stub.call_rpc :async_batch_annotate_images, request, options: options do |response, operation|
@@ -480,6 +521,28 @@ module Google
480
521
  #
481
522
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
482
523
  #
524
+ # @example Basic example
525
+ # require "google/cloud/vision/v1"
526
+ #
527
+ # # Create a client object. The client can be reused for multiple calls.
528
+ # client = Google::Cloud::Vision::V1::ImageAnnotator::Client.new
529
+ #
530
+ # # Create a request. To set request fields, pass in keyword arguments.
531
+ # request = Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesRequest.new
532
+ #
533
+ # # Call the async_batch_annotate_files method.
534
+ # result = client.async_batch_annotate_files request
535
+ #
536
+ # # The returned object is of type Gapic::Operation. You can use this
537
+ # # object to check the status of an operation, cancel it, or wait
538
+ # # for results. Here is how to block until completion:
539
+ # result.wait_until_done! timeout: 60
540
+ # if result.response?
541
+ # p result.response
542
+ # else
543
+ # puts "Error!"
544
+ # end
545
+ #
483
546
  def async_batch_annotate_files request, options = nil
484
547
  raise ::ArgumentError, "request must be provided" if request.nil?
485
548
 
@@ -500,7 +563,9 @@ module Google
500
563
  options.apply_defaults timeout: @config.rpcs.async_batch_annotate_files.timeout,
501
564
  metadata: metadata,
502
565
  retry_policy: @config.rpcs.async_batch_annotate_files.retry_policy
503
- options.apply_defaults metadata: @config.metadata,
566
+
567
+ options.apply_defaults timeout: @config.timeout,
568
+ metadata: @config.metadata,
504
569
  retry_policy: @config.retry_policy
505
570
 
506
571
  @image_annotator_stub.call_rpc :async_batch_annotate_files, request, options: options do |response, operation|
@@ -525,22 +590,21 @@ module Google
525
590
  # Configuration can be applied globally to all clients, or to a single client
526
591
  # on construction.
527
592
  #
528
- # # Examples
529
- #
530
- # To modify the global config, setting the timeout for batch_annotate_images
531
- # to 20 seconds, and all remaining timeouts to 10 seconds:
532
- #
533
- # ::Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
534
- # config.timeout = 10.0
535
- # config.rpcs.batch_annotate_images.timeout = 20.0
536
- # end
537
- #
538
- # To apply the above configuration only to a new client:
539
- #
540
- # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new do |config|
541
- # config.timeout = 10.0
542
- # config.rpcs.batch_annotate_images.timeout = 20.0
543
- # end
593
+ # @example
594
+ #
595
+ # # Modify the global config, setting the timeout for
596
+ # # batch_annotate_images to 20 seconds,
597
+ # # and all remaining timeouts to 10 seconds.
598
+ # ::Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
599
+ # config.timeout = 10.0
600
+ # config.rpcs.batch_annotate_images.timeout = 20.0
601
+ # end
602
+ #
603
+ # # Apply the above configuration only to a new client.
604
+ # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new do |config|
605
+ # config.timeout = 10.0
606
+ # config.rpcs.batch_annotate_images.timeout = 20.0
607
+ # end
544
608
  #
545
609
  # @!attribute [rw] endpoint
546
610
  # The hostname or hostname:port of the service endpoint.