google-cloud-vision-v1 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,13 +54,12 @@ module Google
54
54
  # See {::Google::Cloud::Vision::V1::ProductSearch::Client::Configuration}
55
55
  # for a description of the configuration fields.
56
56
  #
57
- # ## Example
57
+ # @example
58
58
  #
59
- # To modify the configuration for all ProductSearch clients:
60
- #
61
- # ::Google::Cloud::Vision::V1::ProductSearch::Client.configure do |config|
62
- # config.timeout = 10.0
63
- # end
59
+ # # Modify the configuration for all ProductSearch clients
60
+ # ::Google::Cloud::Vision::V1::ProductSearch::Client.configure do |config|
61
+ # config.timeout = 10.0
62
+ # end
64
63
  #
65
64
  # @yield [config] Configure the Client client.
66
65
  # @yieldparam config [Client::Configuration]
@@ -202,19 +201,15 @@ module Google
202
201
  ##
203
202
  # Create a new ProductSearch client object.
204
203
  #
205
- # ## Examples
206
- #
207
- # To create a new ProductSearch client with the default
208
- # configuration:
209
- #
210
- # client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new
204
+ # @example
211
205
  #
212
- # To create a new ProductSearch client with a custom
213
- # configuration:
206
+ # # Create a client using the default configuration
207
+ # client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new
214
208
  #
215
- # client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new do |config|
216
- # config.timeout = 10.0
217
- # end
209
+ # # Create a client using a custom configuration
210
+ # client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new do |config|
211
+ # config.timeout = 10.0
212
+ # end
218
213
  #
219
214
  # @yield [config] Configure the ProductSearch client.
220
215
  # @yieldparam config [Client::Configuration]
@@ -234,10 +229,9 @@ module Google
234
229
 
235
230
  # Create credentials
236
231
  credentials = @config.credentials
237
- # Use self-signed JWT if the scope and endpoint are unchanged from default,
232
+ # Use self-signed JWT if the endpoint is unchanged from default,
238
233
  # 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 &&
234
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
241
235
  !@config.endpoint.split(".").first.include?("-")
242
236
  credentials ||= Credentials.default scope: @config.scope,
243
237
  enable_self_signed_jwt: enable_self_signed_jwt
@@ -249,6 +243,7 @@ module Google
249
243
 
250
244
  @operations_client = Operations.new do |config|
251
245
  config.credentials = credentials
246
+ config.quota_project = @quota_project_id
252
247
  config.endpoint = @config.endpoint
253
248
  end
254
249
 
@@ -313,6 +308,21 @@ module Google
313
308
  #
314
309
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
315
310
  #
311
+ # @example Basic example
312
+ # require "google/cloud/vision/v1"
313
+ #
314
+ # # Create a client object. The client can be reused for multiple calls.
315
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
316
+ #
317
+ # # Create a request. To set request fields, pass in keyword arguments.
318
+ # request = Google::Cloud::Vision::V1::CreateProductSetRequest.new
319
+ #
320
+ # # Call the create_product_set method.
321
+ # result = client.create_product_set request
322
+ #
323
+ # # The returned object is of type Google::Cloud::Vision::V1::ProductSet.
324
+ # p result
325
+ #
316
326
  def create_product_set request, options = nil
317
327
  raise ::ArgumentError, "request must be provided" if request.nil?
318
328
 
@@ -330,16 +340,20 @@ module Google
330
340
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
331
341
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
332
342
 
333
- header_params = {
334
- "parent" => request.parent
335
- }
343
+ header_params = {}
344
+ if request.parent
345
+ header_params["parent"] = request.parent
346
+ end
347
+
336
348
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
337
349
  metadata[:"x-goog-request-params"] ||= request_params_header
338
350
 
339
351
  options.apply_defaults timeout: @config.rpcs.create_product_set.timeout,
340
352
  metadata: metadata,
341
353
  retry_policy: @config.rpcs.create_product_set.retry_policy
342
- options.apply_defaults metadata: @config.metadata,
354
+
355
+ options.apply_defaults timeout: @config.timeout,
356
+ metadata: @config.metadata,
343
357
  retry_policy: @config.retry_policy
344
358
 
345
359
  @product_search_stub.call_rpc :create_product_set, request, options: options do |response, operation|
@@ -390,6 +404,27 @@ module Google
390
404
  #
391
405
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
392
406
  #
407
+ # @example Basic example
408
+ # require "google/cloud/vision/v1"
409
+ #
410
+ # # Create a client object. The client can be reused for multiple calls.
411
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
412
+ #
413
+ # # Create a request. To set request fields, pass in keyword arguments.
414
+ # request = Google::Cloud::Vision::V1::ListProductSetsRequest.new
415
+ #
416
+ # # Call the list_product_sets method.
417
+ # result = client.list_product_sets request
418
+ #
419
+ # # The returned object is of type Gapic::PagedEnumerable. You can
420
+ # # iterate over all elements by calling #each, and the enumerable
421
+ # # will lazily make API calls to fetch subsequent pages. Other
422
+ # # methods are also available for managing paging directly.
423
+ # result.each do |response|
424
+ # # Each element is of type ::Google::Cloud::Vision::V1::ProductSet.
425
+ # p response
426
+ # end
427
+ #
393
428
  def list_product_sets request, options = nil
