google-cloud-retail-v2 0.3.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +8 -8
  3. data/README.md +1 -1
  4. data/lib/google/cloud/retail/v2.rb +2 -0
  5. data/lib/google/cloud/retail/v2/catalog_pb.rb +2 -0
  6. data/lib/google/cloud/retail/v2/catalog_service/client.rb +242 -45
  7. data/lib/google/cloud/retail/v2/catalog_service/paths.rb +21 -0
  8. data/lib/google/cloud/retail/v2/catalog_service_pb.rb +16 -0
  9. data/lib/google/cloud/retail/v2/catalog_service_services_pb.rb +47 -1
  10. data/lib/google/cloud/retail/v2/common_pb.rb +46 -0
  11. data/lib/google/cloud/retail/v2/completion_service.rb +54 -0
  12. data/lib/google/cloud/retail/v2/completion_service/client.rb +543 -0
  13. data/lib/google/cloud/retail/v2/completion_service/credentials.rb +51 -0
  14. data/lib/google/cloud/retail/v2/completion_service/operations.rb +664 -0
  15. data/lib/google/cloud/retail/v2/completion_service/paths.rb +52 -0
  16. data/lib/google/cloud/retail/v2/completion_service_pb.rb +50 -0
  17. data/lib/google/cloud/retail/v2/completion_service_services_pb.rb +61 -0
  18. data/lib/google/cloud/retail/v2/import_config_pb.rb +32 -0
  19. data/lib/google/cloud/retail/v2/prediction_service/client.rb +68 -75
  20. data/lib/google/cloud/retail/v2/prediction_service_services_pb.rb +1 -1
  21. data/lib/google/cloud/retail/v2/product_pb.rb +21 -0
  22. data/lib/google/cloud/retail/v2/product_service/client.rb +684 -48
  23. data/lib/google/cloud/retail/v2/product_service/operations.rb +34 -25
  24. data/lib/google/cloud/retail/v2/product_service_pb.rb +56 -0
  25. data/lib/google/cloud/retail/v2/product_service_services_pb.rb +76 -1
  26. data/lib/google/cloud/retail/v2/search_service.rb +53 -0
  27. data/lib/google/cloud/retail/v2/search_service/client.rb +531 -0
  28. data/lib/google/cloud/retail/v2/search_service/credentials.rb +51 -0
  29. data/lib/google/cloud/retail/v2/search_service/paths.rb +54 -0
  30. data/lib/google/cloud/retail/v2/search_service_pb.rb +131 -0
  31. data/lib/google/cloud/retail/v2/search_service_services_pb.rb +53 -0
  32. data/lib/google/cloud/retail/v2/user_event_pb.rb +11 -0
  33. data/lib/google/cloud/retail/v2/user_event_service/client.rb +47 -47
  34. data/lib/google/cloud/retail/v2/user_event_service/operations.rb +34 -25
  35. data/lib/google/cloud/retail/v2/user_event_service/paths.rb +19 -0
  36. data/lib/google/cloud/retail/v2/user_event_service_services_pb.rb +1 -1
  37. data/lib/google/cloud/retail/v2/version.rb +1 -1
  38. data/proto_docs/google/api/field_behavior.rb +7 -1
  39. data/proto_docs/google/api/httpbody.rb +4 -3
  40. data/proto_docs/google/cloud/retail/v2/catalog.rb +6 -6
  41. data/proto_docs/google/cloud/retail/v2/catalog_service.rb +53 -4
  42. data/proto_docs/google/cloud/retail/v2/common.rb +272 -4
  43. data/proto_docs/google/cloud/retail/v2/completion_service.rb +162 -0
  44. data/proto_docs/google/cloud/retail/v2/import_config.rb +122 -6
  45. data/proto_docs/google/cloud/retail/v2/prediction_service.rb +32 -31
  46. data/proto_docs/google/cloud/retail/v2/product.rb +266 -10
  47. data/proto_docs/google/cloud/retail/v2/product_service.rb +362 -2
  48. data/proto_docs/google/cloud/retail/v2/purge_config.rb +1 -1
  49. data/proto_docs/google/cloud/retail/v2/search_service.rb +681 -0
  50. data/proto_docs/google/cloud/retail/v2/user_event.rb +95 -3
  51. data/proto_docs/google/type/date.rb +53 -0
  52. metadata +20 -4
