google-cloud-retail-v2 0.2.0 → 0.4.0

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