394
429
  raise ::ArgumentError, "request must be provided" if request.nil?
395
430
 
@@ -407,16 +442,20 @@ module Google
407
442
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
408
443
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
409
444
 
410
- header_params = {
411
- "parent" => request.parent
412
- }
445
+ header_params = {}
446
+ if request.parent
447
+ header_params["parent"] = request.parent
448
+ end
449
+
413
450
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
414
451
  metadata[:"x-goog-request-params"] ||= request_params_header
415
452
 
416
453
  options.apply_defaults timeout: @config.rpcs.list_product_sets.timeout,
417
454
  metadata: metadata,
418
455
  retry_policy: @config.rpcs.list_product_sets.retry_policy
419
- options.apply_defaults metadata: @config.metadata,
456
+
457
+ options.apply_defaults timeout: @config.timeout,
458
+ metadata: @config.metadata,
420
459
  retry_policy: @config.retry_policy
421
460
 
422
461
  @product_search_stub.call_rpc :list_product_sets, request, options: options do |response, operation|
@@ -464,6 +503,21 @@ module Google
464
503
  #
465
504
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
466
505
  #
506
+ # @example Basic example
507
+ # require "google/cloud/vision/v1"
508
+ #
509
+ # # Create a client object. The client can be reused for multiple calls.
510
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
511
+ #
512
+ # # Create a request. To set request fields, pass in keyword arguments.
513
+ # request = Google::Cloud::Vision::V1::GetProductSetRequest.new
514
+ #
515
+ # # Call the get_product_set method.
516
+ # result = client.get_product_set request
517
+ #
518
+ # # The returned object is of type Google::Cloud::Vision::V1::ProductSet.
519
+ # p result
520
+ #
467
521
  def get_product_set request, options = nil
468
522
  raise ::ArgumentError, "request must be provided" if request.nil?
469
523
 
@@ -481,16 +535,20 @@ module Google
481
535
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
482
536
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
483
537
 
484
- header_params = {
485
- "name" => request.name
486
- }
538
+ header_params = {}
539
+ if request.name
540
+ header_params["name"] = request.name
541
+ end
542
+
487
543
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
488
544
  metadata[:"x-goog-request-params"] ||= request_params_header
489
545
 
490
546
  options.apply_defaults timeout: @config.rpcs.get_product_set.timeout,
491
547
  metadata: metadata,
492
548
  retry_policy: @config.rpcs.get_product_set.retry_policy
493
- options.apply_defaults metadata: @config.metadata,
549
+
550
+ options.apply_defaults timeout: @config.timeout,
551
+ metadata: @config.metadata,
494
552
  retry_policy: @config.retry_policy
495
553
 
496
554
  @product_search_stub.call_rpc :get_product_set, request, options: options do |response, operation|
@@ -542,6 +600,21 @@ module Google
542
600
  #
543
601
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
544
602
  #
603
+ # @example Basic example
604
+ # require "google/cloud/vision/v1"
605
+ #
606
+ # # Create a client object. The client can be reused for multiple calls.
607
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
608
+ #
609
+ # # Create a request. To set request fields, pass in keyword arguments.
610
+ # request = Google::Cloud::Vision::V1::UpdateProductSetRequest.new
611
+ #
612
+ # # Call the update_product_set method.
613
+ # result = client.update_product_set request
614
+ #
615
+ # # The returned object is of type Google::Cloud::Vision::V1::ProductSet.
616
+ # p result
617
+ #
545
618
  def update_product_set request, options = nil
546
619
  raise ::ArgumentError, "request must be provided" if request.nil?
547
620
 
@@ -559,16 +632,20 @@ module Google
559
632
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
560
633
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
561
634
 
562
- header_params = {
563
- "product_set.name" => request.product_set.name
564
- }
635
+ header_params = {}
636
+ if request.product_set&.name
637
+ header_params["product_set.name"] = request.product_set.name
638
+ end
639
+
565
640
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
566
641
  metadata[:"x-goog-request-params"] ||= request_params_header
567
642
 
568
643
  options.apply_defaults timeout: @config.rpcs.update_product_set.timeout,
569
644
  metadata: metadata,
570
645
  retry_policy: @config.rpcs.update_product_set.retry_policy
571
- options.apply_defaults metadata: @config.metadata,
646
+
647
+ options.apply_defaults timeout: @config.timeout,
648
+ metadata: @config.metadata,
572
649
  retry_policy: @config.retry_policy
573
650
 
574
651
  @product_search_stub.call_rpc :update_product_set, request, options: options do |response, operation|
@@ -614,6 +691,21 @@ module Google
614
691
  #
615
692
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
616
693
  #
694
+ # @example Basic example
695
+ # require "google/cloud/vision/v1"
696
+ #
697
+ # # Create a client object. The client can be reused for multiple calls.
698
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
699
+ #
700
+ # # Create a request. To set request fields, pass in keyword arguments.
701
+ # request = Google::Cloud::Vision::V1::DeleteProductSetRequest.new
702
+ #
703
+ # # Call the delete_product_set method.
704
+ # result = client.delete_product_set request
705
+ #
706
+ # # The returned object is of type Google::Protobuf::Empty.
707
+ # p result
708
+ #
617
709
  def delete_product_set request, options = nil
