google-cloud-retail-v2 0.3.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/google/cloud/retail/v2/catalog_pb.rb +2 -0
  3. data/lib/google/cloud/retail/v2/catalog_service/client.rb +240 -40
  4. data/lib/google/cloud/retail/v2/catalog_service/paths.rb +21 -0
  5. data/lib/google/cloud/retail/v2/catalog_service_pb.rb +16 -0
  6. data/lib/google/cloud/retail/v2/catalog_service_services_pb.rb +46 -0
  7. data/lib/google/cloud/retail/v2/common_pb.rb +46 -0
  8. data/lib/google/cloud/retail/v2/completion_service/client.rb +545 -0
  9. data/lib/google/cloud/retail/v2/completion_service/credentials.rb +51 -0
  10. data/lib/google/cloud/retail/v2/completion_service/operations.rb +664 -0
  11. data/lib/google/cloud/retail/v2/completion_service/paths.rb +52 -0
  12. data/lib/google/cloud/retail/v2/completion_service.rb +54 -0
  13. data/lib/google/cloud/retail/v2/completion_service_pb.rb +50 -0
  14. data/lib/google/cloud/retail/v2/completion_service_services_pb.rb +61 -0
  15. data/lib/google/cloud/retail/v2/import_config_pb.rb +32 -0
  16. data/lib/google/cloud/retail/v2/prediction_service/client.rb +66 -70
  17. data/lib/google/cloud/retail/v2/product_pb.rb +21 -0
  18. data/lib/google/cloud/retail/v2/product_service/client.rb +682 -43
  19. data/lib/google/cloud/retail/v2/product_service/operations.rb +30 -21
  20. data/lib/google/cloud/retail/v2/product_service_pb.rb +56 -0
  21. data/lib/google/cloud/retail/v2/product_service_services_pb.rb +75 -0
  22. data/lib/google/cloud/retail/v2/search_service/client.rb +552 -0
  23. data/lib/google/cloud/retail/v2/search_service/credentials.rb +51 -0
  24. data/lib/google/cloud/retail/v2/search_service/paths.rb +54 -0
  25. data/lib/google/cloud/retail/v2/search_service.rb +53 -0
  26. data/lib/google/cloud/retail/v2/search_service_pb.rb +133 -0
  27. data/lib/google/cloud/retail/v2/search_service_services_pb.rb +53 -0
  28. data/lib/google/cloud/retail/v2/user_event_pb.rb +11 -0
  29. data/lib/google/cloud/retail/v2/user_event_service/client.rb +45 -42
  30. data/lib/google/cloud/retail/v2/user_event_service/operations.rb +30 -21
  31. data/lib/google/cloud/retail/v2/user_event_service/paths.rb +19 -0
  32. data/lib/google/cloud/retail/v2/version.rb +1 -1
  33. data/lib/google/cloud/retail/v2.rb +2 -0
  34. data/proto_docs/google/cloud/retail/v2/catalog.rb +6 -6
  35. data/proto_docs/google/cloud/retail/v2/catalog_service.rb +53 -4
  36. data/proto_docs/google/cloud/retail/v2/common.rb +272 -4
  37. data/proto_docs/google/cloud/retail/v2/completion_service.rb +164 -0
  38. data/proto_docs/google/cloud/retail/v2/import_config.rb +122 -6
  39. data/proto_docs/google/cloud/retail/v2/prediction_service.rb +32 -31
  40. data/proto_docs/google/cloud/retail/v2/product.rb +265 -9
  41. data/proto_docs/google/cloud/retail/v2/product_service.rb +362 -2
  42. data/proto_docs/google/cloud/retail/v2/purge_config.rb +1 -1
  43. data/proto_docs/google/cloud/retail/v2/search_service.rb +711 -0
  44. data/proto_docs/google/cloud/retail/v2/user_event.rb +110 -6
  45. data/proto_docs/google/type/date.rb +53 -0
  46. metadata +20 -4
@@ -169,7 +169,9 @@ module Google
169
169
  options.apply_defaults timeout: @config.rpcs.list_operations.timeout,
170
170
  metadata: metadata,
171
171
  retry_policy: @config.rpcs.list_operations.retry_policy
172
- options.apply_defaults metadata: @config.metadata,
172
+
173
+ options.apply_defaults timeout: @config.timeout,
174
+ metadata: @config.metadata,
173
175
  retry_policy: @config.retry_policy
174
176
 
175
177
  @operations_stub.call_rpc :list_operations, request, options: options do |response, operation|
@@ -239,7 +241,9 @@ module Google
239
241
  options.apply_defaults timeout: @config.rpcs.get_operation.timeout,
240
242
  metadata: metadata,
241
243
  retry_policy: @config.rpcs.get_operation.retry_policy
242
- options.apply_defaults metadata: @config.metadata,
244
+
245
+ options.apply_defaults timeout: @config.timeout,
246
+ metadata: @config.metadata,
243
247
  retry_policy: @config.retry_policy
