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