618
710
  raise ::ArgumentError, "request must be provided" if request.nil?
619
711
 
@@ -631,16 +723,20 @@ module Google
631
723
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
632
724
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
633
725
 
634
- header_params = {
635
- "name" => request.name
636
- }
726
+ header_params = {}
727
+ if request.name
728
+ header_params["name"] = request.name
729
+ end
730
+
637
731
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
638
732
  metadata[:"x-goog-request-params"] ||= request_params_header
639
733
 
640
734
  options.apply_defaults timeout: @config.rpcs.delete_product_set.timeout,
641
735
  metadata: metadata,
642
736
  retry_policy: @config.rpcs.delete_product_set.retry_policy
643
- options.apply_defaults metadata: @config.metadata,
737
+
738
+ options.apply_defaults timeout: @config.timeout,
739
+ metadata: @config.metadata,
644
740
  retry_policy: @config.retry_policy
645
741
 
646
742
  @product_search_stub.call_rpc :delete_product_set, request, options: options do |response, operation|
@@ -697,6 +793,21 @@ module Google
697
793
  #
698
794
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
699
795
  #
796
+ # @example Basic example
797
+ # require "google/cloud/vision/v1"
798
+ #
799
+ # # Create a client object. The client can be reused for multiple calls.
800
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
801
+ #
802
+ # # Create a request. To set request fields, pass in keyword arguments.
803
+ # request = Google::Cloud::Vision::V1::CreateProductRequest.new
804
+ #
805
+ # # Call the create_product method.
806
+ # result = client.create_product request
807
+ #
808
+ # # The returned object is of type Google::Cloud::Vision::V1::Product.
809
+ # p result
810
+ #
700
811
  def create_product request, options = nil
701
812
  raise ::ArgumentError, "request must be provided" if request.nil?
702
813
 
@@ -714,16 +825,20 @@ module Google
714
825
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
715
826
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
716
827
 
717
- header_params = {
718
- "parent" => request.parent
719
- }
828
+ header_params = {}
829
+ if request.parent
830
+ header_params["parent"] = request.parent
831
+ end
832
+
720
833
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
721
834
  metadata[:"x-goog-request-params"] ||= request_params_header
722
835
 
723
836
  options.apply_defaults timeout: @config.rpcs.create_product.timeout,
724
837
  metadata: metadata,
725
838
  retry_policy: @config.rpcs.create_product.retry_policy
726
- options.apply_defaults metadata: @config.metadata,
839
+
840
+ options.apply_defaults timeout: @config.timeout,
841
+ metadata: @config.metadata,
727
842
  retry_policy: @config.retry_policy
728
843
 
729
844
  @product_search_stub.call_rpc :create_product, request, options: options do |response, operation|
@@ -774,6 +889,27 @@ module Google
774
889
  #
775
890
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
776
891
  #
892
+ # @example Basic example
893
+ # require "google/cloud/vision/v1"
894
+ #
895
+ # # Create a client object. The client can be reused for multiple calls.
896
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
897
+ #
898
+ # # Create a request. To set request fields, pass in keyword arguments.
899
+ # request = Google::Cloud::Vision::V1::ListProductsRequest.new
900
+ #
901
+ # # Call the list_products method.
902
+ # result = client.list_products request
903
+ #
904
+ # # The returned object is of type Gapic::PagedEnumerable. You can
905
+ # # iterate over all elements by calling #each, and the enumerable
906
+ # # will lazily make API calls to fetch subsequent pages. Other
907
+ # # methods are also available for managing paging directly.
908
+ # result.each do |response|
909
+ # # Each element is of type ::Google::Cloud::Vision::V1::Product.
910
+ # p response
911
+ # end
912
+ #
777
913
  def list_products request, options = nil
778
914
  raise ::ArgumentError, "request must be provided" if request.nil?
779
915
 
@@ -791,16 +927,20 @@ module Google
791
927
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
792
928
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
793
929
 
794
- header_params = {
795
- "parent" => request.parent
796
- }
930
+ header_params = {}
931
+ if request.parent
932
+ header_params["parent"] = request.parent
933
+ end
934
+
797
935
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
798
936
  metadata[:"x-goog-request-params"] ||= request_params_header
799
937
 
800
938
  options.apply_defaults timeout: @config.rpcs.list_products.timeout,
801
939
  metadata: metadata,
802
940
  retry_policy: @config.rpcs.list_products.retry_policy
803
- options.apply_defaults metadata: @config.metadata,
941
+
942
+ options.apply_defaults timeout: @config.timeout,
943
+ metadata: @config.metadata,
804
944
  retry_policy: @config.retry_policy
805
945
 
806
946
  @product_search_stub.call_rpc :list_products, request, options: options do |response, operation|
@@ -848,6 +988,21 @@ module Google
848
988
  #
849
989
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
850
990
  #