244
248
 
245
249
  @operations_stub.call_rpc :get_operation, request, options: options do |response, operation|
@@ -309,7 +313,9 @@ module Google
309
313
  options.apply_defaults timeout: @config.rpcs.delete_operation.timeout,
310
314
  metadata: metadata,
311
315
  retry_policy: @config.rpcs.delete_operation.retry_policy
312
- options.apply_defaults metadata: @config.metadata,
316
+
317
+ options.apply_defaults timeout: @config.timeout,
318
+ metadata: @config.metadata,
313
319
  retry_policy: @config.retry_policy
314
320
 
315
321
  @operations_stub.call_rpc :delete_operation, request, options: options do |response, operation|
@@ -384,7 +390,9 @@ module Google
384
390
  options.apply_defaults timeout: @config.rpcs.cancel_operation.timeout,
385
391
  metadata: metadata,
386
392
  retry_policy: @config.rpcs.cancel_operation.retry_policy
387
- options.apply_defaults metadata: @config.metadata,
393
+
394
+ options.apply_defaults timeout: @config.timeout,
395
+ metadata: @config.metadata,
388
396
  retry_policy: @config.retry_policy
389
397
 
390
398
  @operations_stub.call_rpc :cancel_operation, request, options: options do |response, operation|
@@ -456,7 +464,9 @@ module Google
456
464
  options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
457
465
  metadata: metadata,
458
466
  retry_policy: @config.rpcs.wait_operation.retry_policy
459
- options.apply_defaults metadata: @config.metadata,
467
+
468
+ options.apply_defaults timeout: @config.timeout,
469
+ metadata: @config.metadata,
460
470
  retry_policy: @config.retry_policy
461
471
 
462
472
  @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
@@ -481,22 +491,21 @@ module Google
481
491
  # Configuration can be applied globally to all clients, or to a single client
482
492
  # on construction.
483
493
  #
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
494
+ # @example
495
+ #
496
+ # # Modify the global config, setting the timeout for
497
+ # # list_operations to 20 seconds,
498
+ # # and all remaining timeouts to 10 seconds.
499
+ # ::Google::Longrunning::Operations::Client.configure do |config|
500
+ # config.timeout = 10.0
501
+ # config.rpcs.list_operations.timeout = 20.0
502
+ # end
503
+ #
504
+ # # Apply the above configuration only to a new client.
505
+ # client = ::Google::Longrunning::Operations::Client.new do |config|
506
+ # config.timeout = 10.0
507
+ # config.rpcs.list_operations.timeout = 20.0
508
+ # end
500
509
  #
501
510
  # @!attribute [rw] endpoint
502
511
  # The hostname or hostname:port of the service endpoint.
@@ -13,6 +13,7 @@ require 'google/cloud/retail/v2/purge_config_pb'
13
13
  require 'google/longrunning/operations_pb'
14
14
  require 'google/protobuf/empty_pb'
15
15
  require 'google/protobuf/field_mask_pb'
16
+ require 'google/protobuf/timestamp_pb'
16
17
  Google::Protobuf::DescriptorPool.generated_pool.build do
17
18
  add_file("google/cloud/retail/v2/product_service.proto", :syntax => :proto3) do
18
19
  add_message "google.cloud.retail.v2.CreateProductRequest" do
@@ -26,10 +27,54 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
26
27
  add_message "google.cloud.retail.v2.UpdateProductRequest" do
27
28
  optional :product, :message, 1, "google.cloud.retail.v2.Product"
28
29
  optional :update_mask, :message, 2, "google.protobuf.FieldMask"
30
+ optional :allow_missing, :bool, 3
29
31
  end
30
32
  add_message "google.cloud.retail.v2.DeleteProductRequest" do
31
33
  optional :name, :string, 1
32
34
  end
