google-cloud-ces-v1 0.a → 0.1.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 (137) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +122 -0
  4. data/README.md +154 -8
  5. data/lib/google/cloud/ces/v1/agent_pb.rb +30 -0
  6. data/lib/google/cloud/ces/v1/agent_service/client.rb +5315 -0
  7. data/lib/google/cloud/ces/v1/agent_service/credentials.rb +48 -0
  8. data/lib/google/cloud/ces/v1/agent_service/operations.rb +841 -0
  9. data/lib/google/cloud/ces/v1/agent_service/paths.rb +424 -0
  10. data/lib/google/cloud/ces/v1/agent_service/rest/client.rb +4944 -0
  11. data/lib/google/cloud/ces/v1/agent_service/rest/operations.rb +925 -0
  12. data/lib/google/cloud/ces/v1/agent_service/rest/service_stub.rb +3028 -0
  13. data/lib/google/cloud/ces/v1/agent_service/rest.rb +55 -0
  14. data/lib/google/cloud/ces/v1/agent_service.rb +57 -0
  15. data/lib/google/cloud/ces/v1/agent_service_pb.rb +105 -0
  16. data/lib/google/cloud/ces/v1/agent_service_services_pb.rb +142 -0
  17. data/lib/google/cloud/ces/v1/agent_tool_pb.rb +24 -0
  18. data/lib/google/cloud/ces/v1/agent_transfers_pb.rb +29 -0
  19. data/lib/google/cloud/ces/v1/app_pb.rb +58 -0
  20. data/lib/google/cloud/ces/v1/app_version_pb.rb +32 -0
  21. data/lib/google/cloud/ces/v1/auth_pb.rb +34 -0
  22. data/lib/google/cloud/ces/v1/bigquery_export_pb.rb +23 -0
  23. data/lib/google/cloud/ces/v1/bindings_override.rb +75 -0
  24. data/lib/google/cloud/ces/v1/changelog_pb.rb +26 -0
  25. data/lib/google/cloud/ces/v1/client_function_pb.rb +24 -0
  26. data/lib/google/cloud/ces/v1/common_pb.rb +46 -0
  27. data/lib/google/cloud/ces/v1/connector_tool_pb.rb +27 -0
  28. data/lib/google/cloud/ces/v1/connector_toolset_pb.rb +25 -0
  29. data/lib/google/cloud/ces/v1/conversation_pb.rb +31 -0
  30. data/lib/google/cloud/ces/v1/data_store_pb.rb +27 -0
  31. data/lib/google/cloud/ces/v1/data_store_tool_pb.rb +40 -0
  32. data/lib/google/cloud/ces/v1/deployment_pb.rb +26 -0
  33. data/lib/google/cloud/ces/v1/example_pb.rb +34 -0
  34. data/lib/google/cloud/ces/v1/fakes_pb.rb +24 -0
  35. data/lib/google/cloud/ces/v1/file_search_tool_pb.rb +24 -0
  36. data/lib/google/cloud/ces/v1/google_search_tool_pb.rb +24 -0
  37. data/lib/google/cloud/ces/v1/guardrail_pb.rb +37 -0
  38. data/lib/google/cloud/ces/v1/mcp_tool_pb.rb +26 -0
  39. data/lib/google/cloud/ces/v1/mcp_toolset_pb.rb +25 -0
  40. data/lib/google/cloud/ces/v1/omnichannel_pb.rb +31 -0
  41. data/lib/google/cloud/ces/v1/omnichannel_service_pb.rb +27 -0
  42. data/lib/google/cloud/ces/v1/open_api_tool_pb.rb +25 -0
  43. data/lib/google/cloud/ces/v1/open_api_toolset_pb.rb +25 -0
  44. data/lib/google/cloud/ces/v1/python_function_pb.rb +23 -0
  45. data/lib/google/cloud/ces/v1/rest.rb +41 -0
  46. data/lib/google/cloud/ces/v1/schema_pb.rb +25 -0
  47. data/lib/google/cloud/ces/v1/search_suggestions_pb.rb +22 -0
  48. data/lib/google/cloud/ces/v1/security_settings_pb.rb +27 -0
  49. data/lib/google/cloud/ces/v1/session_service/client.rb +759 -0
  50. data/lib/google/cloud/ces/v1/session_service/credentials.rb +48 -0
  51. data/lib/google/cloud/ces/v1/session_service/paths.rb +117 -0
  52. data/lib/google/cloud/ces/v1/session_service/rest/client.rb +560 -0
  53. data/lib/google/cloud/ces/v1/session_service/rest/service_stub.rb +199 -0
  54. data/lib/google/cloud/ces/v1/session_service/rest.rb +53 -0
  55. data/lib/google/cloud/ces/v1/session_service.rb +55 -0
  56. data/lib/google/cloud/ces/v1/session_service_pb.rb +50 -0
  57. data/lib/google/cloud/ces/v1/session_service_services_pb.rb +119 -0
  58. data/lib/google/cloud/ces/v1/system_tool_pb.rb +23 -0
  59. data/lib/google/cloud/ces/v1/tool_pb.rb +38 -0
  60. data/lib/google/cloud/ces/v1/tool_service/client.rb +723 -0
  61. data/lib/google/cloud/ces/v1/tool_service/credentials.rb +48 -0
  62. data/lib/google/cloud/ces/v1/tool_service/paths.rb +94 -0
  63. data/lib/google/cloud/ces/v1/tool_service/rest/client.rb +667 -0
  64. data/lib/google/cloud/ces/v1/tool_service/rest/service_stub.rb +267 -0
  65. data/lib/google/cloud/ces/v1/tool_service/rest.rb +53 -0
  66. data/lib/google/cloud/ces/v1/tool_service.rb +55 -0
  67. data/lib/google/cloud/ces/v1/tool_service_pb.rb +35 -0
  68. data/lib/google/cloud/ces/v1/tool_service_services_pb.rb +50 -0
  69. data/lib/google/cloud/ces/v1/toolset_pb.rb +30 -0
  70. data/lib/google/cloud/ces/v1/toolset_tool_pb.rb +24 -0
  71. data/lib/google/cloud/ces/v1/version.rb +7 -2
  72. data/lib/google/cloud/ces/v1/widget_service/client.rb +501 -0
  73. data/lib/google/cloud/ces/v1/widget_service/credentials.rb +48 -0
  74. data/lib/google/cloud/ces/v1/widget_service/paths.rb +75 -0
  75. data/lib/google/cloud/ces/v1/widget_service/rest/client.rb +459 -0
  76. data/lib/google/cloud/ces/v1/widget_service/rest/service_stub.rb +143 -0
  77. data/lib/google/cloud/ces/v1/widget_service/rest.rb +53 -0
  78. data/lib/google/cloud/ces/v1/widget_service.rb +55 -0
  79. data/lib/google/cloud/ces/v1/widget_service_pb.rb +28 -0
  80. data/lib/google/cloud/ces/v1/widget_service_services_pb.rb +46 -0
  81. data/lib/google/cloud/ces/v1/widget_tool_pb.rb +29 -0
  82. data/lib/google/cloud/ces/v1.rb +48 -0
  83. data/lib/google-cloud-ces-v1.rb +21 -0
  84. data/proto_docs/README.md +4 -0
  85. data/proto_docs/google/api/client.rb +593 -0
  86. data/proto_docs/google/api/field_behavior.rb +85 -0
  87. data/proto_docs/google/api/launch_stage.rb +71 -0
  88. data/proto_docs/google/api/resource.rb +227 -0
  89. data/proto_docs/google/cloud/ces/v1/agent.rb +224 -0
  90. data/proto_docs/google/cloud/ces/v1/agent_service.rb +1250 -0
  91. data/proto_docs/google/cloud/ces/v1/agent_tool.rb +42 -0
  92. data/proto_docs/google/cloud/ces/v1/agent_transfers.rb +111 -0
  93. data/proto_docs/google/cloud/ces/v1/app.rb +685 -0
  94. data/proto_docs/google/cloud/ces/v1/app_version.rb +83 -0
  95. data/proto_docs/google/cloud/ces/v1/auth.rb +214 -0
  96. data/proto_docs/google/cloud/ces/v1/bigquery_export.rb +45 -0
  97. data/proto_docs/google/cloud/ces/v1/changelog.rb +73 -0
  98. data/proto_docs/google/cloud/ces/v1/client_function.rb +48 -0
  99. data/proto_docs/google/cloud/ces/v1/common.rb +375 -0
  100. data/proto_docs/google/cloud/ces/v1/connector_tool.rb +122 -0
  101. data/proto_docs/google/cloud/ces/v1/connector_toolset.rb +52 -0
  102. data/proto_docs/google/cloud/ces/v1/conversation.rb +152 -0
  103. data/proto_docs/google/cloud/ces/v1/data_store.rb +102 -0
  104. data/proto_docs/google/cloud/ces/v1/data_store_tool.rb +328 -0
  105. data/proto_docs/google/cloud/ces/v1/deployment.rb +62 -0
  106. data/proto_docs/google/cloud/ces/v1/example.rb +244 -0
  107. data/proto_docs/google/cloud/ces/v1/fakes.rb +55 -0
  108. data/proto_docs/google/cloud/ces/v1/file_search_tool.rb +60 -0
  109. data/proto_docs/google/cloud/ces/v1/google_search_tool.rb +76 -0
  110. data/proto_docs/google/cloud/ces/v1/guardrail.rb +324 -0
  111. data/proto_docs/google/cloud/ces/v1/mcp_tool.rb +85 -0
  112. data/proto_docs/google/cloud/ces/v1/mcp_toolset.rb +71 -0
  113. data/proto_docs/google/cloud/ces/v1/omnichannel.rb +163 -0
  114. data/proto_docs/google/cloud/ces/v1/omnichannel_service.rb +45 -0
  115. data/proto_docs/google/cloud/ces/v1/open_api_tool.rb +66 -0
  116. data/proto_docs/google/cloud/ces/v1/open_api_toolset.rb +57 -0
  117. data/proto_docs/google/cloud/ces/v1/python_function.rb +44 -0
  118. data/proto_docs/google/cloud/ces/v1/schema.rb +162 -0
  119. data/proto_docs/google/cloud/ces/v1/search_suggestions.rb +55 -0
  120. data/proto_docs/google/cloud/ces/v1/security_settings.rb +80 -0
  121. data/proto_docs/google/cloud/ces/v1/session_service.rb +464 -0
  122. data/proto_docs/google/cloud/ces/v1/system_tool.rb +38 -0
  123. data/proto_docs/google/cloud/ces/v1/tool.rb +126 -0
  124. data/proto_docs/google/cloud/ces/v1/tool_service.rb +168 -0
  125. data/proto_docs/google/cloud/ces/v1/toolset.rb +80 -0
  126. data/proto_docs/google/cloud/ces/v1/toolset_tool.rb +40 -0
  127. data/proto_docs/google/cloud/ces/v1/widget_service.rb +62 -0
  128. data/proto_docs/google/cloud/ces/v1/widget_tool.rb +146 -0
  129. data/proto_docs/google/longrunning/operations.rb +191 -0
  130. data/proto_docs/google/protobuf/any.rb +145 -0
  131. data/proto_docs/google/protobuf/duration.rb +98 -0
  132. data/proto_docs/google/protobuf/empty.rb +34 -0
  133. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  134. data/proto_docs/google/protobuf/struct.rb +108 -0
  135. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  136. data/proto_docs/google/rpc/status.rb +48 -0
  137. metadata +183 -9