991
+ # @example Basic example
992
+ # require "google/cloud/vision/v1"
993
+ #
994
+ # # Create a client object. The client can be reused for multiple calls.
995
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
996
+ #
997
+ # # Create a request. To set request fields, pass in keyword arguments.
998
+ # request = Google::Cloud::Vision::V1::GetProductRequest.new
999
+ #
1000
+ # # Call the get_product method.
1001
+ # result = client.get_product request
1002
+ #
1003
+ # # The returned object is of type Google::Cloud::Vision::V1::Product.
1004
+ # p result
1005
+ #
851
1006
  def get_product request, options = nil
852
1007
  raise ::ArgumentError, "request must be provided" if request.nil?
853
1008
 
@@ -865,16 +1020,20 @@ module Google
865
1020
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
866
1021
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
867
1022
 
868
- header_params = {
869
- "name" => request.name
870
- }
1023
+ header_params = {}
1024
+ if request.name
1025
+ header_params["name"] = request.name
1026
+ end
1027
+
871
1028
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
872
1029
  metadata[:"x-goog-request-params"] ||= request_params_header
873
1030
 
874
1031
  options.apply_defaults timeout: @config.rpcs.get_product.timeout,
875
1032
  metadata: metadata,
876
1033
  retry_policy: @config.rpcs.get_product.retry_policy
877
- options.apply_defaults metadata: @config.metadata,
1034
+
1035
+ options.apply_defaults timeout: @config.timeout,
1036
+ metadata: @config.metadata,
878
1037
  retry_policy: @config.retry_policy
879
1038
 
880
1039
  @product_search_stub.call_rpc :get_product, request, options: options do |response, operation|
@@ -935,6 +1094,21 @@ module Google
935
1094
  #
936
1095
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
937
1096
  #
1097
+ # @example Basic example
1098
+ # require "google/cloud/vision/v1"
1099
+ #
1100
+ # # Create a client object. The client can be reused for multiple calls.
1101
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
1102
+ #
1103
+ # # Create a request. To set request fields, pass in keyword arguments.
1104
+ # request = Google::Cloud::Vision::V1::UpdateProductRequest.new
1105
+ #
1106
+ # # Call the update_product method.
1107
+ # result = client.update_product request
1108
+ #
1109
+ # # The returned object is of type Google::Cloud::Vision::V1::Product.
1110
+ # p result
1111
+ #
938
1112
  def update_product request, options = nil
939
1113
  raise ::ArgumentError, "request must be provided" if request.nil?
940
1114
 
@@ -952,16 +1126,20 @@ module Google
952
1126
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
953
1127
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
954
1128
 
955
- header_params = {
956
- "product.name" => request.product.name
957
- }
1129
+ header_params = {}
1130
+ if request.product&.name
1131
+ header_params["product.name"] = request.product.name
1132
+ end
1133
+
958
1134
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
959
1135
  metadata[:"x-goog-request-params"] ||= request_params_header
960
1136
 
961
1137
  options.apply_defaults timeout: @config.rpcs.update_product.timeout,
962
1138
  metadata: metadata,
963
1139
  retry_policy: @config.rpcs.update_product.retry_policy
964
- options.apply_defaults metadata: @config.metadata,
1140
+
1141
+ options.apply_defaults timeout: @config.timeout,
1142
+ metadata: @config.metadata,
965
1143
  retry_policy: @config.retry_policy
966
1144
 
967
1145
  @product_search_stub.call_rpc :update_product, request, options: options do |response, operation|
@@ -1008,6 +1186,21 @@ module Google
1008
1186
  #
1009
1187
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1010
1188
  #
1189
+ # @example Basic example
1190
+ # require "google/cloud/vision/v1"
1191
+ #
1192
+ # # Create a client object. The client can be reused for multiple calls.
1193
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
1194
+ #
1195
+ # # Create a request. To set request fields, pass in keyword arguments.
1196
+ # request = Google::Cloud::Vision::V1::DeleteProductRequest.new
1197
+ #
1198
+ # # Call the delete_product method.
1199
+ # result = client.delete_product request
1200
+ #
1201
+ # # The returned object is of type Google::Protobuf::Empty.
1202
+ # p result
1203
+ #
1011
1204
  def delete_product request, options = nil
1012
1205
  raise ::ArgumentError, "request must be provided" if request.nil?
1013
1206
 
@@ -1025,16 +1218,20 @@ module Google
1025
1218
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
1026
1219
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1027
1220
 
1028
- header_params = {
1029
- "name" => request.name
1030
- }
1221
+ header_params = {}
1222
+ if request.name
1223
+ header_params["name"] = request.name
1224
+ end
1225
+
1031
1226
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1032
1227
  metadata[:"x-goog-request-params"] ||= request_params_header
1033
1228
 
1034
1229
  options.apply_defaults timeout: @config.rpcs.delete_product.timeout,
1035
1230
  metadata: metadata,
1036
1231
  retry_policy: @config.rpcs.delete_product.retry_policy
1037
- options.apply_defaults metadata: @config.metadata,
1232
+
1233
+ options.apply_defaults timeout: @config.timeout,
1234
+ metadata: @config.metadata,
1038
1235
  retry_policy: @config.retry_policy
