google-cloud-automl-v1 0.4.1 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +8 -8
  3. data/README.md +1 -1
  4. data/lib/google/cloud/automl/v1/annotation_payload_pb.rb +2 -2
  5. data/lib/google/cloud/automl/v1/annotation_spec_pb.rb +2 -2
  6. data/lib/google/cloud/automl/v1/automl/client.rb +539 -149
  7. data/lib/google/cloud/automl/v1/automl/operations.rb +149 -37
  8. data/lib/google/cloud/automl/v1/classification_pb.rb +1 -1
  9. data/lib/google/cloud/automl/v1/data_items_pb.rb +2 -2
  10. data/lib/google/cloud/automl/v1/dataset_pb.rb +2 -2
  11. data/lib/google/cloud/automl/v1/detection_pb.rb +2 -2
  12. data/lib/google/cloud/automl/v1/geometry_pb.rb +1 -1
  13. data/lib/google/cloud/automl/v1/image_pb.rb +2 -2
  14. data/lib/google/cloud/automl/v1/io_pb.rb +2 -2
  15. data/lib/google/cloud/automl/v1/model_evaluation_pb.rb +2 -2
  16. data/lib/google/cloud/automl/v1/model_pb.rb +2 -2
  17. data/lib/google/cloud/automl/v1/operations_pb.rb +2 -2
  18. data/lib/google/cloud/automl/v1/prediction_service/client.rb +83 -45
  19. data/lib/google/cloud/automl/v1/prediction_service/operations.rb +149 -37
  20. data/lib/google/cloud/automl/v1/prediction_service_pb.rb +2 -2
  21. data/lib/google/cloud/automl/v1/service_pb.rb +2 -2
  22. data/lib/google/cloud/automl/v1/text_extraction_pb.rb +2 -2
  23. data/lib/google/cloud/automl/v1/text_pb.rb +2 -2
  24. data/lib/google/cloud/automl/v1/text_segment_pb.rb +1 -1
  25. data/lib/google/cloud/automl/v1/text_sentiment_pb.rb +2 -2
  26. data/lib/google/cloud/automl/v1/translation_pb.rb +2 -2
  27. data/lib/google/cloud/automl/v1/version.rb +1 -1
  28. data/proto_docs/google/api/field_behavior.rb +7 -1
  29. data/proto_docs/google/cloud/automl/v1/service.rb +5 -4
  30. metadata +4 -4
@@ -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
@@ -143,6 +143,27 @@ module Google
143
143
  #
144
144
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
145
145
  #
146
+ # @example Basic example
147
+ # require "google/longrunning"
148
+ #
149
+ # # Create a client object. The client can be reused for multiple calls.
150
+ # client = Google::Longrunning::Operations::Client.new
151
+ #
152
+ # # Create a request. To set request fields, pass in keyword arguments.
153
+ # request = Google::Longrunning::ListOperationsRequest.new
154
+ #
155
+ # # Call the list_operations method.
156
+ # result = client.list_operations request
157
+ #
158
+ # # The returned object is of type Gapic::PagedEnumerable. You can
159
+ # # iterate over all elements by calling #each, and the enumerable
160
+ # # will lazily make API calls to fetch subsequent pages. Other
161
+ # # methods are also available for managing paging directly.
162
+ # result.each do |response|
163
+ # # Each element is of type ::Google::Longrunning::Operation.
164
+ # p response
165
+ # end
166
+ #
146
167
  def list_operations request, options = nil
147
168
  raise ::ArgumentError, "request must be provided" if request.nil?
148
169
 
@@ -160,16 +181,20 @@ module Google
160
181
  gapic_version: ::Google::Cloud::AutoML::V1::VERSION
161
182
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
162
183
 
163
- header_params = {
164
- "name" => request.name
165
- }
184
+ header_params = {}
185
+ if request.name
186
+ header_params["name"] = request.name
187
+ end
188
+
166
189
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
167
190
  metadata[:"x-goog-request-params"] ||= request_params_header
168
191
 
169
192
  options.apply_defaults timeout: @config.rpcs.list_operations.timeout,