35
+ add_message "google.cloud.retail.v2.ListProductsRequest" do
36
+ optional :parent, :string, 1
37
+ optional :page_size, :int32, 2
38
+ optional :page_token, :string, 3
39
+ optional :filter, :string, 4
40
+ optional :read_mask, :message, 5, "google.protobuf.FieldMask"
41
+ end
42
+ add_message "google.cloud.retail.v2.ListProductsResponse" do
43
+ repeated :products, :message, 1, "google.cloud.retail.v2.Product"
44
+ optional :next_page_token, :string, 2
45
+ end
46
+ add_message "google.cloud.retail.v2.SetInventoryRequest" do
47
+ optional :inventory, :message, 1, "google.cloud.retail.v2.Product"
48
+ optional :set_mask, :message, 2, "google.protobuf.FieldMask"
49
+ optional :set_time, :message, 3, "google.protobuf.Timestamp"
50
+ optional :allow_missing, :bool, 4
51
+ end
52
+ add_message "google.cloud.retail.v2.SetInventoryMetadata" do
53
+ end
54
+ add_message "google.cloud.retail.v2.SetInventoryResponse" do
55
+ end
56
+ add_message "google.cloud.retail.v2.AddFulfillmentPlacesRequest" do
57
+ optional :product, :string, 1
58
+ optional :type, :string, 2
59
+ repeated :place_ids, :string, 3
60
+ optional :add_time, :message, 4, "google.protobuf.Timestamp"
61
+ optional :allow_missing, :bool, 5
62
+ end
63
+ add_message "google.cloud.retail.v2.AddFulfillmentPlacesMetadata" do
64
+ end
65
+ add_message "google.cloud.retail.v2.AddFulfillmentPlacesResponse" do
66
+ end
67
+ add_message "google.cloud.retail.v2.RemoveFulfillmentPlacesRequest" do
68
+ optional :product, :string, 1
69
+ optional :type, :string, 2
70
+ repeated :place_ids, :string, 3
71
+ optional :remove_time, :message, 4, "google.protobuf.Timestamp"
72
+ optional :allow_missing, :bool, 5
73
+ end
74
+ add_message "google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata" do
75
+ end
76
+ add_message "google.cloud.retail.v2.RemoveFulfillmentPlacesResponse" do
77
+ end
33
78
  end
34
79
  end
35
80
 
@@ -41,6 +86,17 @@ module Google
41
86
  GetProductRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.GetProductRequest").msgclass
42
87
  UpdateProductRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.UpdateProductRequest").msgclass
43
88
  DeleteProductRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.DeleteProductRequest").msgclass
89
+ ListProductsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.ListProductsRequest").msgclass
90
+ ListProductsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.ListProductsResponse").msgclass
91
+ SetInventoryRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.SetInventoryRequest").msgclass
92
+ SetInventoryMetadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.SetInventoryMetadata").msgclass
93
+ SetInventoryResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.SetInventoryResponse").msgclass
94
+ AddFulfillmentPlacesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.AddFulfillmentPlacesRequest").msgclass
95
+ AddFulfillmentPlacesMetadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.AddFulfillmentPlacesMetadata").msgclass
96
+ AddFulfillmentPlacesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.AddFulfillmentPlacesResponse").msgclass
97
+ RemoveFulfillmentPlacesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.RemoveFulfillmentPlacesRequest").msgclass
98
+ RemoveFulfillmentPlacesMetadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata").msgclass
99
+ RemoveFulfillmentPlacesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.RemoveFulfillmentPlacesResponse").msgclass
44
100
  end
45
101
  end
46
102
  end
@@ -38,6 +38,8 @@ module Google
38
38
  rpc :CreateProduct, ::Google::Cloud::Retail::V2::CreateProductRequest, ::Google::Cloud::Retail::V2::Product
39
39
  # Gets a [Product][google.cloud.retail.v2.Product].
40
40
  rpc :GetProduct, ::Google::Cloud::Retail::V2::GetProductRequest, ::Google::Cloud::Retail::V2::Product
41
+ # Gets a list of [Product][google.cloud.retail.v2.Product]s.
42
+ rpc :ListProducts, ::Google::Cloud::Retail::V2::ListProductsRequest, ::Google::Cloud::Retail::V2::ListProductsResponse
41
43
  # Updates a [Product][google.cloud.retail.v2.Product].
42
44
  rpc :UpdateProduct, ::Google::Cloud::Retail::V2::UpdateProductRequest, ::Google::Cloud::Retail::V2::Product
43
45
  # Deletes a [Product][google.cloud.retail.v2.Product].
@@ -50,6 +52,79 @@ module Google
50
52
  # Note that it is possible for a subset of the
51
53
  # [Product][google.cloud.retail.v2.Product]s to be successfully updated.
52
54
  rpc :ImportProducts, ::Google::Cloud::Retail::V2::ImportProductsRequest, ::Google::Longrunning::Operation