1039
1236
 
1040
1237
  @product_search_stub.call_rpc :delete_product, request, options: options do |response, operation|
@@ -1103,6 +1300,21 @@ module Google
1103
1300
  #
1104
1301
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1105
1302
  #
1303
+ # @example Basic example
1304
+ # require "google/cloud/vision/v1"
1305
+ #
1306
+ # # Create a client object. The client can be reused for multiple calls.
1307
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
1308
+ #
1309
+ # # Create a request. To set request fields, pass in keyword arguments.
1310
+ # request = Google::Cloud::Vision::V1::CreateReferenceImageRequest.new
1311
+ #
1312
+ # # Call the create_reference_image method.
1313
+ # result = client.create_reference_image request
1314
+ #
1315
+ # # The returned object is of type Google::Cloud::Vision::V1::ReferenceImage.
1316
+ # p result
1317
+ #
1106
1318
  def create_reference_image request, options = nil
1107
1319
  raise ::ArgumentError, "request must be provided" if request.nil?
1108
1320
 
@@ -1120,16 +1332,20 @@ module Google
1120
1332
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
1121
1333
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1122
1334
 
1123
- header_params = {
1124
- "parent" => request.parent
1125
- }
1335
+ header_params = {}
1336
+ if request.parent
1337
+ header_params["parent"] = request.parent
1338
+ end
1339
+
1126
1340
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1127
1341
  metadata[:"x-goog-request-params"] ||= request_params_header
1128
1342
 
1129
1343
  options.apply_defaults timeout: @config.rpcs.create_reference_image.timeout,
1130
1344
  metadata: metadata,
1131
1345
  retry_policy: @config.rpcs.create_reference_image.retry_policy
1132
- options.apply_defaults metadata: @config.metadata,
1346
+
1347
+ options.apply_defaults timeout: @config.timeout,
1348
+ metadata: @config.metadata,
1133
1349
  retry_policy: @config.retry_policy
1134
1350
 
1135
1351
  @product_search_stub.call_rpc :create_reference_image, request, options: options do |response, operation|
@@ -1178,6 +1394,21 @@ module Google
1178
1394
  #
1179
1395
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1180
1396
  #
1397
+ # @example Basic example
1398
+ # require "google/cloud/vision/v1"
1399
+ #
1400
+ # # Create a client object. The client can be reused for multiple calls.
1401
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
1402
+ #
1403
+ # # Create a request. To set request fields, pass in keyword arguments.
1404
+ # request = Google::Cloud::Vision::V1::DeleteReferenceImageRequest.new
1405
+ #
1406
+ # # Call the delete_reference_image method.
1407
+ # result = client.delete_reference_image request
1408
+ #
1409
+ # # The returned object is of type Google::Protobuf::Empty.
1410
+ # p result
1411
+ #
1181
1412
  def delete_reference_image request, options = nil
1182
1413
  raise ::ArgumentError, "request must be provided" if request.nil?
1183
1414
 
@@ -1195,16 +1426,20 @@ module Google
1195
1426
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
1196
1427
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1197
1428
 
1198
- header_params = {
1199
- "name" => request.name
1200
- }
1429
+ header_params = {}
1430
+ if request.name
1431
+ header_params["name"] = request.name
1432
+ end
1433
+
1201
1434
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1202
1435
  metadata[:"x-goog-request-params"] ||= request_params_header
1203
1436
 
1204
1437
  options.apply_defaults timeout: @config.rpcs.delete_reference_image.timeout,
1205
1438
  metadata: metadata,
1206
1439
  retry_policy: @config.rpcs.delete_reference_image.retry_policy
1207
- options.apply_defaults metadata: @config.metadata,
1440
+
1441
+ options.apply_defaults timeout: @config.timeout,
1442
+ metadata: @config.metadata,
1208
1443
  retry_policy: @config.retry_policy
1209
1444
 
1210
1445
  @product_search_stub.call_rpc :delete_reference_image, request, options: options do |response, operation|
@@ -1260,6 +1495,27 @@ module Google
1260
1495
  #
1261
1496
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1262
1497
  #
1498
+ # @example Basic example
1499
+ # require "google/cloud/vision/v1"
1500
+ #
1501
+ # # Create a client object. The client can be reused for multiple calls.
1502
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
1503
+ #
1504
+ # # Create a request. To set request fields, pass in keyword arguments.
1505
+ # request = Google::Cloud::Vision::V1::ListReferenceImagesRequest.new
1506
+ #
1507
+ # # Call the list_reference_images method.
1508
+ # result = client.list_reference_images request
1509
+ #
1510
+ # # The returned object is of type Gapic::PagedEnumerable. You can
1511
+ # # iterate over all elements by calling #each, and the enumerable
1512
+ # # will lazily make API calls to fetch subsequent pages. Other
1513
+ # # methods are also available for managing paging directly.
1514
+ # result.each do |response|
1515
+ # # Each element is of type ::Google::Cloud::Vision::V1::ReferenceImage.
1516
+ # p response
1517
+ # end
1518
+ #
1263
1519
  def list_reference_images request, options = nil