@@ -26,6 +26,19 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
26
26
  optional :catalog, :message, 1, "google.cloud.retail.v2.Catalog"
27
27
  optional :update_mask, :message, 2, "google.protobuf.FieldMask"
28
28
  end
29
+ add_message "google.cloud.retail.v2.SetDefaultBranchRequest" do
30
+ optional :catalog, :string, 1
31
+ optional :branch_id, :string, 2
32
+ optional :note, :string, 3
33
+ end
34
+ add_message "google.cloud.retail.v2.GetDefaultBranchRequest" do
35
+ optional :catalog, :string, 1
36
+ end
37
+ add_message "google.cloud.retail.v2.GetDefaultBranchResponse" do
38
+ optional :branch, :string, 1
39
+ optional :set_time, :message, 2, "google.protobuf.Timestamp"
40
+ optional :note, :string, 3
41
+ end
29
42
  end
30
43
  end
31
44
 
@@ -36,6 +49,9 @@ module Google
36
49
  ListCatalogsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.ListCatalogsRequest").msgclass
37
50
  ListCatalogsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.ListCatalogsResponse").msgclass
38
51
  UpdateCatalogRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.UpdateCatalogRequest").msgclass
52
+ SetDefaultBranchRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.SetDefaultBranchRequest").msgclass
53
+ GetDefaultBranchRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.GetDefaultBranchRequest").msgclass
54
+ GetDefaultBranchResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.GetDefaultBranchResponse").msgclass
39
55
  end
40
56
  end
41
57
  end
@@ -27,7 +27,7 @@ module Google
27
27
  # Service for managing catalog configuration.
28
28
  class Service
29
29
 
30
- include ::GRPC::GenericService
30
+ include GRPC::GenericService
31
31
 
32
32
  self.marshal_class_method = :encode
33
33
  self.unmarshal_class_method = :decode
@@ -38,6 +38,52 @@ module Google
38
38
  rpc :ListCatalogs, ::Google::Cloud::Retail::V2::ListCatalogsRequest, ::Google::Cloud::Retail::V2::ListCatalogsResponse
39
39
  # Updates the [Catalog][google.cloud.retail.v2.Catalog]s.
40
40
  rpc :UpdateCatalog, ::Google::Cloud::Retail::V2::UpdateCatalogRequest, ::Google::Cloud::Retail::V2::Catalog
41
+ # Set a specified branch id as default branch. API methods such as
42
+ # [SearchService.Search][google.cloud.retail.v2.SearchService.Search],
43
+ # [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct],
44
+ # [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]
45
+ # will treat requests using "default_branch" to the actual branch id set as
46
+ # default.
47
+ #
48
+ # For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as
49
+ # default, setting
50
+ # [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
51
+ # `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent
52
+ # to setting
53
+ # [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
54
+ # `projects/*/locations/*/catalogs/*/branches/1`.
55
+ #
56
+ # Using multiple branches can be useful when developers would like
57
+ # to have a staging branch to test and verify for future usage. When it
58
+ # becomes ready, developers switch on the staging branch using this API while
59
+ # keeping using `projects/*/locations/*/catalogs/*/branches/default_branch`
60
+ # as [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
61
+ # route the traffic to this staging branch.
62
+ #
63
+ # CAUTION: If you have live predict/search traffic, switching the default
64
+ # branch could potentially cause outages if the ID space of the new branch is
65
+ # very different from the old one.
66
+ #
67
+ # More specifically:
68
+ #
69
+ # * PredictionService will only return product IDs from branch {newBranch}.
70
+ # * SearchService will only return product IDs from branch {newBranch}
71
+ # (if branch is not explicitly set).
72
+ # * UserEventService will only join events with products from branch
73
+ # {newBranch}.
74
+ #
75
+ # This feature is only available for users who have Retail Search enabled.
76
+ # Contact Retail Support (retail-search-support@google.com) if you are
77
+ # interested in using Retail Search.
78
+ rpc :SetDefaultBranch, ::Google::Cloud::Retail::V2::SetDefaultBranchRequest, ::Google::Protobuf::Empty
79
+ # Get which branch is currently default branch set by
80
+ # [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch]
81
+ # method under a specified parent catalog.
82
+ #
83
+ # This feature is only available for users who have Retail Search enabled.
84
+ # Contact Retail Support (retail-search-support@google.com) if you are
85
+ # interested in using Retail Search.
86
+ rpc :GetDefaultBranch, ::Google::Cloud::Retail::V2::GetDefaultBranchRequest, ::Google::Cloud::Retail::V2::GetDefaultBranchResponse
41
87
  end
