google-cloud-discovery_engine-v1 0.a → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +149 -0
  4. data/README.md +144 -8
  5. data/lib/google/cloud/discovery_engine/v1/completion_service/client.rb +451 -0
  6. data/lib/google/cloud/discovery_engine/v1/completion_service/credentials.rb +47 -0
  7. data/lib/google/cloud/discovery_engine/v1/completion_service/paths.rb +78 -0
  8. data/lib/google/cloud/discovery_engine/v1/completion_service/rest/client.rb +408 -0
  9. data/lib/google/cloud/discovery_engine/v1/completion_service/rest/service_stub.rb +114 -0
  10. data/lib/google/cloud/discovery_engine/v1/completion_service/rest.rb +52 -0
  11. data/lib/google/cloud/discovery_engine/v1/completion_service.rb +55 -0
  12. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/client.rb +959 -0
  13. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/credentials.rb +47 -0
  14. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/paths.rb +176 -0
  15. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/client.rb +797 -0
  16. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/service_stub.rb +450 -0
  17. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest.rb +52 -0
  18. data/lib/google/cloud/discovery_engine/v1/conversational_search_service.rb +55 -0
  19. data/lib/google/cloud/discovery_engine/v1/document_service/client.rb +1170 -0
  20. data/lib/google/cloud/discovery_engine/v1/document_service/credentials.rb +47 -0
  21. data/lib/google/cloud/discovery_engine/v1/document_service/operations.rb +770 -0
  22. data/lib/google/cloud/discovery_engine/v1/document_service/paths.rb +135 -0
  23. data/lib/google/cloud/discovery_engine/v1/document_service/rest/client.rb +971 -0
  24. data/lib/google/cloud/discovery_engine/v1/document_service/rest/operations.rb +977 -0
  25. data/lib/google/cloud/discovery_engine/v1/document_service/rest/service_stub.rb +518 -0
  26. data/lib/google/cloud/discovery_engine/v1/document_service/rest.rb +54 -0
  27. data/lib/google/cloud/discovery_engine/v1/document_service.rb +57 -0
  28. data/lib/google/cloud/discovery_engine/v1/rest.rb +42 -0
  29. data/lib/google/cloud/discovery_engine/v1/schema_service/client.rb +853 -0
  30. data/lib/google/cloud/discovery_engine/v1/schema_service/credentials.rb +47 -0
  31. data/lib/google/cloud/discovery_engine/v1/schema_service/operations.rb +770 -0
  32. data/lib/google/cloud/discovery_engine/v1/schema_service/paths.rb +127 -0
  33. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/client.rb +693 -0
  34. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/operations.rb +977 -0
  35. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/service_stub.rb +382 -0
  36. data/lib/google/cloud/discovery_engine/v1/schema_service/rest.rb +53 -0
  37. data/lib/google/cloud/discovery_engine/v1/schema_service.rb +56 -0
  38. data/lib/google/cloud/discovery_engine/v1/search_service/client.rb +529 -0
  39. data/lib/google/cloud/discovery_engine/v1/search_service/credentials.rb +47 -0
  40. data/lib/google/cloud/discovery_engine/v1/search_service/paths.rb +131 -0
  41. data/lib/google/cloud/discovery_engine/v1/search_service/rest/client.rb +481 -0
  42. data/lib/google/cloud/discovery_engine/v1/search_service/rest/service_stub.rb +116 -0
  43. data/lib/google/cloud/discovery_engine/v1/search_service/rest.rb +52 -0
  44. data/lib/google/cloud/discovery_engine/v1/search_service.rb +55 -0
  45. data/lib/google/cloud/discovery_engine/v1/user_event_service/client.rb +654 -0
  46. data/lib/google/cloud/discovery_engine/v1/user_event_service/credentials.rb +47 -0
  47. data/lib/google/cloud/discovery_engine/v1/user_event_service/operations.rb +770 -0
  48. data/lib/google/cloud/discovery_engine/v1/user_event_service/paths.rb +131 -0
  49. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/client.rb +558 -0
  50. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/operations.rb +977 -0
  51. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/service_stub.rb +250 -0
  52. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest.rb +53 -0
  53. data/lib/google/cloud/discovery_engine/v1/user_event_service.rb +56 -0
  54. data/lib/google/cloud/discovery_engine/v1/version.rb +7 -2
  55. data/lib/google/cloud/discovery_engine/v1.rb +50 -0
  56. data/lib/google/cloud/discoveryengine/v1/common_pb.rb +46 -0
  57. data/lib/google/cloud/discoveryengine/v1/completion_service_pb.rb +49 -0
  58. data/lib/google/cloud/discoveryengine/v1/completion_service_services_pb.rb +45 -0
  59. data/lib/google/cloud/discoveryengine/v1/conversation_pb.rb +54 -0
  60. data/lib/google/cloud/discoveryengine/v1/conversational_search_service_pb.rb +61 -0
  61. data/lib/google/cloud/discoveryengine/v1/conversational_search_service_services_pb.rb +67 -0
  62. data/lib/google/cloud/discoveryengine/v1/document_pb.rb +48 -0
  63. data/lib/google/cloud/discoveryengine/v1/document_service_pb.rb +58 -0
  64. data/lib/google/cloud/discoveryengine/v1/document_service_services_pb.rb +79 -0
  65. data/lib/google/cloud/discoveryengine/v1/import_config_pb.rb +66 -0
  66. data/lib/google/cloud/discoveryengine/v1/purge_config_pb.rb +49 -0
  67. data/lib/google/cloud/discoveryengine/v1/schema_pb.rb +47 -0
  68. data/lib/google/cloud/discoveryengine/v1/schema_service_pb.rb +61 -0
  69. data/lib/google/cloud/discoveryengine/v1/schema_service_services_pb.rb +53 -0
  70. data/lib/google/cloud/discoveryengine/v1/search_service_pb.rb +73 -0
  71. data/lib/google/cloud/discoveryengine/v1/search_service_services_pb.rb +45 -0
  72. data/lib/google/cloud/discoveryengine/v1/user_event_pb.rb +58 -0
  73. data/lib/google/cloud/discoveryengine/v1/user_event_service_pb.rb +53 -0
  74. data/lib/google/cloud/discoveryengine/v1/user_event_service_services_pb.rb +59 -0
  75. data/lib/google-cloud-discovery_engine-v1.rb +21 -0
  76. data/proto_docs/README.md +4 -0
  77. data/proto_docs/google/api/client.rb +381 -0
  78. data/proto_docs/google/api/field_behavior.rb +85 -0
  79. data/proto_docs/google/api/httpbody.rb +80 -0
  80. data/proto_docs/google/api/launch_stage.rb +71 -0
  81. data/proto_docs/google/api/resource.rb +222 -0
  82. data/proto_docs/google/cloud/discoveryengine/v1/common.rb +106 -0
  83. data/proto_docs/google/cloud/discoveryengine/v1/completion_service.rb +111 -0
  84. data/proto_docs/google/cloud/discoveryengine/v1/conversation.rb +113 -0
  85. data/proto_docs/google/cloud/discoveryengine/v1/conversational_search_service.rb +206 -0
  86. data/proto_docs/google/cloud/discoveryengine/v1/document.rb +108 -0
  87. data/proto_docs/google/cloud/discoveryengine/v1/document_service.rb +181 -0
  88. data/proto_docs/google/cloud/discoveryengine/v1/import_config.rb +340 -0
  89. data/proto_docs/google/cloud/discoveryengine/v1/purge_config.rb +84 -0
  90. data/proto_docs/google/cloud/discoveryengine/v1/schema.rb +45 -0
  91. data/proto_docs/google/cloud/discoveryengine/v1/schema_service.rb +177 -0
  92. data/proto_docs/google/cloud/discoveryengine/v1/search_service.rb +730 -0
  93. data/proto_docs/google/cloud/discoveryengine/v1/user_event.rb +478 -0
  94. data/proto_docs/google/cloud/discoveryengine/v1/user_event_service.rb +64 -0
  95. data/proto_docs/google/longrunning/operations.rb +164 -0
  96. data/proto_docs/google/protobuf/any.rb +144 -0
  97. data/proto_docs/google/protobuf/duration.rb +98 -0
  98. data/proto_docs/google/protobuf/empty.rb +34 -0
  99. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  100. data/proto_docs/google/protobuf/struct.rb +96 -0
  101. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  102. data/proto_docs/google/rpc/status.rb +48 -0
  103. data/proto_docs/google/type/date.rb +53 -0
  104. metadata +277 -13