170
193
  metadata: metadata,
171
194
  retry_policy: @config.rpcs.list_operations.retry_policy
172
- options.apply_defaults metadata: @config.metadata,
195
+
196
+ options.apply_defaults timeout: @config.timeout,
197
+ metadata: @config.metadata,
173
198
  retry_policy: @config.retry_policy
174
199
 
175
200
  @operations_stub.call_rpc :list_operations, request, options: options do |response, operation|
@@ -213,6 +238,28 @@ module Google
213
238
  #
214
239
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
215
240
  #
241
+ # @example Basic example
242
+ # require "google/longrunning"
243
+ #
244
+ # # Create a client object. The client can be reused for multiple calls.
245
+ # client = Google::Longrunning::Operations::Client.new
246
+ #
247
+ # # Create a request. To set request fields, pass in keyword arguments.
248
+ # request = Google::Longrunning::GetOperationRequest.new
249
+ #
250
+ # # Call the get_operation method.
251
+ # result = client.get_operation request
252
+ #
253
+ # # The returned object is of type Gapic::Operation. You can use this
254
+ # # object to check the status of an operation, cancel it, or wait
255
+ # # for results. Here is how to block until completion:
256
+ # result.wait_until_done! timeout: 60
257
+ # if result.response?
258
+ # p result.response
259
+ # else
260
+ # puts "Error!"
261
+ # end
262
+ #
216
263
  def get_operation request, options = nil
217
264
  raise ::ArgumentError, "request must be provided" if request.nil?
218
265
 
@@ -230,16 +277,20 @@ module Google
230
277
  gapic_version: ::Google::Cloud::AutoML::V1::VERSION
231
278
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
232
279
 
233
- header_params = {
234
- "name" => request.name
235
- }
280
+ header_params = {}
281
+ if request.name
282
+ header_params["name"] = request.name
283
+ end
284
+
236
285
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
237
286
  metadata[:"x-goog-request-params"] ||= request_params_header
238
287
 
239
288
  options.apply_defaults timeout: @config.rpcs.get_operation.timeout,
240
289
  metadata: metadata,
241
290
  retry_policy: @config.rpcs.get_operation.retry_policy
242
- options.apply_defaults metadata: @config.metadata,
291
+
292
+ options.apply_defaults timeout: @config.timeout,
293
+ metadata: @config.metadata,
243
294
  retry_policy: @config.retry_policy
244
295
 
245
296
  @operations_stub.call_rpc :get_operation, request, options: options do |response, operation|
@@ -283,6 +334,21 @@ module Google
283
334
  #
284
335
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
285
336
  #
337
+ # @example Basic example
338
+ # require "google/longrunning"
339
+ #
340
+ # # Create a client object. The client can be reused for multiple calls.
341
+ # client = Google::Longrunning::Operations::Client.new
342
+ #
343
+ # # Create a request. To set request fields, pass in keyword arguments.
344
+ # request = Google::Longrunning::DeleteOperationRequest.new
345
+ #
346
+ # # Call the delete_operation method.
347
+ # result = client.delete_operation request
348
+ #
349
+ # # The returned object is of type Google::Protobuf::Empty.
350
+ # p result
351
+ #
286
352
  def delete_operation request, options = nil
287
353
  raise ::ArgumentError, "request must be provided" if request.nil?
288
354
 
@@ -300,16 +366,20 @@ module Google
300
366
  gapic_version: ::Google::Cloud::AutoML::V1::VERSION
301
367
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
302
368
 
303
- header_params = {
304
- "name" => request.name
305
- }
369
+ header_params = {}
370
+ if request.name
371
+ header_params["name"] = request.name
372
+ end
373
+
306
374
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
307
375
  metadata[:"x-goog-request-params"] ||= request_params_header
308
376
 
309
377
  options.apply_defaults timeout: @config.rpcs.delete_operation.timeout,
310
378
  metadata: metadata,
311
379
  retry_policy: @config.rpcs.delete_operation.retry_policy
312
- options.apply_defaults metadata: @config.metadata,
380
+
381
+ options.apply_defaults timeout: @config.timeout,
382
+ metadata: @config.metadata,
313
383
  retry_policy: @config.retry_policy
