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