55
+ # Updates inventory information for a
56
+ # [Product][google.cloud.retail.v2.Product] while respecting the last update
57
+ # timestamps of each inventory field.
58
+ #
59
+ # This process is asynchronous and does not require the
60
+ # [Product][google.cloud.retail.v2.Product] to exist before updating
61
+ # fulfillment information. If the request is valid, the update will be
62
+ # enqueued and processed downstream. As a consequence, when a response is
63
+ # returned, updates are not immediately manifested in the
64
+ # [Product][google.cloud.retail.v2.Product] queried by
65
+ # [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or
66
+ # [ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
67
+ #
68
+ # When inventory is updated with
69
+ # [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and
70
+ # [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the
71
+ # specified inventory field value(s) will overwrite any existing value(s)
72
+ # while ignoring the last update time for this field. Furthermore, the last
73
+ # update time for the specified inventory fields will be overwritten to the
74
+ # time of the
75
+ # [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or
76
+ # [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct]
77
+ # request.
78
+ #
79
+ # If no inventory fields are set in
80
+ # [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product],
81
+ # then any pre-existing inventory information for this product will be used.
82
+ #
83
+ # If no inventory fields are set in [UpdateProductRequest.set_mask][],
84
+ # then any existing inventory information will be preserved.
85
+ #
86
+ # Pre-existing inventory information can only be updated with
87
+ # [SetInventory][google.cloud.retail.v2.ProductService.SetInventory],
88
+ # [AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces],
89
+ # and
90
+ # [RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces].
91
+ #
92
+ # This feature is only available for users who have Retail Search enabled.
93
+ # Please submit a form [here](https://cloud.google.com/contact) to contact
94
+ # cloud sales if you are interested in using Retail Search.
95
+ rpc :SetInventory, ::Google::Cloud::Retail::V2::SetInventoryRequest, ::Google::Longrunning::Operation
96
+ # Incrementally adds place IDs to
97
+ # [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids].
98
+ #
99
+ # This process is asynchronous and does not require the
100
+ # [Product][google.cloud.retail.v2.Product] to exist before updating
101
+ # fulfillment information. If the request is valid, the update will be
102
+ # enqueued and processed downstream. As a consequence, when a response is
103
+ # returned, the added place IDs are not immediately manifested in the
104
+ # [Product][google.cloud.retail.v2.Product] queried by
105
+ # [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or
106
+ # [ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
107
+ #
108
+ # This feature is only available for users who have Retail Search enabled.
109
+ # Please submit a form [here](https://cloud.google.com/contact) to contact
110
+ # cloud sales if you are interested in using Retail Search.
111
+ rpc :AddFulfillmentPlaces, ::Google::Cloud::Retail::V2::AddFulfillmentPlacesRequest, ::Google::Longrunning::Operation
112
+ # Incrementally removes place IDs from a
113
+ # [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids].
114
+ #
115
+ # This process is asynchronous and does not require the
116
+ # [Product][google.cloud.retail.v2.Product] to exist before updating
117
+ # fulfillment information. If the request is valid, the update will be
118
+ # enqueued and processed downstream. As a consequence, when a response is
119
+ # returned, the removed place IDs are not immediately manifested in the
120
+ # [Product][google.cloud.retail.v2.Product] queried by
121
+ # [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or
122
+ # [ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
123
+ #
124
+ # This feature is only available for users who have Retail Search enabled.
125
+ # Please submit a form [here](https://cloud.google.com/contact) to contact
126
+ # cloud sales if you are interested in using Retail Search.
127
+ rpc :RemoveFulfillmentPlaces, ::Google::Cloud::Retail::V2::RemoveFulfillmentPlacesRequest, ::Google::Longrunning::Operation
53
128
  end
54
129
 
55
130
  Stub = Service.rpc_stub_class