314
384
 
315
385
  @operations_stub.call_rpc :delete_operation, request, options: options do |response, operation|
@@ -358,6 +428,21 @@ module Google
358
428
  #
359
429
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
360
430
  #
431
+ # @example Basic example
432
+ # require "google/longrunning"
433
+ #
434
+ # # Create a client object. The client can be reused for multiple calls.
435
+ # client = Google::Longrunning::Operations::Client.new
436
+ #
437
+ # # Create a request. To set request fields, pass in keyword arguments.
438
+ # request = Google::Longrunning::CancelOperationRequest.new
439
+ #
440
+ # # Call the cancel_operation method.
441
+ # result = client.cancel_operation request
442
+ #
443
+ # # The returned object is of type Google::Protobuf::Empty.
444
+ # p result
445
+ #
361
446
  def cancel_operation request, options = nil
362
447
  raise ::ArgumentError, "request must be provided" if request.nil?
363
448
 
@@ -375,16 +460,20 @@ module Google
375
460
  gapic_version: ::Google::Cloud::AutoML::V1::VERSION
376
461
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
377
462
 
378
- header_params = {
379
- "name" => request.name
380
- }
463
+ header_params = {}
464
+ if request.name
465
+ header_params["name"] = request.name
466
+ end
467
+
381
468
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
382
469
  metadata[:"x-goog-request-params"] ||= request_params_header
383
470
 
384
471
  options.apply_defaults timeout: @config.rpcs.cancel_operation.timeout,
385
472
  metadata: metadata,
386
473
  retry_policy: @config.rpcs.cancel_operation.retry_policy
387
- options.apply_defaults metadata: @config.metadata,
474
+
475
+ options.apply_defaults timeout: @config.timeout,
476
+ metadata: @config.metadata,
388
477
  retry_policy: @config.retry_policy
389
478
 
390
479
  @operations_stub.call_rpc :cancel_operation, request, options: options do |response, operation|
@@ -396,9 +485,9 @@ module Google
396
485
  end
397
486
 
398
487
  ##
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
488
+ # Waits until the specified long-running operation is done or reaches at most
489
+ # a specified timeout, returning the latest state. If the operation is
490
+ # already done, the latest state is immediately returned. If the timeout
402
491
  # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
403
492
  # timeout is used. If the server does not support this method, it returns
404
493
  # `google.rpc.Code.UNIMPLEMENTED`.
@@ -436,6 +525,28 @@ module Google
436
525
  #
437
526
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
438
527
  #
528
+ # @example Basic example
529
+ # require "google/longrunning"
530
+ #
531
+ # # Create a client object. The client can be reused for multiple calls.
532
+ # client = Google::Longrunning::Operations::Client.new
533
+ #
534
+ # # Create a request. To set request fields, pass in keyword arguments.
535
+ # request = Google::Longrunning::WaitOperationRequest.new
536
+ #
537
+ # # Call the wait_operation method.
538
+ # result = client.wait_operation request
539
+ #
540
+ # # The returned object is of type Gapic::Operation. You can use this
541
+ # # object to check the status of an operation, cancel it, or wait
542
+ # # for results. Here is how to block until completion:
543
+ # result.wait_until_done! timeout: 60
544
+ # if result.response?
545
+ # p result.response
546
+ # else
547
+ # puts "Error!"
548
+ # end
549
+ #
439
550
  def wait_operation request, options = nil
440
551
  raise ::ArgumentError, "request must be provided" if request.nil?
441
552
 
@@ -456,7 +567,9 @@ module Google
456
567
  options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
457
568
  metadata: metadata,
458
569
  retry_policy: @config.rpcs.wait_operation.retry_policy
459
- options.apply_defaults metadata: @config.metadata,
570
+
571
+ options.apply_defaults timeout: @config.timeout,
572
+ metadata: @config.metadata,
460
573
  retry_policy: @config.retry_policy
461
574
 
462
575
  @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
@@ -481,22 +594,21 @@ module Google
481
594
  # Configuration can be applied globally to all clients, or to a single client