1264
1520
  raise ::ArgumentError, "request must be provided" if request.nil?
1265
1521
 
@@ -1277,16 +1533,20 @@ module Google
1277
1533
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
1278
1534
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1279
1535
 
1280
- header_params = {
1281
- "parent" => request.parent
1282
- }
1536
+ header_params = {}
1537
+ if request.parent
1538
+ header_params["parent"] = request.parent
1539
+ end
1540
+
1283
1541
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1284
1542
  metadata[:"x-goog-request-params"] ||= request_params_header
1285
1543
 
1286
1544
  options.apply_defaults timeout: @config.rpcs.list_reference_images.timeout,
1287
1545
  metadata: metadata,
1288
1546
  retry_policy: @config.rpcs.list_reference_images.retry_policy
1289
- options.apply_defaults metadata: @config.metadata,
1547
+
1548
+ options.apply_defaults timeout: @config.timeout,
1549
+ metadata: @config.metadata,
1290
1550
  retry_policy: @config.retry_policy
1291
1551
 
1292
1552
  @product_search_stub.call_rpc :list_reference_images, request, options: options do |response, operation|
@@ -1334,6 +1594,21 @@ module Google
1334
1594
  #
1335
1595
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1336
1596
  #
1597
+ # @example Basic example
1598
+ # require "google/cloud/vision/v1"
1599
+ #
1600
+ # # Create a client object. The client can be reused for multiple calls.
1601
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
1602
+ #
1603
+ # # Create a request. To set request fields, pass in keyword arguments.
1604
+ # request = Google::Cloud::Vision::V1::GetReferenceImageRequest.new
1605
+ #
1606
+ # # Call the get_reference_image method.
1607
+ # result = client.get_reference_image request
1608
+ #
1609
+ # # The returned object is of type Google::Cloud::Vision::V1::ReferenceImage.
1610
+ # p result
1611
+ #
1337
1612
  def get_reference_image request, options = nil
1338
1613
  raise ::ArgumentError, "request must be provided" if request.nil?
1339
1614
 
@@ -1351,16 +1626,20 @@ module Google
1351
1626
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
1352
1627
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1353
1628
 
1354
- header_params = {
1355
- "name" => request.name
1356
- }
1629
+ header_params = {}
1630
+ if request.name
1631
+ header_params["name"] = request.name
1632
+ end
1633
+
1357
1634
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1358
1635
  metadata[:"x-goog-request-params"] ||= request_params_header
1359
1636
 
1360
1637
  options.apply_defaults timeout: @config.rpcs.get_reference_image.timeout,
1361
1638
  metadata: metadata,
1362
1639
  retry_policy: @config.rpcs.get_reference_image.retry_policy
1363
- options.apply_defaults metadata: @config.metadata,
1640
+
1641
+ options.apply_defaults timeout: @config.timeout,
1642
+ metadata: @config.metadata,
1364
1643
  retry_policy: @config.retry_policy
1365
1644
 
1366
1645
  @product_search_stub.call_rpc :get_reference_image, request, options: options do |response, operation|
@@ -1415,6 +1694,21 @@ module Google
1415
1694
  #
1416
1695
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1417
1696
  #
1697
+ # @example Basic example
1698
+ # require "google/cloud/vision/v1"
1699
+ #
1700
+ # # Create a client object. The client can be reused for multiple calls.
1701
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
1702
+ #
1703
+ # # Create a request. To set request fields, pass in keyword arguments.
1704
+ # request = Google::Cloud::Vision::V1::AddProductToProductSetRequest.new
1705
+ #
1706
+ # # Call the add_product_to_product_set method.
1707
+ # result = client.add_product_to_product_set request
1708
+ #
1709
+ # # The returned object is of type Google::Protobuf::Empty.
1710
+ # p result
1711
+ #
1418
1712
  def add_product_to_product_set request, options = nil
1419
1713
  raise ::ArgumentError, "request must be provided" if request.nil?
1420
1714
 
@@ -1432,16 +1726,20 @@ module Google
1432
1726
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
1433
1727
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1434
1728
 
1435
- header_params = {
1436
- "name" => request.name
1437
- }
1729
+ header_params = {}
1730
+ if request.name
1731
+ header_params["name"] = request.name
1732
+ end
1733
+
1438
1734
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1439
1735
  metadata[:"x-goog-request-params"] ||= request_params_header
1440
1736
 
1441
1737
  options.apply_defaults timeout: @config.rpcs.add_product_to_product_set.timeout,
1442
1738
  metadata: metadata,
1443
1739
  retry_policy: @config.rpcs.add_product_to_product_set.retry_policy
1444
- options.apply_defaults metadata: @config.metadata,
1740
+
1741
+ options.apply_defaults timeout: @config.timeout,
1742
+ metadata: @config.metadata,
1445
1743
  retry_policy: @config.retry_policy
1446
1744
 
1447
1745
  @product_search_stub.call_rpc :add_product_to_product_set, request, options: options do |response, operation|
@@ -1489,6 +1787,21 @@ module Google
1489
1787
  #