@@ -0,0 +1,552 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/retail/v2/search_service_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Retail
25
+ module V2
26
+ module SearchService
27
+ ##
28
+ # Client for the SearchService service.
29
+ #
30
+ # Service for search.
31
+ #
32
+ # This feature is only available for users who have Retail Search enabled.
33
+ # Please submit a form [here](https://cloud.google.com/contact) to contact
34
+ # cloud sales if you are interested in using Retail Search.
35
+ #
36
+ class Client
37
+ include Paths
38
+
39
+ # @private
40
+ attr_reader :search_service_stub
41
+
42
+ ##
43
+ # Configure the SearchService Client class.
44
+ #
45
+ # See {::Google::Cloud::Retail::V2::SearchService::Client::Configuration}
46
+ # for a description of the configuration fields.
47
+ #
48
+ # @example
49
+ #
50
+ # # Modify the configuration for all SearchService clients
51
+ # ::Google::Cloud::Retail::V2::SearchService::Client.configure do |config|
52
+ # config.timeout = 10.0
53
+ # end
54
+ #
55
+ # @yield [config] Configure the Client client.
56
+ # @yieldparam config [Client::Configuration]
57
+ #
58
+ # @return [Client::Configuration]
59
+ #
60
+ def self.configure
61
+ @configure ||= begin
62
+ namespace = ["Google", "Cloud", "Retail", "V2"]
63
+ parent_config = while namespace.any?
64
+ parent_name = namespace.join "::"
65
+ parent_const = const_get parent_name
66
+ break parent_const.configure if parent_const.respond_to? :configure
67
+ namespace.pop
68
+ end
69
+ default_config = Client::Configuration.new parent_config
70
+
71
+ default_config.timeout = 60.0
72
+ default_config.retry_policy = {
73
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
74
+ }
75
+
76
+ default_config
77
+ end
78
+ yield @configure if block_given?
79
+ @configure
80
+ end
81
+
82
+ ##
83
+ # Configure the SearchService Client instance.
84
+ #
85
+ # The configuration is set to the derived mode, meaning that values can be changed,
86
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
87
+ # should be made on {Client.configure}.
88
+ #
89
+ # See {::Google::Cloud::Retail::V2::SearchService::Client::Configuration}
90
+ # for a description of the configuration fields.
91
+ #
92
+ # @yield [config] Configure the Client client.
93
+ # @yieldparam config [Client::Configuration]
94
+ #
95
+ # @return [Client::Configuration]
96
+ #
97
+ def configure
98
+ yield @config if block_given?
99
+ @config
100
+ end
101
+
102
+ ##
103
+ # Create a new SearchService client object.
104
+ #
105
+ # @example
106
+ #
107
+ # # Create a client using the default configuration
108
+ # client = ::Google::Cloud::Retail::V2::SearchService::Client.new
109
+ #
110
+ # # Create a client using a custom configuration
111
+ # client = ::Google::Cloud::Retail::V2::SearchService::Client.new do |config|
112
+ # config.timeout = 10.0
113
+ # end
114
+ #
115
+ # @yield [config] Configure the SearchService client.
116
+ # @yieldparam config [Client::Configuration]
117
+ #
118
+ def initialize
119
+ # These require statements are intentionally placed here to initialize
120
+ # the gRPC module only when it's required.
121
+ # See https://github.com/googleapis/toolkit/issues/446
122
+ require "gapic/grpc"
123
+ require "google/cloud/retail/v2/search_service_services_pb"
124
+
125
+ # Create the configuration object
126
+ @config = Configuration.new Client.configure
127
+
128
+ # Yield the configuration if needed
129
+ yield @config if block_given?
130
+
131
+ # Create credentials
132
+ credentials = @config.credentials
133
+ # Use self-signed JWT if the endpoint is unchanged from default,
134
+ # but only if the default endpoint does not have a region prefix.
135
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
136
+ !@config.endpoint.split(".").first.include?("-")
137
+ credentials ||= Credentials.default scope: @config.scope,
138
+ enable_self_signed_jwt: enable_self_signed_jwt
139
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
140
+ credentials = Credentials.new credentials, scope: @config.scope
141
+ end
142
+ @quota_project_id = @config.quota_project
143
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
144
+
145
+ @search_service_stub = ::Gapic::ServiceStub.new(
146
+ ::Google::Cloud::Retail::V2::SearchService::Stub,
147
+ credentials: credentials,
148
+ endpoint: @config.endpoint,
149
+ channel_args: @config.channel_args,
150
+ interceptors: @config.interceptors
151
+ )
152
+ end
153
+
154
+ # Service calls
155
+
156
+ ##
157
+ # Performs a search.
158
+ #
159
+ # This feature is only available for users who have Retail Search enabled.
160
+ # Please submit a form [here](https://cloud.google.com/contact) to contact
161
+ # cloud sales if you are interested in using Retail Search.
162
+ #
163
+ # @overload search(request, options = nil)
164
+ # Pass arguments to `search` via a request object, either of type
165
+ # {::Google::Cloud::Retail::V2::SearchRequest} or an equivalent Hash.
166
+ #
167
+ # @param request [::Google::Cloud::Retail::V2::SearchRequest, ::Hash]
168
+ # A request object representing the call parameters. Required. To specify no
169
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
170
+ # @param options [::Gapic::CallOptions, ::Hash]
171
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
172
+ #
173
+ # @overload search(placement: nil, branch: nil, query: nil, visitor_id: nil, user_info: nil, page_size: nil, page_token: nil, offset: nil, filter: nil, canonical_filter: nil, order_by: nil, facet_specs: nil, dynamic_facet_spec: nil, boost_spec: nil, query_expansion_spec: nil, variant_rollup_keys: nil, page_categories: nil)
174
+ # Pass arguments to `search` via keyword arguments. Note that at
175
+ # least one keyword argument is required. To specify no parameters, or to keep all
176
+ # the default parameter values, pass an empty Hash as a request object (see above).
177
+ #
178
+ # @param placement [::String]
179
+ # Required. The resource name of the search engine placement, such as
180
+ # `projects/*/locations/global/catalogs/default_catalog/placements/default_search`.
181
+ # This field is used to identify the set of models that will be used to make
182
+ # the search.
183
+ #
184
+ # We currently support one placement with the following ID:
185
+ #
186
+ # * `default_search`.
187
+ # @param branch [::String]
188
+ # The branch resource name, such as
189
+ # `projects/*/locations/global/catalogs/default_catalog/branches/0`.
190
+ #
191
+ # Use "default_branch" as the branch ID or leave this field empty, to search
192
+ # products under the default branch.
193
+ # @param query [::String]
194
+ # Raw search query.
195
+ # @param visitor_id [::String]
196
+ # Required. A unique identifier for tracking visitors. For example, this
197
+ # could be implemented with an HTTP cookie, which should be able to uniquely
198
+ # identify a visitor on a single device. This unique identifier should not
199
+ # change if the visitor logs in or out of the website.
200
+ #
201
+ # The field must be a UTF-8 encoded string with a length limit of 128
202
+ # characters. Otherwise, an INVALID_ARGUMENT error is returned.
203
+ # @param user_info [::Google::Cloud::Retail::V2::UserInfo, ::Hash]
204
+ # User information.
205
+ # @param page_size [::Integer]
206
+ # Maximum number of {::Google::Cloud::Retail::V2::Product Product}s to return. If
207
+ # unspecified, defaults to a reasonable value. The maximum allowed value is
208
+ # 120. Values above 120 will be coerced to 120.
209
+ #
210
+ # If this field is negative, an INVALID_ARGUMENT is returned.
211
+ # @param page_token [::String]
212
+ # A page token
213
+ # {::Google::Cloud::Retail::V2::SearchResponse#next_page_token SearchResponse.next_page_token},
214
+ # received from a previous
215
+ # {::Google::Cloud::Retail::V2::SearchService::Client#search SearchService.Search} call.
216
+ # Provide this to retrieve the subsequent page.
217
+ #
218
+ # When paginating, all other parameters provided to
219
+ # {::Google::Cloud::Retail::V2::SearchService::Client#search SearchService.Search} must
220
+ # match the call that provided the page token. Otherwise, an INVALID_ARGUMENT
221
+ # error is returned.
222
+ # @param offset [::Integer]
223
+ # A 0-indexed integer that specifies the current offset (that is, starting
224
+ # result location, amongst the {::Google::Cloud::Retail::V2::Product Product}s
225
+ # deemed by the API as relevant) in search results. This field is only
226
+ # considered if {::Google::Cloud::Retail::V2::SearchRequest#page_token page_token}
227
+ # is unset.
228
+ #
229
+ # If this field is negative, an INVALID_ARGUMENT is returned.
230
+ # @param filter [::String]
231
+ # The filter syntax consists of an expression language for constructing a
232
+ # predicate from one or more fields of the products being filtered. Filter
233
+ # expression is case-sensitive. See more details at this [user
234
+ # guide](/retail/private/docs/filter-and-order#filter).
235
+ #
236
+ # If this field is unrecognizable, an INVALID_ARGUMENT is returned.
237
+ # @param canonical_filter [::String]
238
+ # The filter applied to every search request when quality improvement such as
239
+ # query expansion is needed. For example, if a query does not have enough
240
+ # results, an expanded query with
241
+ # {::Google::Cloud::Retail::V2::SearchRequest#canonical_filter SearchRequest.canonical_filter}
242
+ # will be returned as a supplement of the original query. This field is
243
+ # strongly recommended to achieve high search quality.
244
+ #
245
+ # See {::Google::Cloud::Retail::V2::SearchRequest#filter SearchRequest.filter} for
246
+ # more details about filter syntax.
247
+ # @param order_by [::String]
248
+ # The order in which products are returned. Products can be ordered by
249
+ # a field in an {::Google::Cloud::Retail::V2::Product Product} object. Leave it
250
+ # unset if ordered by relevance. OrderBy expression is case-sensitive. See
251
+ # more details at this [user
252
+ # guide](/retail/private/docs/filter-and-order#order).
253
+ #
254
+ # If this field is unrecognizable, an INVALID_ARGUMENT is returned.
255
+ # @param facet_specs [::Array<::Google::Cloud::Retail::V2::SearchRequest::FacetSpec, ::Hash>]
256
+ # Facet specifications for faceted search. If empty, no facets are returned.
257
+ #
258
+ # A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error
259
+ # is returned.
260
+ # @param dynamic_facet_spec [::Google::Cloud::Retail::V2::SearchRequest::DynamicFacetSpec, ::Hash]
261
+ # The specification for dynamically generated facets. Notice that only
262
+ # textual facets can be dynamically generated.
263
+ #
264
+ # This feature requires additional allowlisting. Contact Retail Search
265
+ # support team if you are interested in using dynamic facet feature.
266
+ # @param boost_spec [::Google::Cloud::Retail::V2::SearchRequest::BoostSpec, ::Hash]
267
+ # Boost specification to boost certain products. See more details at this
268
+ # [user guide](/retail/private/docs/boosting).
269
+ # @param query_expansion_spec [::Google::Cloud::Retail::V2::SearchRequest::QueryExpansionSpec, ::Hash]
270
+ # The query expansion specification that specifies the conditions under which
271
+ # query expansion will occur. See more details at this [user
272
+ # guide](/retail/private/docs/result-size#query_expansion).
273
+ # @param variant_rollup_keys [::Array<::String>]
274
+ # The keys to fetch and rollup the matching
275
+ # {::Google::Cloud::Retail::V2::Product::Type::VARIANT variant}
276
+ # {::Google::Cloud::Retail::V2::Product Product}s attributes. The attributes from
277
+ # all the matching {::Google::Cloud::Retail::V2::Product::Type::VARIANT variant}
278
+ # {::Google::Cloud::Retail::V2::Product Product}s are merged and de-duplicated.
279
+ # Notice that rollup {::Google::Cloud::Retail::V2::Product::Type::VARIANT variant}
280
+ # {::Google::Cloud::Retail::V2::Product Product}s attributes will lead to extra
281
+ # query latency. Maximum number of keys is 10.
282
+ #
283
+ # For {::Google::Cloud::Retail::V2::FulfillmentInfo FulfillmentInfo}, a
284
+ # fulfillment type and a fulfillment ID must be provided in the format of
285
+ # "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123",
286
+ # "pickupInStore" is fulfillment type and "store123" is the store ID.
287
+ #
288
+ # Supported keys are:
289
+ #
290
+ # * colorFamilies
291
+ # * price
292
+ # * originalPrice
293
+ # * discount
294
+ # * attributes.key, where key is any key in the
295
+ # {::Google::Cloud::Retail::V2::Product#attributes Product.attributes} map.
296
+ # * pickupInStore.id, where id is any
297
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
298
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
299
+ # "pickup-in-store".
300
+ # * shipToStore.id, where id is any
301
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
302
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
303
+ # "ship-to-store".
304
+ # * sameDayDelivery.id, where id is any
305
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
306
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
307
+ # "same-day-delivery".
308
+ # * nextDayDelivery.id, where id is any
309
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
310
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
311
+ # "next-day-delivery".
312
+ # * customFulfillment1.id, where id is any
313
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
314
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
315
+ # "custom-type-1".
316
+ # * customFulfillment2.id, where id is any
317
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
318
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
319
+ # "custom-type-2".
320
+ # * customFulfillment3.id, where id is any
321
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
322
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
323
+ # "custom-type-3".
324
+ # * customFulfillment4.id, where id is any
325
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
326
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
327
+ # "custom-type-4".
328
+ # * customFulfillment5.id, where id is any
329
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
330
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
331
+ # "custom-type-5".
332
+ #
333
+ # If this field is set to an invalid value other than these, an
334
+ # INVALID_ARGUMENT error is returned.
335
+ # @param page_categories [::Array<::String>]
336
+ # The categories associated with a category page. Required for category
337
+ # navigation queries to achieve good search quality. The format should be
338
+ # the same as
339
+ # {::Google::Cloud::Retail::V2::UserEvent#page_categories UserEvent.page_categories};
340
+ #
341
+ # To represent full path of category, use '>' sign to separate different
342
+ # hierarchies. If '>' is part of the category name, please replace it with
343
+ # other character(s).
344
+ #
345
+ # Category pages include special pages such as sales or promotions. For
346
+ # instance, a special sale page may have the category hierarchy:
347
+ # "pageCategories" : ["Sales > 2017 Black Friday Deals"].
348
+ #
349
+ # @yield [response, operation] Access the result along with the RPC operation
350
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::SearchResponse::SearchResult>]
351
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
352
+ #
353
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::SearchResponse::SearchResult>]
354
+ #
355
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
356
+ #
357
+ def search request, options = nil
358
+ raise ::ArgumentError, "request must be provided" if request.nil?
359
+
360
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::SearchRequest
361
+
362
+ # Converts hash and nil to an options object
363
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
364
+
365
+ # Customize the options with defaults
366
+ metadata = @config.rpcs.search.metadata.to_h
367
+
368
+ # Set x-goog-api-client and x-goog-user-project headers
369
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
370
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
371
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION
372
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
373
+
374
+ header_params = {
375
+ "placement" => request.placement
376
+ }
377
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
378
+ metadata[:"x-goog-request-params"] ||= request_params_header
379
+
380
+ options.apply_defaults timeout: @config.rpcs.search.timeout,
381
+ metadata: metadata,
382
+ retry_policy: @config.rpcs.search.retry_policy
383
+
384
+ options.apply_defaults timeout: @config.timeout,
385
+ metadata: @config.metadata,
386
+ retry_policy: @config.retry_policy
387
+
388
+ @search_service_stub.call_rpc :search, request, options: options do |response, operation|
389
+ response = ::Gapic::PagedEnumerable.new @search_service_stub, :search, request, response, operation, options
390
+ yield response, operation if block_given?
391
+ return response
392
+ end
393
+ rescue ::GRPC::BadStatus => e
394
+ raise ::Google::Cloud::Error.from_error(e)
395
+ end
396
+
397
+ ##
398
+ # Configuration class for the SearchService API.
399
+ #
400
+ # This class represents the configuration for SearchService,
401
+ # providing control over timeouts, retry behavior, logging, transport
402
+ # parameters, and other low-level controls. Certain parameters can also be
403
+ # applied individually to specific RPCs. See
404
+ # {::Google::Cloud::Retail::V2::SearchService::Client::Configuration::Rpcs}
405
+ # for a list of RPCs that can be configured independently.
406
+ #
407
+ # Configuration can be applied globally to all clients, or to a single client
408
+ # on construction.
409
+ #
410
+ # @example
411
+ #
412
+ # # Modify the global config, setting the timeout for
413
+ # # search to 20 seconds,
414
+ # # and all remaining timeouts to 10 seconds.
415
+ # ::Google::Cloud::Retail::V2::SearchService::Client.configure do |config|
416
+ # config.timeout = 10.0
417
+ # config.rpcs.search.timeout = 20.0
418
+ # end
419
+ #
420
+ # # Apply the above configuration only to a new client.
421
+ # client = ::Google::Cloud::Retail::V2::SearchService::Client.new do |config|
422
+ # config.timeout = 10.0
423
+ # config.rpcs.search.timeout = 20.0
424
+ # end
425
+ #
426
+ # @!attribute [rw] endpoint
427
+ # The hostname or hostname:port of the service endpoint.
428
+ # Defaults to `"retail.googleapis.com"`.
429
+ # @return [::String]
430
+ # @!attribute [rw] credentials
431
+ # Credentials to send with calls. You may provide any of the following types:
432
+ # * (`String`) The path to a service account key file in JSON format
433
+ # * (`Hash`) A service account key as a Hash
434
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
435
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
436
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
437
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
438
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
439
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
440
+ # * (`nil`) indicating no credentials
441
+ # @return [::Object]
442
+ # @!attribute [rw] scope
443
+ # The OAuth scopes
444
+ # @return [::Array<::String>]
445
+ # @!attribute [rw] lib_name
446
+ # The library name as recorded in instrumentation and logging
447
+ # @return [::String]
448
+ # @!attribute [rw] lib_version
449
+ # The library version as recorded in instrumentation and logging
450
+ # @return [::String]
451
+ # @!attribute [rw] channel_args
452
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
453
+ # `GRPC::Core::Channel` object is provided as the credential.
454
+ # @return [::Hash]
455
+ # @!attribute [rw] interceptors
456
+ # An array of interceptors that are run before calls are executed.
457
+ # @return [::Array<::GRPC::ClientInterceptor>]
458
+ # @!attribute [rw] timeout
459
+ # The call timeout in seconds.
460
+ # @return [::Numeric]
461
+ # @!attribute [rw] metadata
462
+ # Additional gRPC headers to be sent with the call.
463
+ # @return [::Hash{::Symbol=>::String}]
464
+ # @!attribute [rw] retry_policy
465
+ # The retry policy. The value is a hash with the following keys:
466
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
467
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
468
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
469
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
470
+ # trigger a retry.
471
+ # @return [::Hash]
472
+ # @!attribute [rw] quota_project
473
+ # A separate project against which to charge quota.
474
+ # @return [::String]
475
+ #
476
+ class Configuration
477
+ extend ::Gapic::Config
478
+
479
+ config_attr :endpoint, "retail.googleapis.com", ::String
480
+ config_attr :credentials, nil do |value|
481
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
482
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
483
+ allowed.any? { |klass| klass === value }
484
+ end
485
+ config_attr :scope, nil, ::String, ::Array, nil
486
+ config_attr :lib_name, nil, ::String, nil
487
+ config_attr :lib_version, nil, ::String, nil
488
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
489
+ config_attr :interceptors, nil, ::Array, nil
490
+ config_attr :timeout, nil, ::Numeric, nil
491
+ config_attr :metadata, nil, ::Hash, nil
492
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
493
+ config_attr :quota_project, nil, ::String, nil
494
+
495
+ # @private
496
+ def initialize parent_config = nil
497
+ @parent_config = parent_config unless parent_config.nil?
498
+
499
+ yield self if block_given?
500
+ end
501
+
502
+ ##
503
+ # Configurations for individual RPCs
504
+ # @return [Rpcs]
505
+ #
506
+ def rpcs
507
+ @rpcs ||= begin
508
+ parent_rpcs = nil
509
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
510
+ Rpcs.new parent_rpcs
511
+ end
512
+ end
513
+
514
+ ##
515
+ # Configuration RPC class for the SearchService API.
516
+ #
517
+ # Includes fields providing the configuration for each RPC in this service.
518
+ # Each configuration object is of type `Gapic::Config::Method` and includes
519
+ # the following configuration fields:
520
+ #
521
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
522
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
523
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
524
+ # include the following keys:
525
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
526
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
527
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
528
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
529
+ # trigger a retry.
530
+ #
531
+ class Rpcs
532
+ ##
533
+ # RPC-specific configuration for `search`
534
+ # @return [::Gapic::Config::Method]
535
+ #
536
+ attr_reader :search
537
+
538
+ # @private
539
+ def initialize parent_rpcs = nil
540
+ search_config = parent_rpcs.search if parent_rpcs.respond_to? :search
541
+ @search = ::Gapic::Config::Method.new search_config
542
+
543
+ yield self if block_given?
544
+ end
545
+ end
546
+ end
547
+ end
548
+ end
549
+ end
550
+ end
551
+ end
552
+ end