42
88
 
43
89
  Stub = Service.rpc_stub_class
@@ -8,20 +8,56 @@ require 'google/api/field_behavior_pb'
8
8
  require 'google/protobuf/timestamp_pb'
9
9
  Google::Protobuf::DescriptorPool.generated_pool.build do
10
10
  add_file("google/cloud/retail/v2/common.proto", :syntax => :proto3) do
11
+ add_message "google.cloud.retail.v2.Audience" do
12
+ repeated :genders, :string, 1
13
+ repeated :age_groups, :string, 2
14
+ end
15
+ add_message "google.cloud.retail.v2.ColorInfo" do
16
+ repeated :color_families, :string, 1
17
+ repeated :colors, :string, 2
18
+ end
11
19
  add_message "google.cloud.retail.v2.CustomAttribute" do
12
20
  repeated :text, :string, 1
13
21
  repeated :numbers, :double, 2
22
+ proto3_optional :searchable, :bool, 3
23
+ proto3_optional :indexable, :bool, 4
24
+ end
25
+ add_message "google.cloud.retail.v2.FulfillmentInfo" do
26
+ optional :type, :string, 1
27
+ repeated :place_ids, :string, 2
14
28
  end
15
29
  add_message "google.cloud.retail.v2.Image" do
16
30
  optional :uri, :string, 1
17
31
  optional :height, :int32, 2
18
32
  optional :width, :int32, 3
19
33
  end
34
+ add_message "google.cloud.retail.v2.Interval" do
35
+ oneof :min do
36
+ optional :minimum, :double, 1
37
+ optional :exclusive_minimum, :double, 2
38
+ end
39
+ oneof :max do
40
+ optional :maximum, :double, 3
41
+ optional :exclusive_maximum, :double, 4
42
+ end
43
+ end
20
44
  add_message "google.cloud.retail.v2.PriceInfo" do
21
45
  optional :currency_code, :string, 1
22
46
  optional :price, :float, 2
23
47
  optional :original_price, :float, 3
24
48
  optional :cost, :float, 4
49
+ optional :price_effective_time, :message, 5, "google.protobuf.Timestamp"
50
+ optional :price_expire_time, :message, 6, "google.protobuf.Timestamp"
51
+ optional :price_range, :message, 7, "google.cloud.retail.v2.PriceInfo.PriceRange"
52
+ end
53
+ add_message "google.cloud.retail.v2.PriceInfo.PriceRange" do
54
+ optional :price, :message, 1, "google.cloud.retail.v2.Interval"
55
+ optional :original_price, :message, 2, "google.cloud.retail.v2.Interval"
56
+ end
57
+ add_message "google.cloud.retail.v2.Rating" do
58
+ optional :rating_count, :int32, 1
59
+ optional :average_rating, :float, 2
60
+ repeated :rating_histogram, :int32, 3
25
61
  end
26
62
  add_message "google.cloud.retail.v2.UserInfo" do
27
63
  optional :user_id, :string, 1