1490
1788
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1491
1789
  #
1790
+ # @example Basic example
1791
+ # require "google/cloud/vision/v1"
1792
+ #
1793
+ # # Create a client object. The client can be reused for multiple calls.
1794
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
1795
+ #
1796
+ # # Create a request. To set request fields, pass in keyword arguments.
1797
+ # request = Google::Cloud::Vision::V1::RemoveProductFromProductSetRequest.new
1798
+ #
1799
+ # # Call the remove_product_from_product_set method.
1800
+ # result = client.remove_product_from_product_set request
1801
+ #
1802
+ # # The returned object is of type Google::Protobuf::Empty.
1803
+ # p result
1804
+ #
1492
1805
  def remove_product_from_product_set request, options = nil
1493
1806
  raise ::ArgumentError, "request must be provided" if request.nil?
1494
1807
 
@@ -1506,16 +1819,20 @@ module Google
1506
1819
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
1507
1820
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1508
1821
 
1509
- header_params = {
1510
- "name" => request.name
1511
- }
1822
+ header_params = {}
1823
+ if request.name
1824
+ header_params["name"] = request.name
1825
+ end
1826
+
1512
1827
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1513
1828
  metadata[:"x-goog-request-params"] ||= request_params_header
1514
1829
 
1515
1830
  options.apply_defaults timeout: @config.rpcs.remove_product_from_product_set.timeout,
1516
1831
  metadata: metadata,
1517
1832
  retry_policy: @config.rpcs.remove_product_from_product_set.retry_policy
1518
- options.apply_defaults metadata: @config.metadata,
1833
+
1834
+ options.apply_defaults timeout: @config.timeout,
1835
+ metadata: @config.metadata,
1519
1836
  retry_policy: @config.retry_policy
1520
1837
 
1521
1838
  @product_search_stub.call_rpc :remove_product_from_product_set, request, options: options do |response, operation|
@@ -1568,6 +1885,27 @@ module Google
1568
1885
  #
1569
1886
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1570
1887
  #
1888
+ # @example Basic example
1889
+ # require "google/cloud/vision/v1"
1890
+ #
1891
+ # # Create a client object. The client can be reused for multiple calls.
1892
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
1893
+ #
1894
+ # # Create a request. To set request fields, pass in keyword arguments.
1895
+ # request = Google::Cloud::Vision::V1::ListProductsInProductSetRequest.new
1896
+ #
1897
+ # # Call the list_products_in_product_set method.
1898
+ # result = client.list_products_in_product_set request
1899
+ #
1900
+ # # The returned object is of type Gapic::PagedEnumerable. You can
1901
+ # # iterate over all elements by calling #each, and the enumerable
1902
+ # # will lazily make API calls to fetch subsequent pages. Other
1903
+ # # methods are also available for managing paging directly.
1904
+ # result.each do |response|
1905
+ # # Each element is of type ::Google::Cloud::Vision::V1::Product.
1906
+ # p response
1907
+ # end
1908
+ #
1571
1909
  def list_products_in_product_set request, options = nil
1572
1910
  raise ::ArgumentError, "request must be provided" if request.nil?
1573
1911
 
@@ -1585,16 +1923,20 @@ module Google
1585
1923
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
1586
1924
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1587
1925
 
1588
- header_params = {
1589
- "name" => request.name
1590
- }
1926
+ header_params = {}
1927
+ if request.name
1928
+ header_params["name"] = request.name
1929
+ end
1930
+
1591
1931
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1592
1932
  metadata[:"x-goog-request-params"] ||= request_params_header
1593
1933
 
1594
1934
  options.apply_defaults timeout: @config.rpcs.list_products_in_product_set.timeout,
1595
1935
  metadata: metadata,
1596
1936
  retry_policy: @config.rpcs.list_products_in_product_set.retry_policy
1597
- options.apply_defaults metadata: @config.metadata,
1937
+
1938
+ options.apply_defaults timeout: @config.timeout,
1939
+ metadata: @config.metadata,
1598
1940
  retry_policy: @config.retry_policy
1599
1941
 
1600
1942
  @product_search_stub.call_rpc :list_products_in_product_set, request, options: options do |response, operation|
@@ -1649,6 +1991,28 @@ module Google
1649
1991
  #
1650
1992
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1651
1993
  #
1994
+ # @example Basic example
1995
+ # require "google/cloud/vision/v1"
1996
+ #
1997
+ # # Create a client object. The client can be reused for multiple calls.
1998
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
1999
+ #
2000
+ # # Create a request. To set request fields, pass in keyword arguments.
2001
+ # request = Google::Cloud::Vision::V1::ImportProductSetsRequest.new
2002
+ #
2003
+ # # Call the import_product_sets method.
2004
+ # result = client.import_product_sets request
2005
+ #
2006
+ # # The returned object is of type Gapic::Operation. You can use this
2007
+ # # object to check the status of an operation, cancel it, or wait
2008
+ # # for results. Here is how to block until completion:
2009
+ # result.wait_until_done! timeout: 60
2010
+ # if result.response?
2011
+ # p result.response
2012
+ # else
2013
+ # puts "Error!"
2014
+ # end
2015
+ #
1652
2016
  def import_product_sets request, options = nil