482
595
  # on construction.
483
596
  #
484
- # # Examples
485
- #
486
- # To modify the global config, setting the timeout for list_operations
487
- # to 20 seconds, and all remaining timeouts to 10 seconds:
488
- #
489
- # ::Google::Longrunning::Operations::Client.configure do |config|
490
- # config.timeout = 10.0
491
- # config.rpcs.list_operations.timeout = 20.0
492
- # end
493
- #
494
- # To apply the above configuration only to a new client:
495
- #
496
- # client = ::Google::Longrunning::Operations::Client.new do |config|
497
- # config.timeout = 10.0
498
- # config.rpcs.list_operations.timeout = 20.0
499
- # end
597
+ # @example
598
+ #
599
+ # # Modify the global config, setting the timeout for
600
+ # # list_operations to 20 seconds,
601
+ # # and all remaining timeouts to 10 seconds.
602
+ # ::Google::Longrunning::Operations::Client.configure do |config|
603
+ # config.timeout = 10.0
604
+ # config.rpcs.list_operations.timeout = 20.0
605
+ # end
606
+ #
607
+ # # Apply the above configuration only to a new client.
608
+ # client = ::Google::Longrunning::Operations::Client.new do |config|
609
+ # config.timeout = 10.0
610
+ # config.rpcs.list_operations.timeout = 20.0
611
+ # end
500
612
  #
501
613
  # @!attribute [rw] endpoint
502
614
  # The hostname or hostname:port of the service endpoint.
@@ -1,9 +1,9 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/cloud/automl/v1/classification.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/automl/v1/classification.proto", :syntax => :proto3) do
9
9
  add_message "google.cloud.automl.v1.ClassificationAnnotation" do
@@ -1,8 +1,6 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/cloud/automl/v1/data_items.proto
3
3
 
4
- require 'google/protobuf'
5
-
6
4
  require 'google/cloud/automl/v1/geometry_pb'
7
5
  require 'google/cloud/automl/v1/io_pb'
8
6
  require 'google/cloud/automl/v1/text_segment_pb'
@@ -10,6 +8,8 @@ require 'google/protobuf/any_pb'
10
8
  require 'google/protobuf/duration_pb'
11
9
  require 'google/protobuf/struct_pb'
12
10
  require 'google/api/annotations_pb'
11
+ require 'google/protobuf'
12
+
13
13
  Google::Protobuf::DescriptorPool.generated_pool.build do
14
14
  add_file("google/cloud/automl/v1/data_items.proto", :syntax => :proto3) do
15
15
  add_message "google.cloud.automl.v1.Image" do
@@ -1,14 +1,14 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/cloud/automl/v1/dataset.proto
3
3
 
4
- require 'google/protobuf'
5
-
6
4
  require 'google/api/resource_pb'
7
5
  require 'google/cloud/automl/v1/image_pb'
8
6
  require 'google/cloud/automl/v1/text_pb'
9
7
  require 'google/cloud/automl/v1/translation_pb'
10
8
  require 'google/protobuf/timestamp_pb'
11
9
  require 'google/api/annotations_pb'
10
+ require 'google/protobuf'
11
+
12
12
  Google::Protobuf::DescriptorPool.generated_pool.build do
13
13
  add_file("google/cloud/automl/v1/dataset.proto", :syntax => :proto3) do
14
14
  add_message "google.cloud.automl.v1.Dataset" do
@@ -1,11 +1,11 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/cloud/automl/v1/detection.proto
3
3
 
4
- require 'google/protobuf'
5
-
6
4
  require 'google/cloud/automl/v1/geometry_pb'
7
5
  require 'google/protobuf/duration_pb'
8
6
  require 'google/api/annotations_pb'
7
+ require 'google/protobuf'
8
+
9
9
  Google::Protobuf::DescriptorPool.generated_pool.build do
10
10
  add_file("google/cloud/automl/v1/detection.proto", :syntax => :proto3) do
11
11
  add_message "google.cloud.automl.v1.ImageObjectDetectionAnnotation" do