@@ -0,0 +1,759 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2026 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/ces/v1/session_service_pb"
21
+ require "google/cloud/location"
22
+
23
+ module Google
24
+ module Cloud
25
+ module Ces
26
+ module V1
27
+ module SessionService
28
+ ##
29
+ # Client for the SessionService service.
30
+ #
31
+ # Session service provides APIs for interacting with CES agents.
32
+ #
33
+ class Client
34
+ # @private
35
+ API_VERSION = ""
36
+
37
+ # @private
38
+ DEFAULT_ENDPOINT_TEMPLATE = "ces.$UNIVERSE_DOMAIN$"
39
+
40
+ include Paths
41
+
42
+ # @private
43
+ attr_reader :session_service_stub
44
+
45
+ ##
46
+ # Configure the SessionService Client class.
47
+ #
48
+ # See {::Google::Cloud::Ces::V1::SessionService::Client::Configuration}
49
+ # for a description of the configuration fields.
50
+ #
51
+ # @example
52
+ #
53
+ # # Modify the configuration for all SessionService clients
54
+ # ::Google::Cloud::Ces::V1::SessionService::Client.configure do |config|
55
+ # config.timeout = 10.0
56
+ # end
57
+ #
58
+ # @yield [config] Configure the Client client.
59
+ # @yieldparam config [Client::Configuration]
60
+ #
61
+ # @return [Client::Configuration]
62
+ #
63
+ def self.configure
64
+ @configure ||= begin
65
+ namespace = ["Google", "Cloud", "Ces", "V1"]
66
+ parent_config = while namespace.any?
67
+ parent_name = namespace.join "::"
68
+ parent_const = const_get parent_name
69
+ break parent_const.configure if parent_const.respond_to? :configure
70
+ namespace.pop
71
+ end
72
+ default_config = Client::Configuration.new parent_config
73
+
74
+ default_config.timeout = 60.0
75
+ default_config.retry_policy = {
76
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
77
+ }
78
+
79
+ default_config.rpcs.run_session.timeout = 220.0
80
+ default_config.rpcs.run_session.retry_policy = {
81
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: []
82
+ }
83
+
84
+ default_config.rpcs.bidi_run_session.timeout = 3600.0
85
+ default_config.rpcs.bidi_run_session.retry_policy = {
86
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: []
87
+ }
88
+
89
+ default_config
90
+ end
91
+ yield @configure if block_given?
92
+ @configure
93
+ end
94
+
95
+ ##
96
+ # Configure the SessionService Client instance.
97
+ #
98
+ # The configuration is set to the derived mode, meaning that values can be changed,
99
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
100
+ # should be made on {Client.configure}.
101
+ #
102
+ # See {::Google::Cloud::Ces::V1::SessionService::Client::Configuration}
103
+ # for a description of the configuration fields.
104
+ #
105
+ # @yield [config] Configure the Client client.
106
+ # @yieldparam config [Client::Configuration]
107
+ #
108
+ # @return [Client::Configuration]
109
+ #
110
+ def configure
111
+ yield @config if block_given?
112
+ @config
113
+ end
114
+
115
+ ##
116
+ # The effective universe domain
117
+ #
118
+ # @return [String]
119
+ #
120
+ def universe_domain
121
+ @session_service_stub.universe_domain
122
+ end
123
+
124
+ ##
125
+ # Create a new SessionService client object.
126
+ #
127
+ # @example
128
+ #
129
+ # # Create a client using the default configuration
130
+ # client = ::Google::Cloud::Ces::V1::SessionService::Client.new
131
+ #
132
+ # # Create a client using a custom configuration
133
+ # client = ::Google::Cloud::Ces::V1::SessionService::Client.new do |config|
134
+ # config.timeout = 10.0
135
+ # end
136
+ #
137
+ # @yield [config] Configure the SessionService client.
138
+ # @yieldparam config [Client::Configuration]
139
+ #
140
+ def initialize
141
+ # These require statements are intentionally placed here to initialize
142
+ # the gRPC module only when it's required.
143
+ # See https://github.com/googleapis/toolkit/issues/446
144
+ require "gapic/grpc"
145
+ require "google/cloud/ces/v1/session_service_services_pb"
146
+
147
+ # Create the configuration object
148
+ @config = Configuration.new Client.configure
149
+
150
+ # Yield the configuration if needed
151
+ yield @config if block_given?
152
+
153
+ # Create credentials
154
+ credentials = @config.credentials
155
+ # Use self-signed JWT if the endpoint is unchanged from default,
156
+ # but only if the default endpoint does not have a region prefix.
157
+ enable_self_signed_jwt = @config.endpoint.nil? ||
158
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
159
+ !@config.endpoint.split(".").first.include?("-"))
160
+ credentials ||= Credentials.default scope: @config.scope,
161
+ enable_self_signed_jwt: enable_self_signed_jwt
162
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
163
+ credentials = Credentials.new credentials, scope: @config.scope
164
+ end
165
+ @quota_project_id = @config.quota_project
166
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
167
+
168
+ @session_service_stub = ::Gapic::ServiceStub.new(
169
+ ::Google::Cloud::Ces::V1::SessionService::Stub,
170
+ credentials: credentials,
171
+ endpoint: @config.endpoint,
172
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
173
+ universe_domain: @config.universe_domain,
174
+ channel_args: @config.channel_args,
175
+ interceptors: @config.interceptors,
176
+ channel_pool_config: @config.channel_pool,
177
+ logger: @config.logger
178
+ )
179
+
180
+ @session_service_stub.stub_logger&.info do |entry|
181
+ entry.set_system_name
182
+ entry.set_service
183
+ entry.message = "Created client for #{entry.service}"
184
+ entry.set_credentials_fields credentials
185
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
186
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
187
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
188
+ end
189
+
190
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
191
+ config.credentials = credentials
192
+ config.quota_project = @quota_project_id
193
+ config.endpoint = @session_service_stub.endpoint
194
+ config.universe_domain = @session_service_stub.universe_domain
195
+ config.logger = @session_service_stub.logger if config.respond_to? :logger=
196
+ end
197
+ end
198
+
199
+ ##
200
+ # Get the associated client for mix-in of the Locations.
201
+ #
202
+ # @return [Google::Cloud::Location::Locations::Client]
203
+ #
204
+ attr_reader :location_client
205
+
206
+ ##
207
+ # The logger used for request/response debug logging.
208
+ #
209
+ # @return [Logger]
210
+ #
211
+ def logger
212
+ @session_service_stub.logger
213
+ end
214
+
215
+ # Service calls
216
+
217
+ ##
218
+ # Initiates a single-turn interaction with the CES agent within a session.
219
+ #
220
+ # @overload run_session(request, options = nil)
221
+ # Pass arguments to `run_session` via a request object, either of type
222
+ # {::Google::Cloud::Ces::V1::RunSessionRequest} or an equivalent Hash.
223
+ #
224
+ # @param request [::Google::Cloud::Ces::V1::RunSessionRequest, ::Hash]
225
+ # A request object representing the call parameters. Required. To specify no
226
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
227
+ # @param options [::Gapic::CallOptions, ::Hash]
228
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
229
+ #
230
+ # @overload run_session(config: nil, inputs: nil)
231
+ # Pass arguments to `run_session` via keyword arguments. Note that at
232
+ # least one keyword argument is required. To specify no parameters, or to keep all
233
+ # the default parameter values, pass an empty Hash as a request object (see above).
234
+ #
235
+ # @param config [::Google::Cloud::Ces::V1::SessionConfig, ::Hash]
236
+ # Required. The configuration for the session.
237
+ # @param inputs [::Array<::Google::Cloud::Ces::V1::SessionInput, ::Hash>]
238
+ # Required. Inputs for the session.
239
+ #
240
+ # @yield [response, operation] Access the result along with the RPC operation
241
+ # @yieldparam response [::Google::Cloud::Ces::V1::RunSessionResponse]
242
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
243
+ #
244
+ # @return [::Google::Cloud::Ces::V1::RunSessionResponse]
245
+ #
246
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
247
+ #
248
+ # @example Basic example
249
+ # require "google/cloud/ces/v1"
250
+ #
251
+ # # Create a client object. The client can be reused for multiple calls.
252
+ # client = Google::Cloud::Ces::V1::SessionService::Client.new
253
+ #
254
+ # # Create a request. To set request fields, pass in keyword arguments.
255
+ # request = Google::Cloud::Ces::V1::RunSessionRequest.new
256
+ #
257
+ # # Call the run_session method.
258
+ # result = client.run_session request
259
+ #
260
+ # # The returned object is of type Google::Cloud::Ces::V1::RunSessionResponse.
261
+ # p result
262
+ #
263
+ def run_session request, options = nil
264
+ raise ::ArgumentError, "request must be provided" if request.nil?
265
+
266
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Ces::V1::RunSessionRequest
267
+
268
+ # Converts hash and nil to an options object
269
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
270
+
271
+ # Customize the options with defaults
272
+ metadata = @config.rpcs.run_session.metadata.to_h
273
+
274
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
275
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
276
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
277
+ gapic_version: ::Google::Cloud::Ces::V1::VERSION
278
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
279
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
280
+
281
+ header_params = {}
282
+ if request.config&.session
283
+ header_params["config.session"] = request.config.session
284
+ end
285
+
286
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
287
+ metadata[:"x-goog-request-params"] ||= request_params_header
288
+
289
+ options.apply_defaults timeout: @config.rpcs.run_session.timeout,
290
+ metadata: metadata,
291
+ retry_policy: @config.rpcs.run_session.retry_policy
292
+
293
+ options.apply_defaults timeout: @config.timeout,
294
+ metadata: @config.metadata,
295
+ retry_policy: @config.retry_policy
296
+
297
+ @session_service_stub.call_rpc :run_session, request, options: options do |response, operation|
298
+ yield response, operation if block_given?
299
+ end
300
+ rescue ::GRPC::BadStatus => e
301
+ raise ::Google::Cloud::Error.from_error(e)
302
+ end
303
+
304
+ ##
305
+ # Initiates a single-turn interaction with the CES agent. Uses server-side
306
+ # streaming to deliver incremental results and partial responses as they are
307
+ # generated.
308
+ #
309
+ # By default, complete responses (e.g., messages from callbacks or full LLM
310
+ # responses) are sent to the client as soon as they are available. To enable
311
+ # streaming individual text chunks directly from the model, set
312
+ # {::Google::Cloud::Ces::V1::SessionConfig#enable_text_streaming enable_text_streaming}
313
+ # to true.
314
+ #
315
+ # @overload stream_run_session(request, options = nil)
316
+ # Pass arguments to `stream_run_session` via a request object, either of type
317
+ # {::Google::Cloud::Ces::V1::RunSessionRequest} or an equivalent Hash.
318
+ #
319
+ # @param request [::Google::Cloud::Ces::V1::RunSessionRequest, ::Hash]
320
+ # A request object representing the call parameters. Required. To specify no
321
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
322
+ # @param options [::Gapic::CallOptions, ::Hash]
323
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
324
+ #
325
+ # @overload stream_run_session(config: nil, inputs: nil)
326
+ # Pass arguments to `stream_run_session` via keyword arguments. Note that at
327
+ # least one keyword argument is required. To specify no parameters, or to keep all
328
+ # the default parameter values, pass an empty Hash as a request object (see above).
329
+ #
330
+ # @param config [::Google::Cloud::Ces::V1::SessionConfig, ::Hash]
331
+ # Required. The configuration for the session.
332
+ # @param inputs [::Array<::Google::Cloud::Ces::V1::SessionInput, ::Hash>]
333
+ # Required. Inputs for the session.
334
+ #
335
+ # @yield [response, operation] Access the result along with the RPC operation
336
+ # @yieldparam response [::Enumerable<::Google::Cloud::Ces::V1::RunSessionResponse>]
337
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
338
+ #
339
+ # @return [::Enumerable<::Google::Cloud::Ces::V1::RunSessionResponse>]
340
+ #
341
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
342
+ #
343
+ # @example Basic example
344
+ # require "google/cloud/ces/v1"
345
+ #
346
+ # # Create a client object. The client can be reused for multiple calls.
347
+ # client = Google::Cloud::Ces::V1::SessionService::Client.new
348
+ #
349
+ # # Create a request. To set request fields, pass in keyword arguments.
350
+ # request = Google::Cloud::Ces::V1::RunSessionRequest.new
351
+ #
352
+ # # Call the stream_run_session method to start streaming.
353
+ # output = client.stream_run_session request
354
+ #
355
+ # # The returned object is a streamed enumerable yielding elements of type
356
+ # # ::Google::Cloud::Ces::V1::RunSessionResponse
357
+ # output.each do |current_response|
358
+ # p current_response
359
+ # end
360
+ #
361
+ def stream_run_session request, options = nil
362
+ raise ::ArgumentError, "request must be provided" if request.nil?
363
+
364
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Ces::V1::RunSessionRequest
365
+
366
+ # Converts hash and nil to an options object
367
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
368
+
369
+ # Customize the options with defaults
370
+ metadata = @config.rpcs.stream_run_session.metadata.to_h
371
+
372
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
373
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
374
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
375
+ gapic_version: ::Google::Cloud::Ces::V1::VERSION
376
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
377
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
378
+
379
+ header_params = {}
380
+ if request.config&.session
381
+ header_params["config.session"] = request.config.session
382
+ end
383
+
384
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
385
+ metadata[:"x-goog-request-params"] ||= request_params_header
386
+
387
+ options.apply_defaults timeout: @config.rpcs.stream_run_session.timeout,
388
+ metadata: metadata,
389
+ retry_policy: @config.rpcs.stream_run_session.retry_policy
390
+
391
+ options.apply_defaults timeout: @config.timeout,
392
+ metadata: @config.metadata,
393
+ retry_policy: @config.retry_policy
394
+
395
+ @session_service_stub.call_rpc :stream_run_session, request, options: options do |response, operation|
396
+ yield response, operation if block_given?
397
+ end
398
+ rescue ::GRPC::BadStatus => e
399
+ raise ::Google::Cloud::Error.from_error(e)
400
+ end
401
+
402
+ ##
403
+ # Establishes a bidirectional streaming connection with the CES agent.
404
+ # The agent processes continuous multimodal inputs (e.g., text, audio) and
405
+ # generates real-time multimodal output streams.
406
+ #
407
+ # --- Client Request Stream ---
408
+ # The client streams requests in the following order:
409
+ #
410
+ # 1. Initialization:
411
+ # The first message must contain
412
+ # {::Google::Cloud::Ces::V1::BidiSessionClientMessage#config SessionConfig}.
413
+ # For audio sessions, this should also include
414
+ # {::Google::Cloud::Ces::V1::SessionConfig#input_audio_config InputAudioConfig}
415
+ # and
416
+ # {::Google::Cloud::Ces::V1::SessionConfig#output_audio_config OutputAudioConfig}
417
+ # to define audio processing and synthesis parameters.
418
+ #
419
+ # 2. Interaction:
420
+ # Subsequent messages stream
421
+ # {::Google::Cloud::Ces::V1::BidiSessionClientMessage#realtime_input SessionInput}
422
+ # containing real-time user input data.
423
+ #
424
+ # 3. Termination:
425
+ # The client should half-close the stream when there is no more user
426
+ # input. It should also half-close upon receiving
427
+ # {::Google::Cloud::Ces::V1::BidiSessionServerMessage#end_session EndSession}
428
+ # or {::Google::Cloud::Ces::V1::BidiSessionServerMessage#go_away GoAway} from
429
+ # the agent.
430
+ #
431
+ # --- Server Response Stream ---
432
+ # For each interaction turn, the agent streams messages in the following
433
+ # sequence:
434
+ #
435
+ # 1. Speech Recognition (First N messages):
436
+ # Contains
437
+ # {::Google::Cloud::Ces::V1::BidiSessionServerMessage#recognition_result RecognitionResult}
438
+ # representing the concatenated user speech segments captured so far.
439
+ # This is only populated for audio sessions.
440
+ #
441
+ # 2. Response (Next M messages):
442
+ # Contains
443
+ # {::Google::Cloud::Ces::V1::BidiSessionServerMessage#session_output SessionOutput}
444
+ # delivering the agent's response in various modalities (e.g., text,
445
+ # audio).
446
+ #
447
+ # 3. Turn Completion (Final message of the turn):
448
+ # Contains
449
+ # {::Google::Cloud::Ces::V1::BidiSessionServerMessage#session_output SessionOutput}
450
+ # with {::Google::Cloud::Ces::V1::SessionOutput#turn_completed turn_completed}
451
+ # set to true. This signals the end of the current turn and includes
452
+ # {::Google::Cloud::Ces::V1::SessionOutput#diagnostic_info DiagnosticInfo}
453
+ # with execution details.
454
+ #
455
+ # --- Audio Best Practices ---
456
+ # 1. Streaming:
457
+ # Stream {::Google::Cloud::Ces::V1::SessionInput#audio audio data}
458
+ # **CONTINUOUSLY**, even during silence. Recommended chunk size: 40-120ms
459
+ # (balances latency vs. efficiency).
460
+ #
461
+ # 2. Playback & Interruption:
462
+ # Play {::Google::Cloud::Ces::V1::SessionOutput#audio audio responses} upon
463
+ # receipt. Stop playback immediately if an
464
+ # {::Google::Cloud::Ces::V1::BidiSessionServerMessage#interruption_signal InterruptionSignal}
465
+ # is received (e.g., user barge-in or new agent response).
466
+ #
467
+ # @param request [::Gapic::StreamInput, ::Enumerable<::Google::Cloud::Ces::V1::BidiSessionClientMessage, ::Hash>]
468
+ # An enumerable of {::Google::Cloud::Ces::V1::BidiSessionClientMessage} instances.
469
+ # @param options [::Gapic::CallOptions, ::Hash]
470
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
471
+ #
472
+ # @yield [response, operation] Access the result along with the RPC operation
473
+ # @yieldparam response [::Enumerable<::Google::Cloud::Ces::V1::BidiSessionServerMessage>]
474
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
475
+ #
476
+ # @return [::Enumerable<::Google::Cloud::Ces::V1::BidiSessionServerMessage>]
477
+ #
478
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
479
+ #
480
+ # @example Basic example
481
+ # require "google/cloud/ces/v1"
482
+ #
483
+ # # Create a client object. The client can be reused for multiple calls.
484
+ # client = Google::Cloud::Ces::V1::SessionService::Client.new
485
+ #
486
+ # # Create an input stream.
487
+ # input = Gapic::StreamInput.new
488
+ #
489
+ # # Call the bidi_run_session method to start streaming.
490
+ # output = client.bidi_run_session input
491
+ #
492
+ # # Send requests on the stream. For each request object, set fields by
493
+ # # passing keyword arguments. Be sure to close the stream when done.
494
+ # input << Google::Cloud::Ces::V1::BidiSessionClientMessage.new
495
+ # input << Google::Cloud::Ces::V1::BidiSessionClientMessage.new
496
+ # input.close
497
+ #
498
+ # # The returned object is a streamed enumerable yielding elements of type
499
+ # # ::Google::Cloud::Ces::V1::BidiSessionServerMessage
500
+ # output.each do |current_response|
501
+ # p current_response
502
+ # end
503
+ #
504
+ def bidi_run_session request, options = nil
505
+ unless request.is_a? ::Enumerable
506
+ raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
507
+ request = request.to_enum
508
+ end
509
+
510
+ request = request.lazy.map do |req|
511
+ ::Gapic::Protobuf.coerce req, to: ::Google::Cloud::Ces::V1::BidiSessionClientMessage
512
+ end
513
+
514
+ # Converts hash and nil to an options object
515
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
516
+
517
+ # Customize the options with defaults
518
+ metadata = @config.rpcs.bidi_run_session.metadata.to_h
519
+
520
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
521
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
522
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
523
+ gapic_version: ::Google::Cloud::Ces::V1::VERSION
524
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
525
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
526
+
527
+ options.apply_defaults timeout: @config.rpcs.bidi_run_session.timeout,
528
+ metadata: metadata,
529
+ retry_policy: @config.rpcs.bidi_run_session.retry_policy
530
+
531
+ options.apply_defaults timeout: @config.timeout,
532
+ metadata: @config.metadata,
533
+ retry_policy: @config.retry_policy
534
+
535
+ @session_service_stub.call_rpc :bidi_run_session, request, options: options do |response, operation|
536
+ yield response, operation if block_given?
537
+ end
538
+ rescue ::GRPC::BadStatus => e
539
+ raise ::Google::Cloud::Error.from_error(e)
540
+ end
541
+
542
+ ##
543
+ # Configuration class for the SessionService API.
544
+ #
545
+ # This class represents the configuration for SessionService,
546
+ # providing control over timeouts, retry behavior, logging, transport
547
+ # parameters, and other low-level controls. Certain parameters can also be
548
+ # applied individually to specific RPCs. See
549
+ # {::Google::Cloud::Ces::V1::SessionService::Client::Configuration::Rpcs}
550
+ # for a list of RPCs that can be configured independently.
551
+ #
552
+ # Configuration can be applied globally to all clients, or to a single client
553
+ # on construction.
554
+ #
555
+ # @example
556
+ #
557
+ # # Modify the global config, setting the timeout for
558
+ # # run_session to 20 seconds,
559
+ # # and all remaining timeouts to 10 seconds.
560
+ # ::Google::Cloud::Ces::V1::SessionService::Client.configure do |config|
561
+ # config.timeout = 10.0
562
+ # config.rpcs.run_session.timeout = 20.0
563
+ # end
564
+ #
565
+ # # Apply the above configuration only to a new client.
566
+ # client = ::Google::Cloud::Ces::V1::SessionService::Client.new do |config|
567
+ # config.timeout = 10.0
568
+ # config.rpcs.run_session.timeout = 20.0
569
+ # end
570
+ #
571
+ # @!attribute [rw] endpoint
572
+ # A custom service endpoint, as a hostname or hostname:port. The default is
573
+ # nil, indicating to use the default endpoint in the current universe domain.
574
+ # @return [::String,nil]
575
+ # @!attribute [rw] credentials
576
+ # Credentials to send with calls. You may provide any of the following types:
577
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
578
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
579
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
580
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
581
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
582
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
583
+ # * (`nil`) indicating no credentials
584
+ #
585
+ # @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
586
+ # is deprecated. Providing an unvalidated credential configuration to
587
+ # Google APIs can compromise the security of your systems and data.
588
+ #
589
+ # @example
590
+ #
591
+ # # The recommended way to provide credentials is to use the `make_creds` method
592
+ # # on the appropriate credentials class for your environment.
593
+ #
594
+ # require "googleauth"
595
+ #
596
+ # credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
597
+ # json_key_io: ::File.open("/path/to/keyfile.json")
598
+ # )
599
+ #
600
+ # client = ::Google::Cloud::Ces::V1::SessionService::Client.new do |config|
601
+ # config.credentials = credentials
602
+ # end
603
+ #
604
+ # @note Warning: If you accept a credential configuration (JSON file or Hash) from an
605
+ # external source for authentication to Google Cloud, you must validate it before
606
+ # providing it to a Google API client library. Providing an unvalidated credential
607
+ # configuration to Google APIs can compromise the security of your systems and data.
608
+ # For more information, refer to [Validate credential configurations from external
609
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
610
+ # @return [::Object]
611
+ # @!attribute [rw] scope
612
+ # The OAuth scopes
613
+ # @return [::Array<::String>]
614
+ # @!attribute [rw] lib_name
615
+ # The library name as recorded in instrumentation and logging
616
+ # @return [::String]
617
+ # @!attribute [rw] lib_version
618
+ # The library version as recorded in instrumentation and logging
619
+ # @return [::String]
620
+ # @!attribute [rw] channel_args
621
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
622
+ # `GRPC::Core::Channel` object is provided as the credential.
623
+ # @return [::Hash]
624
+ # @!attribute [rw] interceptors
625
+ # An array of interceptors that are run before calls are executed.
626
+ # @return [::Array<::GRPC::ClientInterceptor>]
627
+ # @!attribute [rw] timeout
628
+ # The call timeout in seconds.
629
+ # @return [::Numeric]
630
+ # @!attribute [rw] metadata
631
+ # Additional gRPC headers to be sent with the call.
632
+ # @return [::Hash{::Symbol=>::String}]
633
+ # @!attribute [rw] retry_policy
634
+ # The retry policy. The value is a hash with the following keys:
635
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
636
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
637
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
638
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
639
+ # trigger a retry.
640
+ # @return [::Hash]
641
+ # @!attribute [rw] quota_project
642
+ # A separate project against which to charge quota.
643
+ # @return [::String]
644
+ # @!attribute [rw] universe_domain
645
+ # The universe domain within which to make requests. This determines the
646
+ # default endpoint URL. The default value of nil uses the environment
647
+ # universe (usually the default "googleapis.com" universe).
648
+ # @return [::String,nil]
649
+ # @!attribute [rw] logger
650
+ # A custom logger to use for request/response debug logging, or the value
651
+ # `:default` (the default) to construct a default logger, or `nil` to
652
+ # explicitly disable logging.
653
+ # @return [::Logger,:default,nil]
654
+ #
655
+ class Configuration
656
+ extend ::Gapic::Config
657
+
658
+ # @private
659
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
660
+ DEFAULT_ENDPOINT = "ces.googleapis.com"
661
+
662
+ config_attr :endpoint, nil, ::String, nil
663
+ config_attr :credentials, nil do |value|
664
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
665
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC::Core::Channel
666
+ allowed.any? { |klass| klass === value }
667
+ end
668
+ config_attr :scope, nil, ::String, ::Array, nil
669
+ config_attr :lib_name, nil, ::String, nil
670
+ config_attr :lib_version, nil, ::String, nil
671
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
672
+ config_attr :interceptors, nil, ::Array, nil
673
+ config_attr :timeout, nil, ::Numeric, nil
674
+ config_attr :metadata, nil, ::Hash, nil
675
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
676
+ config_attr :quota_project, nil, ::String, nil
677
+ config_attr :universe_domain, nil, ::String, nil
678
+ config_attr :logger, :default, ::Logger, nil, :default
679
+
680
+ # @private
681
+ def initialize parent_config = nil
682
+ @parent_config = parent_config unless parent_config.nil?
683
+
684
+ yield self if block_given?
685
+ end
686
+
687
+ ##
688
+ # Configurations for individual RPCs
689
+ # @return [Rpcs]
690
+ #
691
+ def rpcs
692
+ @rpcs ||= begin
693
+ parent_rpcs = nil
694
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
695
+ Rpcs.new parent_rpcs
696
+ end
697
+ end
698
+
699
+ ##
700
+ # Configuration for the channel pool
701
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
702
+ #
703
+ def channel_pool
704
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
705
+ end
706
+
707
+ ##
708
+ # Configuration RPC class for the SessionService API.
709
+ #
710
+ # Includes fields providing the configuration for each RPC in this service.
711
+ # Each configuration object is of type `Gapic::Config::Method` and includes
712
+ # the following configuration fields:
713
+ #
714
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
715
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
716
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
717
+ # include the following keys:
718
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
719
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
720
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
721
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
722
+ # trigger a retry.
723
+ #
724
+ class Rpcs
725
+ ##
726
+ # RPC-specific configuration for `run_session`
727
+ # @return [::Gapic::Config::Method]
728
+ #
729
+ attr_reader :run_session
730
+ ##
731
+ # RPC-specific configuration for `stream_run_session`
732
+ # @return [::Gapic::Config::Method]
733
+ #
734
+ attr_reader :stream_run_session
735
+ ##
736
+ # RPC-specific configuration for `bidi_run_session`
737
+ # @return [::Gapic::Config::Method]
738
+ #
739
+ attr_reader :bidi_run_session
740
+
741
+ # @private
742
+ def initialize parent_rpcs = nil
743
+ run_session_config = parent_rpcs.run_session if parent_rpcs.respond_to? :run_session
744
+ @run_session = ::Gapic::Config::Method.new run_session_config
745
+ stream_run_session_config = parent_rpcs.stream_run_session if parent_rpcs.respond_to? :stream_run_session
746
+ @stream_run_session = ::Gapic::Config::Method.new stream_run_session_config
747
+ bidi_run_session_config = parent_rpcs.bidi_run_session if parent_rpcs.respond_to? :bidi_run_session
748
+ @bidi_run_session = ::Gapic::Config::Method.new bidi_run_session_config
749
+
750
+ yield self if block_given?
751
+ end
752
+ end
753
+ end
754
+ end
755
+ end
756
+ end
757
+ end
758
+ end
759
+ end