google-cloud-discovery_engine-v1 2.3.1 → 2.4.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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +4 -4
  3. data/README.md +4 -4
  4. data/lib/google/cloud/discovery_engine/v1/assistant_service/client.rb +509 -0
  5. data/lib/google/cloud/discovery_engine/v1/assistant_service/credentials.rb +47 -0
  6. data/lib/google/cloud/discovery_engine/v1/assistant_service/paths.rb +169 -0
  7. data/lib/google/cloud/discovery_engine/v1/assistant_service/rest/client.rb +478 -0
  8. data/lib/google/cloud/discovery_engine/v1/assistant_service/rest/service_stub.rb +137 -0
  9. data/lib/google/cloud/discovery_engine/v1/assistant_service/rest.rb +52 -0
  10. data/lib/google/cloud/discovery_engine/v1/assistant_service.rb +55 -0
  11. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/client.rb +16 -4
  12. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/client.rb +16 -4
  13. data/lib/google/cloud/discovery_engine/v1/rest.rb +4 -2
  14. data/lib/google/cloud/discovery_engine/v1/search_service/client.rb +16 -28
  15. data/lib/google/cloud/discovery_engine/v1/search_service/rest/client.rb +16 -28
  16. data/lib/google/cloud/discovery_engine/v1/session_service/client.rb +920 -0
  17. data/lib/google/cloud/discovery_engine/v1/session_service/credentials.rb +47 -0
  18. data/lib/google/cloud/discovery_engine/v1/session_service/paths.rb +330 -0
  19. data/lib/google/cloud/discovery_engine/v1/session_service/rest/client.rb +859 -0
  20. data/lib/google/cloud/discovery_engine/v1/session_service/rest/service_stub.rb +462 -0
  21. data/lib/google/cloud/discovery_engine/v1/session_service/rest.rb +52 -0
  22. data/lib/google/cloud/discovery_engine/v1/session_service.rb +55 -0
  23. data/lib/google/cloud/discovery_engine/v1/version.rb +1 -1
  24. data/lib/google/cloud/discovery_engine/v1.rb +5 -3
  25. data/lib/google/cloud/discoveryengine/v1/assist_answer_pb.rb +59 -0
  26. data/lib/google/cloud/discoveryengine/v1/assistant_pb.rb +45 -0
  27. data/lib/google/cloud/discoveryengine/v1/assistant_service_pb.rb +62 -0
  28. data/lib/google/cloud/discoveryengine/v1/assistant_service_services_pb.rb +45 -0
  29. data/lib/google/cloud/discoveryengine/v1/session_pb.rb +1 -1
  30. data/lib/google/cloud/discoveryengine/v1/session_service_pb.rb +49 -0
  31. data/lib/google/cloud/discoveryengine/v1/session_service_services_pb.rb +64 -0
  32. data/proto_docs/google/cloud/discoveryengine/v1/assist_answer.rb +278 -0
  33. data/proto_docs/google/cloud/discoveryengine/v1/assistant.rb +39 -0
  34. data/proto_docs/google/cloud/discoveryengine/v1/assistant_service.rb +207 -0
  35. data/proto_docs/google/cloud/discoveryengine/v1/conversational_search_service.rb +15 -3
  36. data/proto_docs/google/cloud/discoveryengine/v1/search_service.rb +8 -14
  37. data/proto_docs/google/cloud/discoveryengine/v1/session.rb +20 -4
  38. metadata +24 -1