@@ -1,9 +1,9 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/cloud/automl/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/automl/v1/geometry.proto", :syntax => :proto3) do
9
9
  add_message "google.cloud.automl.v1.NormalizedVertex" do
@@ -1,13 +1,13 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/cloud/automl/v1/image.proto
3
3
 
4
- require 'google/protobuf'
5
-
6
4
  require 'google/api/resource_pb'
7
5
  require 'google/cloud/automl/v1/annotation_spec_pb'
8
6
  require 'google/cloud/automl/v1/classification_pb'
9
7
  require 'google/protobuf/timestamp_pb'
10
8
  require 'google/api/annotations_pb'
9
+ require 'google/protobuf'
10
+
11
11
  Google::Protobuf::DescriptorPool.generated_pool.build do
12
12
  add_file("google/cloud/automl/v1/image.proto", :syntax => :proto3) do
13
13
  add_message "google.cloud.automl.v1.ImageClassificationDatasetMetadata" do
@@ -1,10 +1,10 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/cloud/automl/v1/io.proto
3
3
 
4
- require 'google/protobuf'
5
-
6
4
  require 'google/api/field_behavior_pb'
7
5
  require 'google/api/annotations_pb'
6
+ require 'google/protobuf'
7
+
8
8
  Google::Protobuf::DescriptorPool.generated_pool.build do
9
9
  add_file("google/cloud/automl/v1/io.proto", :syntax => :proto3) do
10
10
  add_message "google.cloud.automl.v1.InputConfig" do
@@ -1,8 +1,6 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/cloud/automl/v1/model_evaluation.proto
3
3
 
4
- require 'google/protobuf'
5
-
6
4
  require 'google/api/resource_pb'
7
5
  require 'google/cloud/automl/v1/classification_pb'
8
6
  require 'google/cloud/automl/v1/detection_pb'
@@ -11,6 +9,8 @@ require 'google/cloud/automl/v1/text_sentiment_pb'
11
9
  require 'google/cloud/automl/v1/translation_pb'
12
10
  require 'google/protobuf/timestamp_pb'
13
11
  require 'google/api/annotations_pb'
12
+ require 'google/protobuf'
13
+
14
14
  Google::Protobuf::DescriptorPool.generated_pool.build do
15
15
  add_file("google/cloud/automl/v1/model_evaluation.proto", :syntax => :proto3) do
16
16
  add_message "google.cloud.automl.v1.ModelEvaluation" do
@@ -1,14 +1,14 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/cloud/automl/v1/model.proto
3
3
 
4
- require 'google/protobuf'
5
-
6
4
  require 'google/api/resource_pb'
7
5
  require 'google/cloud/automl/v1/image_pb'
8
6
  require 'google/cloud/automl/v1/text_pb'
9
7
  require 'google/cloud/automl/v1/translation_pb'
10
8
  require 'google/protobuf/timestamp_pb'
11
9
  require 'google/api/annotations_pb'
10
+ require 'google/protobuf'
11
+
12
12
  Google::Protobuf::DescriptorPool.generated_pool.build do
13
13
  add_file("google/cloud/automl/v1/model.proto", :syntax => :proto3) do
14
14
  add_message "google.cloud.automl.v1.Model" do
@@ -1,13 +1,13 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/cloud/automl/v1/operations.proto
3
3
 
4
- require 'google/protobuf'
5
-
6
4
  require 'google/cloud/automl/v1/dataset_pb'
7
5
  require 'google/cloud/automl/v1/io_pb'
8
6
  require 'google/protobuf/timestamp_pb'
9
7
  require 'google/rpc/status_pb'
10
8
  require 'google/api/annotations_pb'
9
+ require 'google/protobuf'
10
+
11
11
  Google::Protobuf::DescriptorPool.generated_pool.build do
12
12
  add_file("google/cloud/automl/v1/operations.proto", :syntax => :proto3) do
13
13
  add_message "google.cloud.automl.v1.OperationMetadata" do
@@ -44,13 +44,12 @@ module Google
44
44
  # See {::Google::Cloud::AutoML::V1::PredictionService::Client::Configuration}
45
45
  # for a description of the configuration fields.
46
46
  #