@@ -29,6 +65,9 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
29
65
  optional :user_agent, :string, 3
30
66
  optional :direct_user_request, :bool, 4
31
67
  end
68
+ add_message "google.cloud.retail.v2.Promotion" do
69
+ optional :promotion_id, :string, 1
70
+ end
32
71
  end
33
72
  end
34
73
 
@@ -36,10 +75,17 @@ module Google
36
75
  module Cloud
37
76
  module Retail
38
77
  module V2
78
+ Audience = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.Audience").msgclass
79
+ ColorInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.ColorInfo").msgclass
39
80
  CustomAttribute = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.CustomAttribute").msgclass
81
+ FulfillmentInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.FulfillmentInfo").msgclass
40
82
  Image = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.Image").msgclass
83
+ Interval = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.Interval").msgclass
41
84
  PriceInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.PriceInfo").msgclass
85
+ PriceInfo::PriceRange = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.PriceInfo.PriceRange").msgclass
86
+ Rating = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.Rating").msgclass
42
87
  UserInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.UserInfo").msgclass
88
+ Promotion = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.Promotion").msgclass
43
89
  end
44
90
  end
45
91
  end
@@ -0,0 +1,54 @@
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 "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/retail/v2/version"
24
+
25
+ require "google/cloud/retail/v2/completion_service/credentials"
26
+ require "google/cloud/retail/v2/completion_service/paths"
27
+ require "google/cloud/retail/v2/completion_service/operations"
28
+ require "google/cloud/retail/v2/completion_service/client"
29
+
30
+ module Google
31
+ module Cloud
32
+ module Retail
33
+ module V2
34
+ ##
35
+ # Auto-completion service for retail.
36
+ #
37
+ # This feature is only available for users who have Retail Search enabled.
38
+ # Contact Retail Support (retail-search-support@google.com) if you are
39
+ # interested in using Retail Search.
40
+ #
41
+ # To load this service and instantiate a client:
42
+ #
43
+ # require "google/cloud/retail/v2/completion_service"
44
+ # client = ::Google::Cloud::Retail::V2::CompletionService::Client.new
45
+ #
46
+ module CompletionService
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ helper_path = ::File.join __dir__, "completion_service", "helpers.rb"
54
+ require "google/cloud/retail/v2/completion_service/helpers" if ::File.file? helper_path
@@ -0,0 +1,543 @@
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/completion_service_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Retail
25
+ module V2
26
+ module CompletionService
27
+ ##
28
+ # Client for the CompletionService service.
29
+ #
30
+ # Auto-completion service for retail.
31
+ #
32
+ # This feature is only available for users who have Retail Search enabled.
33
+ # Contact Retail Support (retail-search-support@google.com) if you are
34
+ # interested in using Retail Search.
35
+ #
36
+ class Client
37
+ include Paths
38
+
39
+ # @private
40
+ attr_reader :completion_service_stub
41
+
42
+ ##
43
+ # Configure the CompletionService Client class.
44
+ #
45
+ # See {::Google::Cloud::Retail::V2::CompletionService::Client::Configuration}
46
+ # for a description of the configuration fields.
47
+ #
48
+ # @example
49
+ #
50
+ # # Modify the configuration for all CompletionService clients
51
+ # ::Google::Cloud::Retail::V2::CompletionService::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 CompletionService 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::CompletionService::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 CompletionService client object.
104
+ #
105
+ # @example
106
+ #
107
+ # # Create a client using the default configuration
108
+ # client = ::Google::Cloud::Retail::V2::CompletionService::Client.new
109
+ #
110
+ # # Create a client using a custom configuration
111
+ # client = ::Google::Cloud::Retail::V2::CompletionService::Client.new do |config|
112
+ # config.timeout = 10.0
113
+ # end
114
+ #
115
+ # @yield [config] Configure the CompletionService 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/completion_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
+ @operations_client = Operations.new do |config|
146
+ config.credentials = credentials
147
+ config.endpoint = @config.endpoint
148
+ end
149
+
150
+ @completion_service_stub = ::Gapic::ServiceStub.new(
151
+ ::Google::Cloud::Retail::V2::CompletionService::Stub,
152
+ credentials: credentials,
153
+ endpoint: @config.endpoint,
154
+ channel_args: @config.channel_args,
155
+ interceptors: @config.interceptors
156
+ )
157
+ end
158
+
159
+ ##
160
+ # Get the associated client for long-running operations.
161
+ #
162
+ # @return [::Google::Cloud::Retail::V2::CompletionService::Operations]
163
+ #
164
+ attr_reader :operations_client
165
+
166
+ # Service calls
167
+
168
+ ##
169
+ # Completes the specified prefix with keyword suggestions.
170
+ #
171
+ # This feature is only available for users who have Retail Search enabled.
172
+ # Contact Retail Support (retail-search-support@google.com) if you are
173
+ # interested in using Retail Search.
174
+ #
175
+ # @overload complete_query(request, options = nil)
176
+ # Pass arguments to `complete_query` via a request object, either of type
177
+ # {::Google::Cloud::Retail::V2::CompleteQueryRequest} or an equivalent Hash.
178
+ #
179
+ # @param request [::Google::Cloud::Retail::V2::CompleteQueryRequest, ::Hash]
180
+ # A request object representing the call parameters. Required. To specify no
181
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
182
+ # @param options [::Gapic::CallOptions, ::Hash]
183
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
184
+ #
185
+ # @overload complete_query(catalog: nil, query: nil, visitor_id: nil, language_codes: nil, device_type: nil, dataset: nil, max_suggestions: nil)
186
+ # Pass arguments to `complete_query` via keyword arguments. Note that at
187
+ # least one keyword argument is required. To specify no parameters, or to keep all
188
+ # the default parameter values, pass an empty Hash as a request object (see above).
189
+ #
190
+ # @param catalog [::String]
191
+ # Required. Catalog for which the completion is performed.
192
+ #
193
+ # Full resource name of catalog, such as
194
+ # `projects/*/locations/global/catalogs/default_catalog`.
195
+ # @param query [::String]
196
+ # Required. The query used to generate suggestions.
197
+ #
198
+ # The maximum number of allowed characters is 255.
199
+ # @param visitor_id [::String]
200
+ # A unique identifier for tracking visitors. For example, this could be
201
+ # implemented with an HTTP cookie, which should be able to uniquely identify
202
+ # a visitor on a single device. This unique identifier should not change if
203
+ # the visitor logs in or out of the website.
204
+ #
205
+ # The field must be a UTF-8 encoded string with a length limit of 128
206
+ # characters. Otherwise, an INVALID_ARGUMENT error is returned.
207
+ # @param language_codes [::Array<::String>]
208
+ # The list of languages of the query. This is
209
+ # the BCP-47 language code, such as "en-US" or "sr-Latn".
210
+ # For more information, see
211
+ # [Tags for Identifying Languages](https://tools.ietf.org/html/bcp47).
212
+ #
213
+ # The maximum number of allowed characters is 255.
214
+ # Only "en-US" is currently supported.
215
+ # @param device_type [::String]
216
+ # The device type context for completion suggestions.
217
+ # It is useful to apply different suggestions on different device types, e.g.
218
+ # DESKTOP, MOBILE. If it is empty, the suggestions are across all device
219
+ # types.
220
+ #
221
+ # Supported formats:
222
+ #
223
+ # * UNKNOWN_DEVICE_TYPE
224
+ #
225
+ # * DESKTOP
226
+ #
227
+ # * MOBILE
228
+ #
229
+ # * A customized string starts with OTHER_, e.g. OTHER_IPHONE.
230
+ # @param dataset [::String]
231
+ # Determines which dataset to use for fetching completion. "user-data" will
232
+ # use the imported dataset through
233
+ # {::Google::Cloud::Retail::V2::CompletionService::Client#import_completion_data CompletionService.ImportCompletionData}.
234
+ # "cloud-retail" will use the dataset generated by cloud retail based on user
235
+ # events. If leave empty, it will use the "user-data".
236
+ #
237
+ # Current supported values:
238
+ #
239
+ # * user-data
240
+ #
241
+ # * cloud-retail
242
+ # This option is not automatically enabled. Before using cloud-retail,
243
+ # contact retail-search-support@google.com first.
244
+ # @param max_suggestions [::Integer]
245
+ # Completion max suggestions.
246
+ #
247
+ # The maximum allowed max suggestions is 20. The default value is 20.
248
+ #
249
+ # @yield [response, operation] Access the result along with the RPC operation
250
+ # @yieldparam response [::Google::Cloud::Retail::V2::CompleteQueryResponse]
251
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
252
+ #
253
+ # @return [::Google::Cloud::Retail::V2::CompleteQueryResponse]
254
+ #
255
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
256
+ #
257
+ def complete_query request, options = nil
258
+ raise ::ArgumentError, "request must be provided" if request.nil?
259
+
260
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::CompleteQueryRequest
261
+
262
+ # Converts hash and nil to an options object
263
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
264
+
265
+ # Customize the options with defaults
266
+ metadata = @config.rpcs.complete_query.metadata.to_h
267
+
268
+ # Set x-goog-api-client and x-goog-user-project headers
269
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
270
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
271
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION
272
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
273
+
274
+ header_params = {
275
+ "catalog" => request.catalog
276
+ }
277
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
278
+ metadata[:"x-goog-request-params"] ||= request_params_header
279
+
280
+ options.apply_defaults timeout: @config.rpcs.complete_query.timeout,
281
+ metadata: metadata,
282
+ retry_policy: @config.rpcs.complete_query.retry_policy
283
+
284
+ options.apply_defaults timeout: @config.timeout,
285
+ metadata: @config.metadata,
286
+ retry_policy: @config.retry_policy
287
+
288
+ @completion_service_stub.call_rpc :complete_query, request, options: options do |response, operation|
289
+ yield response, operation if block_given?
290
+ return response
291
+ end
292
+ rescue ::GRPC::BadStatus => e
293
+ raise ::Google::Cloud::Error.from_error(e)
294
+ end
295
+
296
+ ##
297
+ # Bulk import of processed completion dataset.
298
+ #
299
+ # Request processing may be synchronous. Partial updating is not supported.
300
+ #
301
+ # This feature is only available for users who have Retail Search enabled.
302
+ # Contact Retail Support (retail-search-support@google.com) if you are
303
+ # interested in using Retail Search.
304
+ #
305
+ # @overload import_completion_data(request, options = nil)
306
+ # Pass arguments to `import_completion_data` via a request object, either of type
307
+ # {::Google::Cloud::Retail::V2::ImportCompletionDataRequest} or an equivalent Hash.
308
+ #
309
+ # @param request [::Google::Cloud::Retail::V2::ImportCompletionDataRequest, ::Hash]
310
+ # A request object representing the call parameters. Required. To specify no
311
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
312
+ # @param options [::Gapic::CallOptions, ::Hash]
313
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
314
+ #
315
+ # @overload import_completion_data(parent: nil, input_config: nil, notification_pubsub_topic: nil)
316
+ # Pass arguments to `import_completion_data` via keyword arguments. Note that at
317
+ # least one keyword argument is required. To specify no parameters, or to keep all
318
+ # the default parameter values, pass an empty Hash as a request object (see above).
319
+ #
320
+ # @param parent [::String]
321
+ # Required. The catalog which the suggestions dataset belongs to.
322
+ #
323
+ # Format: `projects/1234/locations/global/catalogs/default_catalog`.
324
+ # @param input_config [::Google::Cloud::Retail::V2::CompletionDataInputConfig, ::Hash]
325
+ # Required. The desired input location of the data.
326
+ # @param notification_pubsub_topic [::String]
327
+ # Pub/Sub topic for receiving notification. If this field is set,
328
+ # when the import is finished, a notification will be sent to
329
+ # specified Pub/Sub topic. The message data will be JSON string of a
330
+ # {::Google::Longrunning::Operation Operation}.
331
+ # Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`.
332
+ #
333
+ # @yield [response, operation] Access the result along with the RPC operation
334
+ # @yieldparam response [::Gapic::Operation]
335
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
336
+ #
337
+ # @return [::Gapic::Operation]
338
+ #
339
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
340
+ #
341
+ def import_completion_data request, options = nil
342
+ raise ::ArgumentError, "request must be provided" if request.nil?
343
+
344
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::ImportCompletionDataRequest
345
+
346
+ # Converts hash and nil to an options object
347
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
348
+
349
+ # Customize the options with defaults
350
+ metadata = @config.rpcs.import_completion_data.metadata.to_h
351
+
352
+ # Set x-goog-api-client and x-goog-user-project headers
353
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
354
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
355
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION
356
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
357
+
358
+ header_params = {
359
+ "parent" => request.parent
360
+ }
361
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
362
+ metadata[:"x-goog-request-params"] ||= request_params_header
363
+
364
+ options.apply_defaults timeout: @config.rpcs.import_completion_data.timeout,
365
+ metadata: metadata,
366
+ retry_policy: @config.rpcs.import_completion_data.retry_policy
367
+
368
+ options.apply_defaults timeout: @config.timeout,
369
+ metadata: @config.metadata,
370
+ retry_policy: @config.retry_policy
371
+
372
+ @completion_service_stub.call_rpc :import_completion_data, request, options: options do |response, operation|
373
+ response = ::Gapic::Operation.new response, @operations_client, options: options
374
+ yield response, operation if block_given?
375
+ return response
376
+ end
377
+ rescue ::GRPC::BadStatus => e
378
+ raise ::Google::Cloud::Error.from_error(e)
379
+ end
380
+
381
+ ##
382
+ # Configuration class for the CompletionService API.
383
+ #
384
+ # This class represents the configuration for CompletionService,
385
+ # providing control over timeouts, retry behavior, logging, transport
386
+ # parameters, and other low-level controls. Certain parameters can also be
387
+ # applied individually to specific RPCs. See
388
+ # {::Google::Cloud::Retail::V2::CompletionService::Client::Configuration::Rpcs}
389
+ # for a list of RPCs that can be configured independently.
390
+ #
391
+ # Configuration can be applied globally to all clients, or to a single client
392
+ # on construction.
393
+ #
394
+ # @example
395
+ #
396
+ # # Modify the global config, setting the timeout for
397
+ # # complete_query to 20 seconds,
398
+ # # and all remaining timeouts to 10 seconds.
399
+ # ::Google::Cloud::Retail::V2::CompletionService::Client.configure do |config|
400
+ # config.timeout = 10.0
401
+ # config.rpcs.complete_query.timeout = 20.0
402
+ # end
403
+ #
404
+ # # Apply the above configuration only to a new client.
405
+ # client = ::Google::Cloud::Retail::V2::CompletionService::Client.new do |config|
406
+ # config.timeout = 10.0
407
+ # config.rpcs.complete_query.timeout = 20.0
408
+ # end
409
+ #
410
+ # @!attribute [rw] endpoint
411
+ # The hostname or hostname:port of the service endpoint.
412
+ # Defaults to `"retail.googleapis.com"`.
413
+ # @return [::String]
414
+ # @!attribute [rw] credentials
415
+ # Credentials to send with calls. You may provide any of the following types:
416
+ # * (`String`) The path to a service account key file in JSON format
417
+ # * (`Hash`) A service account key as a Hash
418
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
419
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
420
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
421
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
422
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
423
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
424
+ # * (`nil`) indicating no credentials
425
+ # @return [::Object]
426
+ # @!attribute [rw] scope
427
+ # The OAuth scopes
428
+ # @return [::Array<::String>]
429
+ # @!attribute [rw] lib_name
430
+ # The library name as recorded in instrumentation and logging
431
+ # @return [::String]
432
+ # @!attribute [rw] lib_version
433
+ # The library version as recorded in instrumentation and logging
434
+ # @return [::String]
435
+ # @!attribute [rw] channel_args
436
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
437
+ # `GRPC::Core::Channel` object is provided as the credential.
438
+ # @return [::Hash]
439
+ # @!attribute [rw] interceptors
440
+ # An array of interceptors that are run before calls are executed.
441
+ # @return [::Array<::GRPC::ClientInterceptor>]
442
+ # @!attribute [rw] timeout
443
+ # The call timeout in seconds.
444
+ # @return [::Numeric]
445
+ # @!attribute [rw] metadata
446
+ # Additional gRPC headers to be sent with the call.
447
+ # @return [::Hash{::Symbol=>::String}]
448
+ # @!attribute [rw] retry_policy
449
+ # The retry policy. The value is a hash with the following keys:
450
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
451
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
452
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
453
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
454
+ # trigger a retry.
455
+ # @return [::Hash]
456
+ # @!attribute [rw] quota_project
457
+ # A separate project against which to charge quota.
458
+ # @return [::String]
459
+ #
460
+ class Configuration
461
+ extend ::Gapic::Config
462
+
463
+ config_attr :endpoint, "retail.googleapis.com", ::String
464
+ config_attr :credentials, nil do |value|
465
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
466
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
467
+ allowed.any? { |klass| klass === value }
468
+ end
469
+ config_attr :scope, nil, ::String, ::Array, nil
470
+ config_attr :lib_name, nil, ::String, nil
471
+ config_attr :lib_version, nil, ::String, nil
472
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
473
+ config_attr :interceptors, nil, ::Array, nil
474
+ config_attr :timeout, nil, ::Numeric, nil
475
+ config_attr :metadata, nil, ::Hash, nil
476
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
477
+ config_attr :quota_project, nil, ::String, nil
478
+
479
+ # @private
480
+ def initialize parent_config = nil
481
+ @parent_config = parent_config unless parent_config.nil?
482
+
483
+ yield self if block_given?
484
+ end
485
+
486
+ ##
487
+ # Configurations for individual RPCs
488
+ # @return [Rpcs]
489
+ #
490
+ def rpcs
491
+ @rpcs ||= begin
492
+ parent_rpcs = nil
493
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
494
+ Rpcs.new parent_rpcs
495
+ end
496
+ end
497
+
498
+ ##
499
+ # Configuration RPC class for the CompletionService API.
500
+ #
501
+ # Includes fields providing the configuration for each RPC in this service.
502
+ # Each configuration object is of type `Gapic::Config::Method` and includes
503
+ # the following configuration fields:
504
+ #
505
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
506
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
507
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
508
+ # include the following keys:
509
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
510
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
511
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
512
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
513
+ # trigger a retry.
514
+ #
515
+ class Rpcs
516
+ ##
517
+ # RPC-specific configuration for `complete_query`
518
+ # @return [::Gapic::Config::Method]
519
+ #
520
+ attr_reader :complete_query
521
+ ##
522
+ # RPC-specific configuration for `import_completion_data`
523
+ # @return [::Gapic::Config::Method]
524
+ #
525
+ attr_reader :import_completion_data
526
+
527
+ # @private
528
+ def initialize parent_rpcs = nil
529
+ complete_query_config = parent_rpcs.complete_query if parent_rpcs.respond_to? :complete_query
530
+ @complete_query = ::Gapic::Config::Method.new complete_query_config
531
+ import_completion_data_config = parent_rpcs.import_completion_data if parent_rpcs.respond_to? :import_completion_data
532
+ @import_completion_data = ::Gapic::Config::Method.new import_completion_data_config
533
+
534
+ yield self if block_given?
535
+ end
536
+ end
537
+ end
538
+ end
539
+ end
540
+ end
541
+ end
542
+ end
543
+ end