@@ -0,0 +1,169 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2025 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 AssistantService
25
+ # Path helper methods for the AssistantService API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified Assistant resource string.
29
+ #
30
+ # The resource will be in the following format:
31
+ #
32
+ # `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/assistants/{assistant}`
33
+ #
34
+ # @param project [String]
35
+ # @param location [String]
36
+ # @param collection [String]
37
+ # @param engine [String]
38
+ # @param assistant [String]
39
+ #
40
+ # @return [::String]
41
+ def assistant_path project:, location:, collection:, engine:, assistant:
42
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
43
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
44
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
45
+ raise ::ArgumentError, "engine cannot contain /" if engine.to_s.include? "/"
46
+
47
+ "projects/#{project}/locations/#{location}/collections/#{collection}/engines/#{engine}/assistants/#{assistant}"
48
+ end
49
+
50
+ ##
51
+ # Create a fully-qualified DataStore resource string.
52
+ #
53
+ # @overload data_store_path(project:, location:, data_store:)
54
+ # The resource will be in the following format:
55
+ #
56
+ # `projects/{project}/locations/{location}/dataStores/{data_store}`
57
+ #
58
+ # @param project [String]
59
+ # @param location [String]
60
+ # @param data_store [String]
61
+ #
62
+ # @overload data_store_path(project:, location:, collection:, data_store:)
63
+ # The resource will be in the following format:
64
+ #
65
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`
66
+ #
67
+ # @param project [String]
68
+ # @param location [String]
69
+ # @param collection [String]
70
+ # @param data_store [String]
71
+ #
72
+ # @return [::String]
73
+ def data_store_path **args
74
+ resources = {
75
+ "data_store:location:project" => (proc do |project:, location:, data_store:|
76
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
77
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
78
+
79
+ "projects/#{project}/locations/#{location}/dataStores/#{data_store}"
80
+ end),
81
+ "collection:data_store:location:project" => (proc do |project:, location:, collection:, data_store:|
82
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
83
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
84
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
85
+
86
+ "projects/#{project}/locations/#{location}/collections/#{collection}/dataStores/#{data_store}"
87
+ end)
88
+ }
89
+
90
+ resource = resources[args.keys.sort.join(":")]
91
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
92
+ resource.call(**args)
93
+ end
94
+
95
+ ##
96
+ # Create a fully-qualified Session resource string.
97
+ #
98
+ # @overload session_path(project:, location:, data_store:, session:)
99
+ # The resource will be in the following format:
100
+ #
101
+ # `projects/{project}/locations/{location}/dataStores/{data_store}/sessions/{session}`
102
+ #
103
+ # @param project [String]
104
+ # @param location [String]
105
+ # @param data_store [String]
106
+ # @param session [String]
107
+ #
108
+ # @overload session_path(project:, location:, collection:, data_store:, session:)
109
+ # The resource will be in the following format:
110
+ #
111
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/sessions/{session}`
112
+ #
113
+ # @param project [String]
114
+ # @param location [String]
115
+ # @param collection [String]
116
+ # @param data_store [String]
117
+ # @param session [String]
118
+ #
119
+ # @overload session_path(project:, location:, collection:, engine:, session:)
120
+ # The resource will be in the following format:
121
+ #
122
+ # `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/sessions/{session}`
123
+ #
124
+ # @param project [String]
125
+ # @param location [String]
126
+ # @param collection [String]
127
+ # @param engine [String]
128
+ # @param session [String]
129
+ #
130
+ # @return [::String]
131
+ def session_path **args
132
+ resources = {
133
+ "data_store:location:project:session" => (proc do |project:, location:, data_store:, session:|
134
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
135
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
136
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
137
+
138
+ "projects/#{project}/locations/#{location}/dataStores/#{data_store}/sessions/#{session}"
139
+ end),
140
+ "collection:data_store:location:project:session" => (proc do |project:, location:, collection:, data_store:, session:|
141
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
142
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
143
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
144
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
145
+
146
+ "projects/#{project}/locations/#{location}/collections/#{collection}/dataStores/#{data_store}/sessions/#{session}"
147
+ end),
148
+ "collection:engine:location:project:session" => (proc do |project:, location:, collection:, engine:, session:|
149
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
150
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
151
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
152
+ raise ::ArgumentError, "engine cannot contain /" if engine.to_s.include? "/"
153
+
154
+ "projects/#{project}/locations/#{location}/collections/#{collection}/engines/#{engine}/sessions/#{session}"
155
+ end)
156
+ }
157
+
158
+ resource = resources[args.keys.sort.join(":")]
159
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
160
+ resource.call(**args)
161
+ end
162
+
163
+ extend self
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end
169
+ end
@@ -0,0 +1,478 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2025 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/assistant_service_pb"
21
+ require "google/cloud/discovery_engine/v1/assistant_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 AssistantService
29
+ module Rest
30
+ ##
31
+ # REST client for the AssistantService service.
32
+ #
33
+ # Service for managing Assistant configuration and assisting users.
34
+ #
35
+ class Client
36
+ # @private
37
+ API_VERSION = ""
38
+
39
+ # @private
40
+ DEFAULT_ENDPOINT_TEMPLATE = "discoveryengine.$UNIVERSE_DOMAIN$"
41
+
42
+ include Paths
43
+
44
+ # @private
45
+ attr_reader :assistant_service_stub
46
+
47
+ ##
48
+ # Configure the AssistantService Client class.
49
+ #
50
+ # See {::Google::Cloud::DiscoveryEngine::V1::AssistantService::Rest::Client::Configuration}
51
+ # for a description of the configuration fields.
52
+ #
53
+ # @example
54
+ #
55
+ # # Modify the configuration for all AssistantService clients
56
+ # ::Google::Cloud::DiscoveryEngine::V1::AssistantService::Rest::Client.configure do |config|
57
+ # config.timeout = 10.0
58
+ # end
59
+ #
60
+ # @yield [config] Configure the Client client.
61
+ # @yieldparam config [Client::Configuration]
62
+ #
63
+ # @return [Client::Configuration]
64
+ #
65
+ def self.configure
66
+ @configure ||= begin
67
+ namespace = ["Google", "Cloud", "DiscoveryEngine", "V1"]
68
+ parent_config = while namespace.any?
69
+ parent_name = namespace.join "::"
70
+ parent_const = const_get parent_name
71
+ break parent_const.configure if parent_const.respond_to? :configure
72
+ namespace.pop
73
+ end
74
+ default_config = Client::Configuration.new parent_config
75
+
76
+ default_config.timeout = 30.0
77
+ default_config.retry_policy = {
78
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
79
+ }
80
+
81
+ default_config.rpcs.stream_assist.timeout = 300.0
82
+ default_config.rpcs.stream_assist.retry_policy = {
83
+ initial_delay: 1.0, max_delay: 30.0, multiplier: 1.3, retry_codes: [14]
84
+ }
85
+
86
+ default_config
87
+ end
88
+ yield @configure if block_given?
89
+ @configure
90
+ end
91
+
92
+ ##
93
+ # Configure the AssistantService Client instance.
94
+ #
95
+ # The configuration is set to the derived mode, meaning that values can be changed,
96
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
97
+ # should be made on {Client.configure}.
98
+ #
99
+ # See {::Google::Cloud::DiscoveryEngine::V1::AssistantService::Rest::Client::Configuration}
100
+ # for a description of the configuration fields.
101
+ #
102
+ # @yield [config] Configure the Client client.
103
+ # @yieldparam config [Client::Configuration]
104
+ #
105
+ # @return [Client::Configuration]
106
+ #
107
+ def configure
108
+ yield @config if block_given?
109
+ @config
110
+ end
111
+
112
+ ##
113
+ # The effective universe domain
114
+ #
115
+ # @return [String]
116
+ #
117
+ def universe_domain
118
+ @assistant_service_stub.universe_domain
119
+ end
120
+
121
+ ##
122
+ # Create a new AssistantService REST client object.
123
+ #
124
+ # @example
125
+ #
126
+ # # Create a client using the default configuration
127
+ # client = ::Google::Cloud::DiscoveryEngine::V1::AssistantService::Rest::Client.new
128
+ #
129
+ # # Create a client using a custom configuration
130
+ # client = ::Google::Cloud::DiscoveryEngine::V1::AssistantService::Rest::Client.new do |config|
131
+ # config.timeout = 10.0
132
+ # end
133
+ #
134
+ # @yield [config] Configure the AssistantService client.
135
+ # @yieldparam config [Client::Configuration]
136
+ #
137
+ def initialize
138
+ # Create the configuration object
139
+ @config = Configuration.new Client.configure
140
+
141
+ # Yield the configuration if needed
142
+ yield @config if block_given?
143
+
144
+ # Create credentials
145
+ credentials = @config.credentials
146
+ # Use self-signed JWT if the endpoint is unchanged from default,
147
+ # but only if the default endpoint does not have a region prefix.
148
+ enable_self_signed_jwt = @config.endpoint.nil? ||
149
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
150
+ !@config.endpoint.split(".").first.include?("-"))
151
+ credentials ||= Credentials.default scope: @config.scope,
152
+ enable_self_signed_jwt: enable_self_signed_jwt
153
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
154
+ credentials = Credentials.new credentials, scope: @config.scope
155
+ end
156
+
157
+ @quota_project_id = @config.quota_project
158
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
159
+
160
+ @assistant_service_stub = ::Google::Cloud::DiscoveryEngine::V1::AssistantService::Rest::ServiceStub.new(
161
+ endpoint: @config.endpoint,
162
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
163
+ universe_domain: @config.universe_domain,
164
+ credentials: credentials,
165
+ logger: @config.logger
166
+ )
167
+
168
+ @assistant_service_stub.logger(stub: true)&.info do |entry|
169
+ entry.set_system_name
170
+ entry.set_service
171
+ entry.message = "Created client for #{entry.service}"
172
+ entry.set_credentials_fields credentials
173
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
174
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
175
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
176
+ end
177
+
178
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
179
+ config.credentials = credentials
180
+ config.quota_project = @quota_project_id
181
+ config.endpoint = @assistant_service_stub.endpoint
182
+ config.universe_domain = @assistant_service_stub.universe_domain
183
+ config.logger = @assistant_service_stub.logger if config.respond_to? :logger=
184
+ end
185
+ end
186
+
187
+ ##
188
+ # Get the associated client for mix-in of the Locations.
189
+ #
190
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
191
+ #
192
+ attr_reader :location_client
193
+
194
+ ##
195
+ # The logger used for request/response debug logging.
196
+ #
197
+ # @return [Logger]
198
+ #
199
+ def logger
200
+ @assistant_service_stub.logger
201
+ end
202
+
203
+ # Service calls
204
+
205
+ ##
206
+ # Assists the user with a query in a streaming fashion.
207
+ #
208
+ # @overload stream_assist(request, options = nil)
209
+ # Pass arguments to `stream_assist` via a request object, either of type
210
+ # {::Google::Cloud::DiscoveryEngine::V1::StreamAssistRequest} or an equivalent Hash.
211
+ #
212
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::StreamAssistRequest, ::Hash]
213
+ # A request object representing the call parameters. Required. To specify no
214
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
215
+ # @param options [::Gapic::CallOptions, ::Hash]
216
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
217
+ #
218
+ # @overload stream_assist(name: nil, query: nil, session: nil, user_metadata: nil, tools_spec: nil, generation_spec: nil)
219
+ # Pass arguments to `stream_assist` via keyword arguments. Note that at
220
+ # least one keyword argument is required. To specify no parameters, or to keep all
221
+ # the default parameter values, pass an empty Hash as a request object (see above).
222
+ #
223
+ # @param name [::String]
224
+ # Required. The resource name of the
225
+ # {::Google::Cloud::DiscoveryEngine::V1::Assistant Assistant}. Format:
226
+ # `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/assistants/{assistant}`
227
+ # @param query [::Google::Cloud::DiscoveryEngine::V1::Query, ::Hash]
228
+ # Optional. Current user query.
229
+ #
230
+ # Empty query is only supported if `file_ids` are provided. In this case, the
231
+ # answer will be generated based on those context files.
232
+ # @param session [::String]
233
+ # Optional. The session to use for the request. If specified, the assistant
234
+ # has access to the session history, and the query and the answer are stored
235
+ # there.
236
+ #
237
+ # If `-` is specified as the session ID, or it is left empty, then a new
238
+ # session is created with an automatically generated ID.
239
+ #
240
+ # Format:
241
+ # `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/sessions/{session}`
242
+ # @param user_metadata [::Google::Cloud::DiscoveryEngine::V1::AssistUserMetadata, ::Hash]
243
+ # Optional. Information about the user initiating the query.
244
+ # @param tools_spec [::Google::Cloud::DiscoveryEngine::V1::StreamAssistRequest::ToolsSpec, ::Hash]
245
+ # Optional. Specification of tools that are used to serve the request.
246
+ # @param generation_spec [::Google::Cloud::DiscoveryEngine::V1::StreamAssistRequest::GenerationSpec, ::Hash]
247
+ # Optional. Specification of the generation configuration for the request.
248
+ # @return [::Enumerable<::Google::Cloud::DiscoveryEngine::V1::StreamAssistResponse>]
249
+ #
250
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
251
+ #
252
+ # @example Basic example
253
+ # require "google/cloud/discovery_engine/v1"
254
+ #
255
+ # # Create a client object. The client can be reused for multiple calls.
256
+ # client = Google::Cloud::DiscoveryEngine::V1::AssistantService::Rest::Client.new
257
+ #
258
+ # # Create a request. To set request fields, pass in keyword arguments.
259
+ # request = Google::Cloud::DiscoveryEngine::V1::StreamAssistRequest.new
260
+ #
261
+ # # Call the stream_assist method to start streaming.
262
+ # output = client.stream_assist request
263
+ #
264
+ # # The returned object is a streamed enumerable yielding elements of type
265
+ # # ::Google::Cloud::DiscoveryEngine::V1::StreamAssistResponse
266
+ # output.each do |current_response|
267
+ # p current_response
268
+ # end
269
+ #
270
+ def stream_assist request, options = nil
271
+ raise ::ArgumentError, "request must be provided" if request.nil?
272
+
273
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::StreamAssistRequest
274
+
275
+ # Converts hash and nil to an options object
276
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
277
+
278
+ # Customize the options with defaults
279
+ call_metadata = @config.rpcs.stream_assist.metadata.to_h
280
+
281
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
282
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
283
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
284
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION,
285
+ transports_version_send: [:rest]
286
+
287
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
288
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
289
+
290
+ options.apply_defaults timeout: @config.rpcs.stream_assist.timeout,
291
+ metadata: call_metadata,
292
+ retry_policy: @config.rpcs.stream_assist.retry_policy
293
+
294
+ options.apply_defaults timeout: @config.timeout,
295
+ metadata: @config.metadata,
296
+ retry_policy: @config.retry_policy
297
+
298
+ ::Gapic::Rest::ServerStream.new(
299
+ ::Google::Cloud::DiscoveryEngine::V1::StreamAssistResponse,
300
+ ::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q|
301
+ @assistant_service_stub.stream_assist request, options do |chunk|
302
+ in_q.deq
303
+ out_q.enq chunk
304
+ end
305
+ end
306
+ )
307
+ rescue ::Gapic::Rest::Error => e
308
+ raise ::Google::Cloud::Error.from_error(e)
309
+ end
310
+
311
+ ##
312
+ # Configuration class for the AssistantService REST API.
313
+ #
314
+ # This class represents the configuration for AssistantService REST,
315
+ # providing control over timeouts, retry behavior, logging, transport
316
+ # parameters, and other low-level controls. Certain parameters can also be
317
+ # applied individually to specific RPCs. See
318
+ # {::Google::Cloud::DiscoveryEngine::V1::AssistantService::Rest::Client::Configuration::Rpcs}
319
+ # for a list of RPCs that can be configured independently.
320
+ #
321
+ # Configuration can be applied globally to all clients, or to a single client
322
+ # on construction.
323
+ #
324
+ # @example
325
+ #
326
+ # # Modify the global config, setting the timeout for
327
+ # # stream_assist to 20 seconds,
328
+ # # and all remaining timeouts to 10 seconds.
329
+ # ::Google::Cloud::DiscoveryEngine::V1::AssistantService::Rest::Client.configure do |config|
330
+ # config.timeout = 10.0
331
+ # config.rpcs.stream_assist.timeout = 20.0
332
+ # end
333
+ #
334
+ # # Apply the above configuration only to a new client.
335
+ # client = ::Google::Cloud::DiscoveryEngine::V1::AssistantService::Rest::Client.new do |config|
336
+ # config.timeout = 10.0
337
+ # config.rpcs.stream_assist.timeout = 20.0
338
+ # end
339
+ #
340
+ # @!attribute [rw] endpoint
341
+ # A custom service endpoint, as a hostname or hostname:port. The default is
342
+ # nil, indicating to use the default endpoint in the current universe domain.
343
+ # @return [::String,nil]
344
+ # @!attribute [rw] credentials
345
+ # Credentials to send with calls. You may provide any of the following types:
346
+ # * (`String`) The path to a service account key file in JSON format
347
+ # * (`Hash`) A service account key as a Hash
348
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
349
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
350
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
351
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
352
+ # * (`nil`) indicating no credentials
353
+ #
354
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
355
+ # external source for authentication to Google Cloud, you must validate it before
356
+ # providing it to a Google API client library. Providing an unvalidated credential
357
+ # configuration to Google APIs can compromise the security of your systems and data.
358
+ # For more information, refer to [Validate credential configurations from external
359
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
360
+ # @return [::Object]
361
+ # @!attribute [rw] scope
362
+ # The OAuth scopes
363
+ # @return [::Array<::String>]
364
+ # @!attribute [rw] lib_name
365
+ # The library name as recorded in instrumentation and logging
366
+ # @return [::String]
367
+ # @!attribute [rw] lib_version
368
+ # The library version as recorded in instrumentation and logging
369
+ # @return [::String]
370
+ # @!attribute [rw] timeout
371
+ # The call timeout in seconds.
372
+ # @return [::Numeric]
373
+ # @!attribute [rw] metadata
374
+ # Additional headers to be sent with the call.
375
+ # @return [::Hash{::Symbol=>::String}]
376
+ # @!attribute [rw] retry_policy
377
+ # The retry policy. The value is a hash with the following keys:
378
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
379
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
380
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
381
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
382
+ # trigger a retry.
383
+ # @return [::Hash]
384
+ # @!attribute [rw] quota_project
385
+ # A separate project against which to charge quota.
386
+ # @return [::String]
387
+ # @!attribute [rw] universe_domain
388
+ # The universe domain within which to make requests. This determines the
389
+ # default endpoint URL. The default value of nil uses the environment
390
+ # universe (usually the default "googleapis.com" universe).
391
+ # @return [::String,nil]
392
+ # @!attribute [rw] logger
393
+ # A custom logger to use for request/response debug logging, or the value
394
+ # `:default` (the default) to construct a default logger, or `nil` to
395
+ # explicitly disable logging.
396
+ # @return [::Logger,:default,nil]
397
+ #
398
+ class Configuration
399
+ extend ::Gapic::Config
400
+
401
+ # @private
402
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
403
+ DEFAULT_ENDPOINT = "discoveryengine.googleapis.com"
404
+
405
+ config_attr :endpoint, nil, ::String, nil
406
+ config_attr :credentials, nil do |value|
407
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
408
+ allowed.any? { |klass| klass === value }
409
+ end
410
+ config_attr :scope, nil, ::String, ::Array, nil
411
+ config_attr :lib_name, nil, ::String, nil
412
+ config_attr :lib_version, nil, ::String, nil
413
+ config_attr :timeout, nil, ::Numeric, nil
414
+ config_attr :metadata, nil, ::Hash, nil
415
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
416
+ config_attr :quota_project, nil, ::String, nil
417
+ config_attr :universe_domain, nil, ::String, nil
418
+ config_attr :logger, :default, ::Logger, nil, :default
419
+
420
+ # @private
421
+ def initialize parent_config = nil
422
+ @parent_config = parent_config unless parent_config.nil?
423
+
424
+ yield self if block_given?
425
+ end
426
+
427
+ ##
428
+ # Configurations for individual RPCs
429
+ # @return [Rpcs]
430
+ #
431
+ def rpcs
432
+ @rpcs ||= begin
433
+ parent_rpcs = nil
434
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
435
+ Rpcs.new parent_rpcs
436
+ end
437
+ end
438
+
439
+ ##
440
+ # Configuration RPC class for the AssistantService API.
441
+ #
442
+ # Includes fields providing the configuration for each RPC in this service.
443
+ # Each configuration object is of type `Gapic::Config::Method` and includes
444
+ # the following configuration fields:
445
+ #
446
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
447
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
448
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
449
+ # include the following keys:
450
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
451
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
452
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
453
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
454
+ # trigger a retry.
455
+ #
456
+ class Rpcs
457
+ ##
458
+ # RPC-specific configuration for `stream_assist`
459
+ # @return [::Gapic::Config::Method]
460
+ #
461
+ attr_reader :stream_assist
462
+
463
+ # @private
464
+ def initialize parent_rpcs = nil
465
+ stream_assist_config = parent_rpcs.stream_assist if parent_rpcs.respond_to? :stream_assist
466
+ @stream_assist = ::Gapic::Config::Method.new stream_assist_config
467
+
468
+ yield self if block_given?
469
+ end
470
+ end
471
+ end
472
+ end
473
+ end
474
+ end
475
+ end
476
+ end
477
+ end
478
+ end