@@ -0,0 +1,131 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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
+
20
+ module Google
21
+ module Cloud
22
+ module DiscoveryEngine
23
+ module V1
24
+ module SearchService
25
+ # Path helper methods for the SearchService API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified Branch resource string.
29
+ #
30
+ # @overload branch_path(project:, location:, data_store:, branch:)
31
+ # The resource will be in the following format:
32
+ #
33
+ # `projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}`
34
+ #
35
+ # @param project [String]
36
+ # @param location [String]
37
+ # @param data_store [String]
38
+ # @param branch [String]
39
+ #
40
+ # @overload branch_path(project:, location:, collection:, data_store:, branch:)
41
+ # The resource will be in the following format:
42
+ #
43
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`
44
+ #
45
+ # @param project [String]
46
+ # @param location [String]
47
+ # @param collection [String]
48
+ # @param data_store [String]
49
+ # @param branch [String]
50
+ #
51
+ # @return [::String]
52
+ def branch_path **args
53
+ resources = {
54
+ "branch:data_store:location:project" => (proc do |project:, location:, data_store:, branch:|
55
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
56
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
57
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
58
+
59
+ "projects/#{project}/locations/#{location}/dataStores/#{data_store}/branches/#{branch}"
60
+ end),
61
+ "branch:collection:data_store:location:project" => (proc do |project:, location:, collection:, data_store:, branch:|
62
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
63
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
64
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
65
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
66
+
67
+ "projects/#{project}/locations/#{location}/collections/#{collection}/dataStores/#{data_store}/branches/#{branch}"
68
+ end)
69
+ }
70
+
71
+ resource = resources[args.keys.sort.join(":")]
72
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
73
+ resource.call(**args)
74
+ end
75
+
76
+ ##
77
+ # Create a fully-qualified ServingConfig resource string.
78
+ #
79
+ # @overload serving_config_path(project:, location:, data_store:, serving_config:)
80
+ # The resource will be in the following format:
81
+ #
82
+ # `projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}`
83
+ #
84
+ # @param project [String]
85
+ # @param location [String]
86
+ # @param data_store [String]
87
+ # @param serving_config [String]
88
+ #
89
+ # @overload serving_config_path(project:, location:, collection:, data_store:, serving_config:)
90
+ # The resource will be in the following format:
91
+ #
92
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}`
93
+ #
94
+ # @param project [String]
95
+ # @param location [String]
96
+ # @param collection [String]
97
+ # @param data_store [String]
98
+ # @param serving_config [String]
99
+ #
100
+ # @return [::String]
101
+ def serving_config_path **args
102
+ resources = {
103
+ "data_store:location:project:serving_config" => (proc do |project:, location:, data_store:, serving_config:|
104
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
105
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
106
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
107
+
108
+ "projects/#{project}/locations/#{location}/dataStores/#{data_store}/servingConfigs/#{serving_config}"
109
+ end),
110
+ "collection:data_store:location:project:serving_config" => (proc do |project:, location:, collection:, data_store:, serving_config:|
111
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
112
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
113
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
114
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
115
+
116
+ "projects/#{project}/locations/#{location}/collections/#{collection}/dataStores/#{data_store}/servingConfigs/#{serving_config}"
117
+ end)
118
+ }
119
+
120
+ resource = resources[args.keys.sort.join(":")]
121
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
122
+ resource.call(**args)
123
+ end
124
+
125
+ extend self
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,481 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/discoveryengine/v1/search_service_pb"
21
+ require "google/cloud/discovery_engine/v1/search_service/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+
24
+ module Google
25
+ module Cloud
26
+ module DiscoveryEngine
27
+ module V1
28
+ module SearchService
29
+ module Rest
30
+ ##
31
+ # REST client for the SearchService service.
32
+ #
33
+ # Service for search.
34
+ #
35
+ class Client
36
+ include Paths
37
+
38
+ # @private
39
+ attr_reader :search_service_stub
40
+
41
+ ##
42
+ # Configure the SearchService Client class.
43
+ #
44
+ # See {::Google::Cloud::DiscoveryEngine::V1::SearchService::Rest::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # @example
48
+ #
49
+ # # Modify the configuration for all SearchService clients
50
+ # ::Google::Cloud::DiscoveryEngine::V1::SearchService::Rest::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
53
+ #
54
+ # @yield [config] Configure the Client client.
55
+ # @yieldparam config [Client::Configuration]
56
+ #
57
+ # @return [Client::Configuration]
58
+ #
59
+ def self.configure
60
+ @configure ||= begin
61
+ namespace = ["Google", "Cloud", "DiscoveryEngine", "V1"]
62
+ parent_config = while namespace.any?
63
+ parent_name = namespace.join "::"
64
+ parent_const = const_get parent_name
65
+ break parent_const.configure if parent_const.respond_to? :configure
66
+ namespace.pop
67
+ end
68
+ default_config = Client::Configuration.new parent_config
69
+
70
+ default_config.timeout = 5.0
71
+ default_config.retry_policy = {
72
+ initial_delay: 0.1, max_delay: 5.0, multiplier: 1.3, retry_codes: [14]
73
+ }
74
+
75
+ default_config
76
+ end
77
+ yield @configure if block_given?
78
+ @configure
79
+ end
80
+
81
+ ##
82
+ # Configure the SearchService Client instance.
83
+ #
84
+ # The configuration is set to the derived mode, meaning that values can be changed,
85
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
86
+ # should be made on {Client.configure}.
87
+ #
88
+ # See {::Google::Cloud::DiscoveryEngine::V1::SearchService::Rest::Client::Configuration}
89
+ # for a description of the configuration fields.
90
+ #
91
+ # @yield [config] Configure the Client client.
92
+ # @yieldparam config [Client::Configuration]
93
+ #
94
+ # @return [Client::Configuration]
95
+ #
96
+ def configure
97
+ yield @config if block_given?
98
+ @config
99
+ end
100
+
101
+ ##
102
+ # Create a new SearchService REST client object.
103
+ #
104
+ # @example
105
+ #
106
+ # # Create a client using the default configuration
107
+ # client = ::Google::Cloud::DiscoveryEngine::V1::SearchService::Rest::Client.new
108
+ #
109
+ # # Create a client using a custom configuration
110
+ # client = ::Google::Cloud::DiscoveryEngine::V1::SearchService::Rest::Client.new do |config|
111
+ # config.timeout = 10.0
112
+ # end
113
+ #
114
+ # @yield [config] Configure the SearchService client.
115
+ # @yieldparam config [Client::Configuration]
116
+ #
117
+ def initialize
118
+ # Create the configuration object
119
+ @config = Configuration.new Client.configure
120
+
121
+ # Yield the configuration if needed
122
+ yield @config if block_given?
123
+
124
+ # Create credentials
125
+ credentials = @config.credentials
126
+ # Use self-signed JWT if the endpoint is unchanged from default,
127
+ # but only if the default endpoint does not have a region prefix.
128
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
129
+ !@config.endpoint.split(".").first.include?("-")
130
+ credentials ||= Credentials.default scope: @config.scope,
131
+ enable_self_signed_jwt: enable_self_signed_jwt
132
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
133
+ credentials = Credentials.new credentials, scope: @config.scope
134
+ end
135
+
136
+ @quota_project_id = @config.quota_project
137
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
138
+
139
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
140
+ config.credentials = credentials
141
+ config.quota_project = @quota_project_id
142
+ config.endpoint = @config.endpoint
143
+ end
144
+
145
+ @search_service_stub = ::Google::Cloud::DiscoveryEngine::V1::SearchService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
146
+ end
147
+
148
+ ##
149
+ # Get the associated client for mix-in of the Locations.
150
+ #
151
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
152
+ #
153
+ attr_reader :location_client
154
+
155
+ # Service calls
156
+
157
+ ##
158
+ # Performs a search.
159
+ #
160
+ # @overload search(request, options = nil)
161
+ # Pass arguments to `search` via a request object, either of type
162
+ # {::Google::Cloud::DiscoveryEngine::V1::SearchRequest} or an equivalent Hash.
163
+ #
164
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::SearchRequest, ::Hash]
165
+ # A request object representing the call parameters. Required. To specify no
166
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
167
+ # @param options [::Gapic::CallOptions, ::Hash]
168
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
169
+ #
170
+ # @overload search(serving_config: nil, branch: nil, query: nil, image_query: nil, page_size: nil, page_token: nil, offset: nil, filter: nil, order_by: nil, user_info: nil, facet_specs: nil, boost_spec: nil, params: nil, query_expansion_spec: nil, spell_correction_spec: nil, user_pseudo_id: nil, content_search_spec: nil, safe_search: nil, user_labels: nil)
171
+ # Pass arguments to `search` via keyword arguments. Note that at
172
+ # least one keyword argument is required. To specify no parameters, or to keep all
173
+ # the default parameter values, pass an empty Hash as a request object (see above).
174
+ #
175
+ # @param serving_config [::String]
176
+ # Required. The resource name of the Search serving config, such as
177
+ # `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`.
178
+ # This field is used to identify the serving configuration name, set
179
+ # of models used to make the search.
180
+ # @param branch [::String]
181
+ # The branch resource name, such as
182
+ # `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/branches/0`.
183
+ #
184
+ # Use `default_branch` as the branch ID or leave this field empty, to search
185
+ # documents under the default branch.
186
+ # @param query [::String]
187
+ # Raw search query.
188
+ # @param image_query [::Google::Cloud::DiscoveryEngine::V1::SearchRequest::ImageQuery, ::Hash]
189
+ # Raw image query.
190
+ # @param page_size [::Integer]
191
+ # Maximum number of {::Google::Cloud::DiscoveryEngine::V1::Document Document}s to
192
+ # return. If unspecified, defaults to a reasonable value. The maximum allowed
193
+ # value is 100. Values above 100 are coerced to 100.
194
+ #
195
+ # If this field is negative, an `INVALID_ARGUMENT` is returned.
196
+ # @param page_token [::String]
197
+ # A page token received from a previous
198
+ # {::Google::Cloud::DiscoveryEngine::V1::SearchService::Rest::Client#search SearchService.Search}
199
+ # call. Provide this to retrieve the subsequent page.
200
+ #
201
+ # When paginating, all other parameters provided to
202
+ # {::Google::Cloud::DiscoveryEngine::V1::SearchService::Rest::Client#search SearchService.Search}
203
+ # must match the call that provided the page token. Otherwise, an
204
+ # `INVALID_ARGUMENT` error is returned.
205
+ # @param offset [::Integer]
206
+ # A 0-indexed integer that specifies the current offset (that is, starting
207
+ # result location, amongst the
208
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}s deemed by the API as
209
+ # relevant) in search results. This field is only considered if
210
+ # {::Google::Cloud::DiscoveryEngine::V1::SearchRequest#page_token page_token} is
211
+ # unset.
212
+ #
213
+ # If this field is negative, an `INVALID_ARGUMENT` is returned.
214
+ # @param filter [::String]
215
+ # The filter syntax consists of an expression language for constructing a
216
+ # predicate from one or more fields of the documents being filtered. Filter
217
+ # expression is case-sensitive.
218
+ #
219
+ # If this field is unrecognizable, an `INVALID_ARGUMENT` is returned.
220
+ # @param order_by [::String]
221
+ # The order in which documents are returned. Documents can be ordered by
222
+ # a field in an {::Google::Cloud::DiscoveryEngine::V1::Document Document} object.
223
+ # Leave it unset if ordered by relevance. `order_by` expression is
224
+ # case-sensitive.
225
+ #
226
+ # If this field is unrecognizable, an `INVALID_ARGUMENT` is returned.
227
+ # @param user_info [::Google::Cloud::DiscoveryEngine::V1::UserInfo, ::Hash]
228
+ # Information about the end user.
229
+ # Highly recommended for analytics.
230
+ # {::Google::Cloud::DiscoveryEngine::V1::UserInfo#user_agent UserInfo.user_agent}
231
+ # is used to deduce `device_type` for analytics.
232
+ # @param facet_specs [::Array<::Google::Cloud::DiscoveryEngine::V1::SearchRequest::FacetSpec, ::Hash>]
233
+ # Facet specifications for faceted search. If empty, no facets are returned.
234
+ #
235
+ # A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT`
236
+ # error is returned.
237
+ # @param boost_spec [::Google::Cloud::DiscoveryEngine::V1::SearchRequest::BoostSpec, ::Hash]
238
+ # Boost specification to boost certain documents.
239
+ # @param params [::Hash{::String => ::Google::Protobuf::Value, ::Hash}]
240
+ # Additional search parameters.
241
+ #
242
+ # For public website search only, supported values are:
243
+ #
244
+ # * `user_country_code`: string. Default empty. If set to non-empty, results
245
+ # are restricted or boosted based on the location provided.
246
+ # * `search_type`: double. Default empty. Enables non-webpage searching
247
+ # depending on the value. The only valid non-default value is 1,
248
+ # which enables image searching.
249
+ # @param query_expansion_spec [::Google::Cloud::DiscoveryEngine::V1::SearchRequest::QueryExpansionSpec, ::Hash]
250
+ # The query expansion specification that specifies the conditions under which
251
+ # query expansion occurs.
252
+ # @param spell_correction_spec [::Google::Cloud::DiscoveryEngine::V1::SearchRequest::SpellCorrectionSpec, ::Hash]
253
+ # The spell correction specification that specifies the mode under
254
+ # which spell correction takes effect.
255
+ # @param user_pseudo_id [::String]
256
+ # A unique identifier for tracking visitors. For example, this could be
257
+ # implemented with an HTTP cookie, which should be able to uniquely identify
258
+ # a visitor on a single device. This unique identifier should not change if
259
+ # the visitor logs in or out of the website.
260
+ #
261
+ # This field should NOT have a fixed value such as `unknown_visitor`.
262
+ #
263
+ # This should be the same identifier as
264
+ # {::Google::Cloud::DiscoveryEngine::V1::UserEvent#user_pseudo_id UserEvent.user_pseudo_id}
265
+ # and
266
+ # {::Google::Cloud::DiscoveryEngine::V1::CompleteQueryRequest#user_pseudo_id CompleteQueryRequest.user_pseudo_id}
267
+ #
268
+ # The field must be a UTF-8 encoded string with a length limit of 128
269
+ # characters. Otherwise, an `INVALID_ARGUMENT` error is returned.
270
+ # @param content_search_spec [::Google::Cloud::DiscoveryEngine::V1::SearchRequest::ContentSearchSpec, ::Hash]
271
+ # A specification for configuring the behavior of content search.
272
+ # @param safe_search [::Boolean]
273
+ # Whether to turn on safe search. This is only supported for
274
+ # website search.
275
+ # @param user_labels [::Hash{::String => ::String}]
276
+ # The user labels applied to a resource must meet the following requirements:
277
+ #
278
+ # * Each resource can have multiple labels, up to a maximum of 64.
279
+ # * Each label must be a key-value pair.
280
+ # * Keys have a minimum length of 1 character and a maximum length of 63
281
+ # characters and cannot be empty. Values can be empty and have a maximum
282
+ # length of 63 characters.
283
+ # * Keys and values can contain only lowercase letters, numeric characters,
284
+ # underscores, and dashes. All characters must use UTF-8 encoding, and
285
+ # international characters are allowed.
286
+ # * The key portion of a label must be unique. However, you can use the same
287
+ # key with multiple resources.
288
+ # * Keys must start with a lowercase letter or international character.
289
+ #
290
+ # See [Google Cloud
291
+ # Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
292
+ # for more details.
293
+ # @yield [result, operation] Access the result along with the TransportOperation object
294
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1::SearchResponse]
295
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
296
+ #
297
+ # @return [::Google::Cloud::DiscoveryEngine::V1::SearchResponse]
298
+ #
299
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
300
+ def search request, options = nil
301
+ raise ::ArgumentError, "request must be provided" if request.nil?
302
+
303
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::SearchRequest
304
+
305
+ # Converts hash and nil to an options object
306
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
307
+
308
+ # Customize the options with defaults
309
+ call_metadata = @config.rpcs.search.metadata.to_h
310
+
311
+ # Set x-goog-api-client and x-goog-user-project headers
312
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
313
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
314
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION,
315
+ transports_version_send: [:rest]
316
+
317
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
318
+
319
+ options.apply_defaults timeout: @config.rpcs.search.timeout,
320
+ metadata: call_metadata,
321
+ retry_policy: @config.rpcs.search.retry_policy
322
+
323
+ options.apply_defaults timeout: @config.timeout,
324
+ metadata: @config.metadata,
325
+ retry_policy: @config.retry_policy
326
+
327
+ @search_service_stub.search request, options do |result, operation|
328
+ yield result, operation if block_given?
329
+ return result
330
+ end
331
+ rescue ::Gapic::Rest::Error => e
332
+ raise ::Google::Cloud::Error.from_error(e)
333
+ end
334
+
335
+ ##
336
+ # Configuration class for the SearchService REST API.
337
+ #
338
+ # This class represents the configuration for SearchService REST,
339
+ # providing control over timeouts, retry behavior, logging, transport
340
+ # parameters, and other low-level controls. Certain parameters can also be
341
+ # applied individually to specific RPCs. See
342
+ # {::Google::Cloud::DiscoveryEngine::V1::SearchService::Rest::Client::Configuration::Rpcs}
343
+ # for a list of RPCs that can be configured independently.
344
+ #
345
+ # Configuration can be applied globally to all clients, or to a single client
346
+ # on construction.
347
+ #
348
+ # @example
349
+ #
350
+ # # Modify the global config, setting the timeout for
351
+ # # search to 20 seconds,
352
+ # # and all remaining timeouts to 10 seconds.
353
+ # ::Google::Cloud::DiscoveryEngine::V1::SearchService::Rest::Client.configure do |config|
354
+ # config.timeout = 10.0
355
+ # config.rpcs.search.timeout = 20.0
356
+ # end
357
+ #
358
+ # # Apply the above configuration only to a new client.
359
+ # client = ::Google::Cloud::DiscoveryEngine::V1::SearchService::Rest::Client.new do |config|
360
+ # config.timeout = 10.0
361
+ # config.rpcs.search.timeout = 20.0
362
+ # end
363
+ #
364
+ # @!attribute [rw] endpoint
365
+ # The hostname or hostname:port of the service endpoint.
366
+ # Defaults to `"discoveryengine.googleapis.com"`.
367
+ # @return [::String]
368
+ # @!attribute [rw] credentials
369
+ # Credentials to send with calls. You may provide any of the following types:
370
+ # * (`String`) The path to a service account key file in JSON format
371
+ # * (`Hash`) A service account key as a Hash
372
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
373
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
374
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
375
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
376
+ # * (`nil`) indicating no credentials
377
+ # @return [::Object]
378
+ # @!attribute [rw] scope
379
+ # The OAuth scopes
380
+ # @return [::Array<::String>]
381
+ # @!attribute [rw] lib_name
382
+ # The library name as recorded in instrumentation and logging
383
+ # @return [::String]
384
+ # @!attribute [rw] lib_version
385
+ # The library version as recorded in instrumentation and logging
386
+ # @return [::String]
387
+ # @!attribute [rw] timeout
388
+ # The call timeout in seconds.
389
+ # @return [::Numeric]
390
+ # @!attribute [rw] metadata
391
+ # Additional headers to be sent with the call.
392
+ # @return [::Hash{::Symbol=>::String}]
393
+ # @!attribute [rw] retry_policy
394
+ # The retry policy. The value is a hash with the following keys:
395
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
396
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
397
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
398
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
399
+ # trigger a retry.
400
+ # @return [::Hash]
401
+ # @!attribute [rw] quota_project
402
+ # A separate project against which to charge quota.
403
+ # @return [::String]
404
+ #
405
+ class Configuration
406
+ extend ::Gapic::Config
407
+
408
+ DEFAULT_ENDPOINT = "discoveryengine.googleapis.com"
409
+
410
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
411
+ config_attr :credentials, nil do |value|
412
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
413
+ allowed.any? { |klass| klass === value }
414
+ end
415
+ config_attr :scope, nil, ::String, ::Array, nil
416
+ config_attr :lib_name, nil, ::String, nil
417
+ config_attr :lib_version, nil, ::String, nil
418
+ config_attr :timeout, nil, ::Numeric, nil
419
+ config_attr :metadata, nil, ::Hash, nil
420
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
421
+ config_attr :quota_project, nil, ::String, nil
422
+
423
+ # @private
424
+ def initialize parent_config = nil
425
+ @parent_config = parent_config unless parent_config.nil?
426
+
427
+ yield self if block_given?
428
+ end
429
+
430
+ ##
431
+ # Configurations for individual RPCs
432
+ # @return [Rpcs]
433
+ #
434
+ def rpcs
435
+ @rpcs ||= begin
436
+ parent_rpcs = nil
437
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
438
+ Rpcs.new parent_rpcs
439
+ end
440
+ end
441
+
442
+ ##
443
+ # Configuration RPC class for the SearchService API.
444
+ #
445
+ # Includes fields providing the configuration for each RPC in this service.
446
+ # Each configuration object is of type `Gapic::Config::Method` and includes
447
+ # the following configuration fields:
448
+ #
449
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
450
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
451
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
452
+ # include the following keys:
453
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
454
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
455
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
456
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
457
+ # trigger a retry.
458
+ #
459
+ class Rpcs
460
+ ##
461
+ # RPC-specific configuration for `search`
462
+ # @return [::Gapic::Config::Method]
463
+ #
464
+ attr_reader :search
465
+
466
+ # @private
467
+ def initialize parent_rpcs = nil
468
+ search_config = parent_rpcs.search if parent_rpcs.respond_to? :search
469
+ @search = ::Gapic::Config::Method.new search_config
470
+
471
+ yield self if block_given?
472
+ end
473
+ end
474
+ end
475
+ end
476
+ end
477
+ end
478
+ end
479
+ end
480
+ end
481
+ end