47
- # ## Example
47
+ # @example
48
48
  #
49
- # To modify the configuration for all PredictionService clients:
50
- #
51
- # ::Google::Cloud::AutoML::V1::PredictionService::Client.configure do |config|
52
- # config.timeout = 10.0
53
- # end
49
+ # # Modify the configuration for all PredictionService clients
50
+ # ::Google::Cloud::AutoML::V1::PredictionService::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
54
53
  #
55
54
  # @yield [config] Configure the Client client.
56
55
  # @yieldparam config [Client::Configuration]
@@ -101,19 +100,15 @@ module Google
101
100
  ##
102
101
  # Create a new PredictionService client object.
103
102
  #
104
- # ## Examples
105
- #
106
- # To create a new PredictionService client with the default
107
- # configuration:
108
- #
109
- # client = ::Google::Cloud::AutoML::V1::PredictionService::Client.new
103
+ # @example
110
104
  #
111
- # To create a new PredictionService client with a custom
112
- # configuration:
105
+ # # Create a client using the default configuration
106
+ # client = ::Google::Cloud::AutoML::V1::PredictionService::Client.new
113
107
  #
114
- # client = ::Google::Cloud::AutoML::V1::PredictionService::Client.new do |config|
115
- # config.timeout = 10.0
116
- # end
108
+ # # Create a client using a custom configuration
109
+ # client = ::Google::Cloud::AutoML::V1::PredictionService::Client.new do |config|
110
+ # config.timeout = 10.0
111
+ # end
117
112
  #
118
113
  # @yield [config] Configure the PredictionService client.
119
114
  # @yieldparam config [Client::Configuration]
@@ -133,14 +128,13 @@ module Google
133
128
 
134
129
  # Create credentials
135
130
  credentials = @config.credentials
136
- # Use self-signed JWT if the scope and endpoint are unchanged from default,
131
+ # Use self-signed JWT if the endpoint is unchanged from default,
137
132
  # but only if the default endpoint does not have a region prefix.
138
- enable_self_signed_jwt = @config.scope == Client.configure.scope &&
139
- @config.endpoint == Client.configure.endpoint &&
133
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
140
134
  !@config.endpoint.split(".").first.include?("-")
141
135
  credentials ||= Credentials.default scope: @config.scope,
142
136
  enable_self_signed_jwt: enable_self_signed_jwt
143
- if credentials.is_a?(String) || credentials.is_a?(Hash)
137
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
144
138
  credentials = Credentials.new credentials, scope: @config.scope
145
139
  end
146
140
  @quota_project_id = @config.quota_project
@@ -268,6 +262,21 @@ module Google
268
262
  #
269
263
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
270
264
  #
265
+ # @example Basic example
266
+ # require "google/cloud/automl/v1"
267
+ #
268
+ # # Create a client object. The client can be reused for multiple calls.
269
+ # client = Google::Cloud::AutoML::V1::PredictionService::Client.new
270
+ #
271
+ # # Create a request. To set request fields, pass in keyword arguments.
272
+ # request = Google::Cloud::AutoML::V1::PredictRequest.new
273
+ #
274
+ # # Call the predict method.
275
+ # result = client.predict request
276
+ #
277
+ # # The returned object is of type Google::Cloud::AutoML::V1::PredictResponse.
278
+ # p result
279
+ #
271
280
  def predict request, options = nil
272
281
  raise ::ArgumentError, "request must be provided" if request.nil?
273
282
 
@@ -285,16 +294,20 @@ module Google
285
294
  gapic_version: ::Google::Cloud::AutoML::V1::VERSION
286
295
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
287
296
 
288
- header_params = {
289
- "name" => request.name
290
- }
297
+ header_params = {}
298
+ if request.name
299
+ header_params["name"] = request.name
300
+ end
301
+
291
302
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
292
303
  metadata[:"x-goog-request-params"] ||= request_params_header
293
304
 
294
305
  options.apply_defaults timeout: @config.rpcs.predict.timeout,
295
306
  metadata: metadata,
296
307
  retry_policy: @config.rpcs.predict.retry_policy