1653
2017
  raise ::ArgumentError, "request must be provided" if request.nil?
1654
2018
 
@@ -1666,16 +2030,20 @@ module Google
1666
2030
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
1667
2031
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1668
2032
 
1669
- header_params = {
1670
- "parent" => request.parent
1671
- }
2033
+ header_params = {}
2034
+ if request.parent
2035
+ header_params["parent"] = request.parent
2036
+ end
2037
+
1672
2038
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1673
2039
  metadata[:"x-goog-request-params"] ||= request_params_header
1674
2040
 
1675
2041
  options.apply_defaults timeout: @config.rpcs.import_product_sets.timeout,
1676
2042
  metadata: metadata,
1677
2043
  retry_policy: @config.rpcs.import_product_sets.retry_policy
1678
- options.apply_defaults metadata: @config.metadata,
2044
+
2045
+ options.apply_defaults timeout: @config.timeout,
2046
+ metadata: @config.metadata,
1679
2047
  retry_policy: @config.retry_policy
1680
2048
 
1681
2049
  @product_search_stub.call_rpc :import_product_sets, request, options: options do |response, operation|
@@ -1749,6 +2117,28 @@ module Google
1749
2117
  #
1750
2118
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1751
2119
  #
2120
+ # @example Basic example
2121
+ # require "google/cloud/vision/v1"
2122
+ #
2123
+ # # Create a client object. The client can be reused for multiple calls.
2124
+ # client = Google::Cloud::Vision::V1::ProductSearch::Client.new
2125
+ #
2126
+ # # Create a request. To set request fields, pass in keyword arguments.
2127
+ # request = Google::Cloud::Vision::V1::PurgeProductsRequest.new
2128
+ #
2129
+ # # Call the purge_products method.
2130
+ # result = client.purge_products request
2131
+ #
2132
+ # # The returned object is of type Gapic::Operation. You can use this
2133
+ # # object to check the status of an operation, cancel it, or wait
2134
+ # # for results. Here is how to block until completion:
2135
+ # result.wait_until_done! timeout: 60
2136
+ # if result.response?
2137
+ # p result.response
2138
+ # else
2139
+ # puts "Error!"
2140
+ # end
2141
+ #
1752
2142
  def purge_products request, options = nil
1753
2143
  raise ::ArgumentError, "request must be provided" if request.nil?
1754
2144
 
@@ -1766,16 +2156,20 @@ module Google
1766
2156
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
1767
2157
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1768
2158
 
1769
- header_params = {
1770
- "parent" => request.parent
1771
- }
2159
+ header_params = {}
2160
+ if request.parent
2161
+ header_params["parent"] = request.parent
2162
+ end
2163
+
1772
2164
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1773
2165
  metadata[:"x-goog-request-params"] ||= request_params_header
1774
2166
 
1775
2167
  options.apply_defaults timeout: @config.rpcs.purge_products.timeout,
1776
2168
  metadata: metadata,
1777
2169
  retry_policy: @config.rpcs.purge_products.retry_policy
1778
- options.apply_defaults metadata: @config.metadata,
2170
+
2171
+ options.apply_defaults timeout: @config.timeout,
2172
+ metadata: @config.metadata,
1779
2173
  retry_policy: @config.retry_policy
1780
2174
 
1781
2175
  @product_search_stub.call_rpc :purge_products, request, options: options do |response, operation|
@@ -1800,22 +2194,21 @@ module Google
1800
2194
  # Configuration can be applied globally to all clients, or to a single client
1801
2195
  # on construction.
1802
2196
  #
1803
- # # Examples
1804
- #
1805
- # To modify the global config, setting the timeout for create_product_set
1806
- # to 20 seconds, and all remaining timeouts to 10 seconds:
1807
- #
1808
- # ::Google::Cloud::Vision::V1::ProductSearch::Client.configure do |config|
1809
- # config.timeout = 10.0
1810
- # config.rpcs.create_product_set.timeout = 20.0
1811
- # end
1812
- #
1813
- # To apply the above configuration only to a new client:
1814
- #
1815
- # client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new do |config|
1816
- # config.timeout = 10.0
1817
- # config.rpcs.create_product_set.timeout = 20.0
1818
- # end
2197
+ # @example
2198
+ #
2199
+ # # Modify the global config, setting the timeout for
2200
+ # # create_product_set to 20 seconds,
2201
+ # # and all remaining timeouts to 10 seconds.
2202
+ # ::Google::Cloud::Vision::V1::ProductSearch::Client.configure do |config|
2203
+ # config.timeout = 10.0
2204
+ # config.rpcs.create_product_set.timeout = 20.0
2205
+ # end
2206
+ #
2207
+ # # Apply the above configuration only to a new client.
2208
+ # client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new do |config|
2209
+ # config.timeout = 10.0
2210
+ # config.rpcs.create_product_set.timeout = 20.0
2211
+ # end
1819
2212
  #
1820
2213
  # @!attribute [rw] endpoint
1821
2214
  # The hostname or hostname:port of the service endpoint.