297
- options.apply_defaults metadata: @config.metadata,
308
+
309
+ options.apply_defaults timeout: @config.timeout,
310
+ metadata: @config.metadata,
298
311
  retry_policy: @config.retry_policy
299
312
 
300
313
  @prediction_service_stub.call_rpc :predict, request, options: options do |response, operation|
@@ -437,6 +450,28 @@ module Google
437
450
  #
438
451
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
439
452
  #
453
+ # @example Basic example
454
+ # require "google/cloud/automl/v1"
455
+ #
456
+ # # Create a client object. The client can be reused for multiple calls.
457
+ # client = Google::Cloud::AutoML::V1::PredictionService::Client.new
458
+ #
459
+ # # Create a request. To set request fields, pass in keyword arguments.
460
+ # request = Google::Cloud::AutoML::V1::BatchPredictRequest.new
461
+ #
462
+ # # Call the batch_predict method.
463
+ # result = client.batch_predict request
464
+ #
465
+ # # The returned object is of type Gapic::Operation. You can use this
466
+ # # object to check the status of an operation, cancel it, or wait
467
+ # # for results. Here is how to block until completion:
468
+ # result.wait_until_done! timeout: 60
469
+ # if result.response?
470
+ # p result.response
471
+ # else
472
+ # puts "Error!"
473
+ # end
474
+ #
440
475
  def batch_predict request, options = nil
441
476
  raise ::ArgumentError, "request must be provided" if request.nil?
442
477
 
@@ -454,16 +489,20 @@ module Google
454
489
  gapic_version: ::Google::Cloud::AutoML::V1::VERSION
455
490
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
456
491
 
457
- header_params = {
458
- "name" => request.name
459
- }
492
+ header_params = {}
493
+ if request.name
494
+ header_params["name"] = request.name
495
+ end
496
+
460
497
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
461
498
  metadata[:"x-goog-request-params"] ||= request_params_header
462
499
 
463
500
  options.apply_defaults timeout: @config.rpcs.batch_predict.timeout,
464
501
  metadata: metadata,
465
502
  retry_policy: @config.rpcs.batch_predict.retry_policy
466
- options.apply_defaults metadata: @config.metadata,
503
+
504
+ options.apply_defaults timeout: @config.timeout,
505
+ metadata: @config.metadata,
467
506
  retry_policy: @config.retry_policy
468
507
 
469
508
  @prediction_service_stub.call_rpc :batch_predict, request, options: options do |response, operation|
@@ -488,22 +527,21 @@ module Google
488
527
  # Configuration can be applied globally to all clients, or to a single client
489
528
  # on construction.
490
529
  #
491
- # # Examples
492
- #
493
- # To modify the global config, setting the timeout for predict
494
- # to 20 seconds, and all remaining timeouts to 10 seconds:
495
- #
496
- # ::Google::Cloud::AutoML::V1::PredictionService::Client.configure do |config|
497
- # config.timeout = 10.0
498
- # config.rpcs.predict.timeout = 20.0
499
- # end
500
- #
501
- # To apply the above configuration only to a new client:
502
- #
503
- # client = ::Google::Cloud::AutoML::V1::PredictionService::Client.new do |config|
504
- # config.timeout = 10.0
505
- # config.rpcs.predict.timeout = 20.0
506
- # end
530
+ # @example
531
+ #
532
+ # # Modify the global config, setting the timeout for
533
+ # # predict to 20 seconds,
534
+ # # and all remaining timeouts to 10 seconds.
535
+ # ::Google::Cloud::AutoML::V1::PredictionService::Client.configure do |config|
536
+ # config.timeout = 10.0
537
+ # config.rpcs.predict.timeout = 20.0
538
+ # end
539
+ #
540
+ # # Apply the above configuration only to a new client.
541
+ # client = ::Google::Cloud::AutoML::V1::PredictionService::Client.new do |config|
542
+ # config.timeout = 10.0
543
+ # config.rpcs.predict.timeout = 20.0
544
+ # end
507
545
  #
508
546
  # @!attribute [rw] endpoint
509
547
  # The hostname or hostname:port of the service endpoint.