google-cloud-discovery_engine-v1 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/lib/google/cloud/discovery_engine/v1/completion_service/client.rb +9 -3
  3. data/lib/google/cloud/discovery_engine/v1/completion_service/operations.rb +13 -5
  4. data/lib/google/cloud/discovery_engine/v1/completion_service/rest/client.rb +9 -3
  5. data/lib/google/cloud/discovery_engine/v1/completion_service/rest/operations.rb +28 -5
  6. data/lib/google/cloud/discovery_engine/v1/control_service/client.rb +875 -0
  7. data/lib/google/cloud/discovery_engine/v1/control_service/credentials.rb +47 -0
  8. data/lib/google/cloud/discovery_engine/v1/control_service/paths.rb +167 -0
  9. data/lib/google/cloud/discovery_engine/v1/control_service/rest/client.rb +814 -0
  10. data/lib/google/cloud/discovery_engine/v1/control_service/rest/service_stub.rb +440 -0
  11. data/lib/google/cloud/discovery_engine/v1/control_service/rest.rb +55 -0
  12. data/lib/google/cloud/discovery_engine/v1/control_service.rb +58 -0
  13. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/client.rb +764 -6
  14. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/paths.rb +199 -0
  15. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/client.rb +715 -6
  16. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/service_stub.rb +520 -0
  17. data/lib/google/cloud/discovery_engine/v1/data_store_service/client.rb +15 -7
  18. data/lib/google/cloud/discovery_engine/v1/data_store_service/operations.rb +13 -5
  19. data/lib/google/cloud/discovery_engine/v1/data_store_service/paths.rb +45 -0
  20. data/lib/google/cloud/discovery_engine/v1/data_store_service/rest/client.rb +15 -7
  21. data/lib/google/cloud/discovery_engine/v1/data_store_service/rest/operations.rb +28 -5
  22. data/lib/google/cloud/discovery_engine/v1/document_service/client.rb +23 -13
  23. data/lib/google/cloud/discovery_engine/v1/document_service/operations.rb +13 -5
  24. data/lib/google/cloud/discovery_engine/v1/document_service/rest/client.rb +23 -13
  25. data/lib/google/cloud/discovery_engine/v1/document_service/rest/operations.rb +28 -5
  26. data/lib/google/cloud/discovery_engine/v1/engine_service/client.rb +13 -5
  27. data/lib/google/cloud/discovery_engine/v1/engine_service/operations.rb +13 -5
  28. data/lib/google/cloud/discovery_engine/v1/engine_service/rest/client.rb +13 -5
  29. data/lib/google/cloud/discovery_engine/v1/engine_service/rest/operations.rb +28 -5
  30. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/client.rb +471 -0
  31. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/credentials.rb +47 -0
  32. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/paths.rb +52 -0
  33. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/rest/client.rb +438 -0
  34. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/rest/service_stub.rb +129 -0
  35. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/rest.rb +52 -0
  36. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service.rb +55 -0
  37. data/lib/google/cloud/discovery_engine/v1/project_service/client.rb +485 -0
  38. data/lib/google/cloud/discovery_engine/v1/project_service/credentials.rb +47 -0
  39. data/lib/google/cloud/discovery_engine/v1/project_service/operations.rb +809 -0
  40. data/lib/google/cloud/discovery_engine/v1/project_service/paths.rb +47 -0
  41. data/lib/google/cloud/discovery_engine/v1/project_service/rest/client.rb +452 -0
  42. data/lib/google/cloud/discovery_engine/v1/project_service/rest/operations.rb +1114 -0
  43. data/lib/google/cloud/discovery_engine/v1/project_service/rest/service_stub.rb +129 -0
  44. data/lib/google/cloud/discovery_engine/v1/project_service/rest.rb +54 -0
  45. data/lib/google/cloud/discovery_engine/v1/project_service.rb +57 -0
  46. data/lib/google/cloud/discovery_engine/v1/rank_service/client.rb +481 -0
  47. data/lib/google/cloud/discovery_engine/v1/rank_service/credentials.rb +47 -0
  48. data/lib/google/cloud/discovery_engine/v1/rank_service/paths.rb +52 -0
  49. data/lib/google/cloud/discovery_engine/v1/rank_service/rest/client.rb +448 -0
  50. data/lib/google/cloud/discovery_engine/v1/rank_service/rest/service_stub.rb +129 -0
  51. data/lib/google/cloud/discovery_engine/v1/rank_service/rest.rb +52 -0
  52. data/lib/google/cloud/discovery_engine/v1/rank_service.rb +55 -0
  53. data/lib/google/cloud/discovery_engine/v1/recommendation_service/client.rb +24 -19
  54. data/lib/google/cloud/discovery_engine/v1/recommendation_service/paths.rb +66 -0
  55. data/lib/google/cloud/discovery_engine/v1/recommendation_service/rest/client.rb +24 -19
  56. data/lib/google/cloud/discovery_engine/v1/rest.rb +4 -0
  57. data/lib/google/cloud/discovery_engine/v1/schema_service/client.rb +18 -10
  58. data/lib/google/cloud/discovery_engine/v1/schema_service/operations.rb +13 -5
  59. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/client.rb +18 -10
  60. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/operations.rb +28 -5
  61. data/lib/google/cloud/discovery_engine/v1/search_service/client.rb +15 -8
  62. data/lib/google/cloud/discovery_engine/v1/search_service/rest/client.rb +15 -8
  63. data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/client.rb +27 -12
  64. data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/operations.rb +13 -5
  65. data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/rest/client.rb +27 -12
  66. data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/rest/operations.rb +28 -5
  67. data/lib/google/cloud/discovery_engine/v1/user_event_service/client.rb +23 -6
  68. data/lib/google/cloud/discovery_engine/v1/user_event_service/operations.rb +13 -5
  69. data/lib/google/cloud/discovery_engine/v1/user_event_service/paths.rb +21 -0
  70. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/client.rb +23 -6
  71. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/operations.rb +28 -5
  72. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/service_stub.rb +8 -0
  73. data/lib/google/cloud/discovery_engine/v1/version.rb +1 -1
  74. data/lib/google/cloud/discovery_engine/v1.rb +4 -0
  75. data/lib/google/cloud/discoveryengine/v1/answer_pb.rb +69 -0
  76. data/lib/google/cloud/discoveryengine/v1/common_pb.rb +2 -1
  77. data/lib/google/cloud/discoveryengine/v1/control_pb.rb +55 -0
  78. data/lib/google/cloud/discoveryengine/v1/control_service_pb.rb +57 -0
  79. data/lib/google/cloud/discoveryengine/v1/control_service_services_pb.rb +69 -0
  80. data/lib/google/cloud/discoveryengine/v1/conversational_search_service_pb.rb +32 -1
  81. data/lib/google/cloud/discoveryengine/v1/conversational_search_service_services_pb.rb +25 -0
  82. data/lib/google/cloud/discoveryengine/v1/data_store_pb.rb +3 -1
  83. data/lib/google/cloud/discoveryengine/v1/document_processing_config_pb.rb +48 -0
  84. data/lib/google/cloud/discoveryengine/v1/document_service_services_pb.rb +1 -1
  85. data/lib/google/cloud/discoveryengine/v1/engine_pb.rb +1 -1
  86. data/lib/google/cloud/discoveryengine/v1/grounded_generation_service_pb.rb +52 -0
  87. data/lib/google/cloud/discoveryengine/v1/grounded_generation_service_services_pb.rb +45 -0
  88. data/lib/google/cloud/discoveryengine/v1/grounding_pb.rb +46 -0
  89. data/lib/google/cloud/discoveryengine/v1/project_pb.rb +49 -0
  90. data/lib/google/cloud/discoveryengine/v1/project_service_pb.rb +50 -0
  91. data/lib/google/cloud/discoveryengine/v1/project_service_services_pb.rb +51 -0
  92. data/lib/google/cloud/discoveryengine/v1/rank_service_pb.rb +49 -0
  93. data/lib/google/cloud/discoveryengine/v1/rank_service_services_pb.rb +45 -0
  94. data/lib/google/cloud/discoveryengine/v1/session_pb.rb +50 -0
  95. data/lib/google/cloud/discoveryengine/v1/site_search_engine_pb.rb +1 -1
  96. data/lib/google/cloud/discoveryengine/v1/user_event_pb.rb +1 -1
  97. data/lib/google/cloud/discoveryengine/v1/user_event_service_pb.rb +1 -1
  98. data/lib/google/cloud/discoveryengine/v1/user_event_service_services_pb.rb +1 -1
  99. data/proto_docs/google/cloud/discoveryengine/v1/answer.rb +362 -0
  100. data/proto_docs/google/cloud/discoveryengine/v1/common.rb +16 -0
  101. data/proto_docs/google/cloud/discoveryengine/v1/control.rb +207 -0
  102. data/proto_docs/google/cloud/discoveryengine/v1/control_service.rb +126 -0
  103. data/proto_docs/google/cloud/discoveryengine/v1/conversation.rb +2 -2
  104. data/proto_docs/google/cloud/discoveryengine/v1/conversational_search_service.rb +485 -0
  105. data/proto_docs/google/cloud/discoveryengine/v1/data_store.rb +3 -0
  106. data/proto_docs/google/cloud/discoveryengine/v1/data_store_service.rb +2 -2
  107. data/proto_docs/google/cloud/discoveryengine/v1/document_processing_config.rb +102 -0
  108. data/proto_docs/google/cloud/discoveryengine/v1/document_service.rb +5 -5
  109. data/proto_docs/google/cloud/discoveryengine/v1/engine.rb +3 -3
  110. data/proto_docs/google/cloud/discoveryengine/v1/grounded_generation_service.rb +144 -0
  111. data/proto_docs/google/cloud/discoveryengine/v1/grounding.rb +79 -0
  112. data/proto_docs/google/cloud/discoveryengine/v1/import_config.rb +4 -4
  113. data/proto_docs/google/cloud/discoveryengine/v1/project.rb +106 -0
  114. data/proto_docs/google/cloud/discoveryengine/v1/project_service.rb +57 -0
  115. data/proto_docs/google/cloud/discoveryengine/v1/rank_service.rb +124 -0
  116. data/proto_docs/google/cloud/discoveryengine/v1/recommendation_service.rb +20 -19
  117. data/proto_docs/google/cloud/discoveryengine/v1/schema_service.rb +5 -5
  118. data/proto_docs/google/cloud/discoveryengine/v1/search_service.rb +23 -18
  119. data/proto_docs/google/cloud/discoveryengine/v1/session.rb +88 -0
  120. data/proto_docs/google/cloud/discoveryengine/v1/site_search_engine.rb +3 -0
  121. data/proto_docs/google/cloud/discoveryengine/v1/user_event.rb +24 -3
  122. data/proto_docs/google/cloud/discoveryengine/v1/user_event_service.rb +13 -1
  123. metadata +56 -2
@@ -0,0 +1,438 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2024 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/grounded_generation_service_pb"
21
+ require "google/cloud/discovery_engine/v1/grounded_generation_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 GroundedGenerationService
29
+ module Rest
30
+ ##
31
+ # REST client for the GroundedGenerationService service.
32
+ #
33
+ # Service for grounded generation.
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 :grounded_generation_service_stub
46
+
47
+ ##
48
+ # Configure the GroundedGenerationService Client class.
49
+ #
50
+ # See {::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client::Configuration}
51
+ # for a description of the configuration fields.
52
+ #
53
+ # @example
54
+ #
55
+ # # Modify the configuration for all GroundedGenerationService clients
56
+ # ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::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 = 5.0
77
+ default_config.retry_policy = {
78
+ initial_delay: 0.1, max_delay: 5.0, multiplier: 1.3, retry_codes: [14]
79
+ }
80
+
81
+ default_config
82
+ end
83
+ yield @configure if block_given?
84
+ @configure
85
+ end
86
+
87
+ ##
88
+ # Configure the GroundedGenerationService Client instance.
89
+ #
90
+ # The configuration is set to the derived mode, meaning that values can be changed,
91
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
92
+ # should be made on {Client.configure}.
93
+ #
94
+ # See {::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client::Configuration}
95
+ # for a description of the configuration fields.
96
+ #
97
+ # @yield [config] Configure the Client client.
98
+ # @yieldparam config [Client::Configuration]
99
+ #
100
+ # @return [Client::Configuration]
101
+ #
102
+ def configure
103
+ yield @config if block_given?
104
+ @config
105
+ end
106
+
107
+ ##
108
+ # The effective universe domain
109
+ #
110
+ # @return [String]
111
+ #
112
+ def universe_domain
113
+ @grounded_generation_service_stub.universe_domain
114
+ end
115
+
116
+ ##
117
+ # Create a new GroundedGenerationService REST client object.
118
+ #
119
+ # @example
120
+ #
121
+ # # Create a client using the default configuration
122
+ # client = ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client.new
123
+ #
124
+ # # Create a client using a custom configuration
125
+ # client = ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client.new do |config|
126
+ # config.timeout = 10.0
127
+ # end
128
+ #
129
+ # @yield [config] Configure the GroundedGenerationService client.
130
+ # @yieldparam config [Client::Configuration]
131
+ #
132
+ def initialize
133
+ # Create the configuration object
134
+ @config = Configuration.new Client.configure
135
+
136
+ # Yield the configuration if needed
137
+ yield @config if block_given?
138
+
139
+ # Create credentials
140
+ credentials = @config.credentials
141
+ # Use self-signed JWT if the endpoint is unchanged from default,
142
+ # but only if the default endpoint does not have a region prefix.
143
+ enable_self_signed_jwt = @config.endpoint.nil? ||
144
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
145
+ !@config.endpoint.split(".").first.include?("-"))
146
+ credentials ||= Credentials.default scope: @config.scope,
147
+ enable_self_signed_jwt: enable_self_signed_jwt
148
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
149
+ credentials = Credentials.new credentials, scope: @config.scope
150
+ end
151
+
152
+ @quota_project_id = @config.quota_project
153
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
154
+
155
+ @grounded_generation_service_stub = ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::ServiceStub.new(
156
+ endpoint: @config.endpoint,
157
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
158
+ universe_domain: @config.universe_domain,
159
+ credentials: credentials
160
+ )
161
+
162
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
163
+ config.credentials = credentials
164
+ config.quota_project = @quota_project_id
165
+ config.endpoint = @grounded_generation_service_stub.endpoint
166
+ config.universe_domain = @grounded_generation_service_stub.universe_domain
167
+ end
168
+ end
169
+
170
+ ##
171
+ # Get the associated client for mix-in of the Locations.
172
+ #
173
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
174
+ #
175
+ attr_reader :location_client
176
+
177
+ # Service calls
178
+
179
+ ##
180
+ # Performs a grounding check.
181
+ #
182
+ # @overload check_grounding(request, options = nil)
183
+ # Pass arguments to `check_grounding` via a request object, either of type
184
+ # {::Google::Cloud::DiscoveryEngine::V1::CheckGroundingRequest} or an equivalent Hash.
185
+ #
186
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::CheckGroundingRequest, ::Hash]
187
+ # A request object representing the call parameters. Required. To specify no
188
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
189
+ # @param options [::Gapic::CallOptions, ::Hash]
190
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
191
+ #
192
+ # @overload check_grounding(grounding_config: nil, answer_candidate: nil, facts: nil, grounding_spec: nil, user_labels: nil)
193
+ # Pass arguments to `check_grounding` via keyword arguments. Note that at
194
+ # least one keyword argument is required. To specify no parameters, or to keep all
195
+ # the default parameter values, pass an empty Hash as a request object (see above).
196
+ #
197
+ # @param grounding_config [::String]
198
+ # Required. The resource name of the grounding config, such as
199
+ # `projects/*/locations/global/groundingConfigs/default_grounding_config`.
200
+ # @param answer_candidate [::String]
201
+ # Answer candidate to check. Can have a maximum length of 1024 characters.
202
+ # @param facts [::Array<::Google::Cloud::DiscoveryEngine::V1::GroundingFact, ::Hash>]
203
+ # List of facts for the grounding check.
204
+ # We support up to 200 facts.
205
+ # @param grounding_spec [::Google::Cloud::DiscoveryEngine::V1::CheckGroundingSpec, ::Hash]
206
+ # Configuration of the grounding check.
207
+ # @param user_labels [::Hash{::String => ::String}]
208
+ # The user labels applied to a resource must meet the following requirements:
209
+ #
210
+ # * Each resource can have multiple labels, up to a maximum of 64.
211
+ # * Each label must be a key-value pair.
212
+ # * Keys have a minimum length of 1 character and a maximum length of 63
213
+ # characters and cannot be empty. Values can be empty and have a maximum
214
+ # length of 63 characters.
215
+ # * Keys and values can contain only lowercase letters, numeric characters,
216
+ # underscores, and dashes. All characters must use UTF-8 encoding, and
217
+ # international characters are allowed.
218
+ # * The key portion of a label must be unique. However, you can use the same
219
+ # key with multiple resources.
220
+ # * Keys must start with a lowercase letter or international character.
221
+ #
222
+ # See [Google Cloud
223
+ # Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
224
+ # for more details.
225
+ # @yield [result, operation] Access the result along with the TransportOperation object
226
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1::CheckGroundingResponse]
227
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
228
+ #
229
+ # @return [::Google::Cloud::DiscoveryEngine::V1::CheckGroundingResponse]
230
+ #
231
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
232
+ #
233
+ # @example Basic example
234
+ # require "google/cloud/discovery_engine/v1"
235
+ #
236
+ # # Create a client object. The client can be reused for multiple calls.
237
+ # client = Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client.new
238
+ #
239
+ # # Create a request. To set request fields, pass in keyword arguments.
240
+ # request = Google::Cloud::DiscoveryEngine::V1::CheckGroundingRequest.new
241
+ #
242
+ # # Call the check_grounding method.
243
+ # result = client.check_grounding request
244
+ #
245
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::CheckGroundingResponse.
246
+ # p result
247
+ #
248
+ def check_grounding request, options = nil
249
+ raise ::ArgumentError, "request must be provided" if request.nil?
250
+
251
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::CheckGroundingRequest
252
+
253
+ # Converts hash and nil to an options object
254
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
255
+
256
+ # Customize the options with defaults
257
+ call_metadata = @config.rpcs.check_grounding.metadata.to_h
258
+
259
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
260
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
261
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
262
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION,
263
+ transports_version_send: [:rest]
264
+
265
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
266
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
267
+
268
+ options.apply_defaults timeout: @config.rpcs.check_grounding.timeout,
269
+ metadata: call_metadata,
270
+ retry_policy: @config.rpcs.check_grounding.retry_policy
271
+
272
+ options.apply_defaults timeout: @config.timeout,
273
+ metadata: @config.metadata,
274
+ retry_policy: @config.retry_policy
275
+
276
+ @grounded_generation_service_stub.check_grounding request, options do |result, operation|
277
+ yield result, operation if block_given?
278
+ return result
279
+ end
280
+ rescue ::Gapic::Rest::Error => e
281
+ raise ::Google::Cloud::Error.from_error(e)
282
+ end
283
+
284
+ ##
285
+ # Configuration class for the GroundedGenerationService REST API.
286
+ #
287
+ # This class represents the configuration for GroundedGenerationService REST,
288
+ # providing control over timeouts, retry behavior, logging, transport
289
+ # parameters, and other low-level controls. Certain parameters can also be
290
+ # applied individually to specific RPCs. See
291
+ # {::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client::Configuration::Rpcs}
292
+ # for a list of RPCs that can be configured independently.
293
+ #
294
+ # Configuration can be applied globally to all clients, or to a single client
295
+ # on construction.
296
+ #
297
+ # @example
298
+ #
299
+ # # Modify the global config, setting the timeout for
300
+ # # check_grounding to 20 seconds,
301
+ # # and all remaining timeouts to 10 seconds.
302
+ # ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client.configure do |config|
303
+ # config.timeout = 10.0
304
+ # config.rpcs.check_grounding.timeout = 20.0
305
+ # end
306
+ #
307
+ # # Apply the above configuration only to a new client.
308
+ # client = ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client.new do |config|
309
+ # config.timeout = 10.0
310
+ # config.rpcs.check_grounding.timeout = 20.0
311
+ # end
312
+ #
313
+ # @!attribute [rw] endpoint
314
+ # A custom service endpoint, as a hostname or hostname:port. The default is
315
+ # nil, indicating to use the default endpoint in the current universe domain.
316
+ # @return [::String,nil]
317
+ # @!attribute [rw] credentials
318
+ # Credentials to send with calls. You may provide any of the following types:
319
+ # * (`String`) The path to a service account key file in JSON format
320
+ # * (`Hash`) A service account key as a Hash
321
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
322
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
323
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
324
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
325
+ # * (`nil`) indicating no credentials
326
+ # @return [::Object]
327
+ # @!attribute [rw] scope
328
+ # The OAuth scopes
329
+ # @return [::Array<::String>]
330
+ # @!attribute [rw] lib_name
331
+ # The library name as recorded in instrumentation and logging
332
+ # @return [::String]
333
+ # @!attribute [rw] lib_version
334
+ # The library version as recorded in instrumentation and logging
335
+ # @return [::String]
336
+ # @!attribute [rw] timeout
337
+ # The call timeout in seconds.
338
+ # @return [::Numeric]
339
+ # @!attribute [rw] metadata
340
+ # Additional headers to be sent with the call.
341
+ # @return [::Hash{::Symbol=>::String}]
342
+ # @!attribute [rw] retry_policy
343
+ # The retry policy. The value is a hash with the following keys:
344
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
345
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
346
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
347
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
348
+ # trigger a retry.
349
+ # @return [::Hash]
350
+ # @!attribute [rw] quota_project
351
+ # A separate project against which to charge quota.
352
+ # @return [::String]
353
+ # @!attribute [rw] universe_domain
354
+ # The universe domain within which to make requests. This determines the
355
+ # default endpoint URL. The default value of nil uses the environment
356
+ # universe (usually the default "googleapis.com" universe).
357
+ # @return [::String,nil]
358
+ #
359
+ class Configuration
360
+ extend ::Gapic::Config
361
+
362
+ # @private
363
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
364
+ DEFAULT_ENDPOINT = "discoveryengine.googleapis.com"
365
+
366
+ config_attr :endpoint, nil, ::String, nil
367
+ config_attr :credentials, nil do |value|
368
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
369
+ allowed.any? { |klass| klass === value }
370
+ end
371
+ config_attr :scope, nil, ::String, ::Array, nil
372
+ config_attr :lib_name, nil, ::String, nil
373
+ config_attr :lib_version, nil, ::String, nil
374
+ config_attr :timeout, nil, ::Numeric, nil
375
+ config_attr :metadata, nil, ::Hash, nil
376
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
377
+ config_attr :quota_project, nil, ::String, nil
378
+ config_attr :universe_domain, nil, ::String, nil
379
+
380
+ # @private
381
+ def initialize parent_config = nil
382
+ @parent_config = parent_config unless parent_config.nil?
383
+
384
+ yield self if block_given?
385
+ end
386
+
387
+ ##
388
+ # Configurations for individual RPCs
389
+ # @return [Rpcs]
390
+ #
391
+ def rpcs
392
+ @rpcs ||= begin
393
+ parent_rpcs = nil
394
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
395
+ Rpcs.new parent_rpcs
396
+ end
397
+ end
398
+
399
+ ##
400
+ # Configuration RPC class for the GroundedGenerationService API.
401
+ #
402
+ # Includes fields providing the configuration for each RPC in this service.
403
+ # Each configuration object is of type `Gapic::Config::Method` and includes
404
+ # the following configuration fields:
405
+ #
406
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
407
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
408
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
409
+ # include the following keys:
410
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
411
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
412
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
413
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
414
+ # trigger a retry.
415
+ #
416
+ class Rpcs
417
+ ##
418
+ # RPC-specific configuration for `check_grounding`
419
+ # @return [::Gapic::Config::Method]
420
+ #
421
+ attr_reader :check_grounding
422
+
423
+ # @private
424
+ def initialize parent_rpcs = nil
425
+ check_grounding_config = parent_rpcs.check_grounding if parent_rpcs.respond_to? :check_grounding
426
+ @check_grounding = ::Gapic::Config::Method.new check_grounding_config
427
+
428
+ yield self if block_given?
429
+ end
430
+ end
431
+ end
432
+ end
433
+ end
434
+ end
435
+ end
436
+ end
437
+ end
438
+ end
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2024 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/discoveryengine/v1/grounded_generation_service_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module DiscoveryEngine
24
+ module V1
25
+ module GroundedGenerationService
26
+ module Rest
27
+ ##
28
+ # REST service stub for the GroundedGenerationService service.
29
+ # Service stub contains baseline method implementations
30
+ # including transcoding, making the REST call, and deserialing the response.
31
+ #
32
+ class ServiceStub
33
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:
34
+ # These require statements are intentionally placed here to initialize
35
+ # the REST modules only when it's required.
36
+ require "gapic/rest"
37
+
38
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint,
39
+ endpoint_template: endpoint_template,
40
+ universe_domain: universe_domain,
41
+ credentials: credentials,
42
+ numeric_enums: true,
43
+ raise_faraday_errors: false
44
+ end
45
+
46
+ ##
47
+ # The effective universe domain
48
+ #
49
+ # @return [String]
50
+ #
51
+ def universe_domain
52
+ @client_stub.universe_domain
53
+ end
54
+
55
+ ##
56
+ # The effective endpoint
57
+ #
58
+ # @return [String]
59
+ #
60
+ def endpoint
61
+ @client_stub.endpoint
62
+ end
63
+
64
+ ##
65
+ # Baseline implementation for the check_grounding REST call
66
+ #
67
+ # @param request_pb [::Google::Cloud::DiscoveryEngine::V1::CheckGroundingRequest]
68
+ # A request object representing the call parameters. Required.
69
+ # @param options [::Gapic::CallOptions]
70
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
71
+ #
72
+ # @yield [result, operation] Access the result along with the TransportOperation object
73
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1::CheckGroundingResponse]
74
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
75
+ #
76
+ # @return [::Google::Cloud::DiscoveryEngine::V1::CheckGroundingResponse]
77
+ # A result object deserialized from the server's reply
78
+ def check_grounding request_pb, options = nil
79
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
80
+
81
+ verb, uri, query_string_params, body = ServiceStub.transcode_check_grounding_request request_pb
82
+ query_string_params = if query_string_params.any?
83
+ query_string_params.to_h { |p| p.split "=", 2 }
84
+ else
85
+ {}
86
+ end
87
+
88
+ response = @client_stub.make_http_request(
89
+ verb,
90
+ uri: uri,
91
+ body: body || "",
92
+ params: query_string_params,
93
+ options: options
94
+ )
95
+ operation = ::Gapic::Rest::TransportOperation.new response
96
+ result = ::Google::Cloud::DiscoveryEngine::V1::CheckGroundingResponse.decode_json response.body, ignore_unknown_fields: true
97
+
98
+ yield result, operation if block_given?
99
+ result
100
+ end
101
+
102
+ ##
103
+ # @private
104
+ #
105
+ # GRPC transcoding helper method for the check_grounding REST call
106
+ #
107
+ # @param request_pb [::Google::Cloud::DiscoveryEngine::V1::CheckGroundingRequest]
108
+ # A request object representing the call parameters. Required.
109
+ # @return [Array(String, [String, nil], Hash{String => String})]
110
+ # Uri, Body, Query string parameters
111
+ def self.transcode_check_grounding_request request_pb
112
+ transcoder = Gapic::Rest::GrpcTranscoder.new
113
+ .with_bindings(
114
+ uri_method: :post,
115
+ uri_template: "/v1/{grounding_config}:check",
116
+ body: "*",
117
+ matches: [
118
+ ["grounding_config", %r{^projects/[^/]+/locations/[^/]+/groundingConfigs/[^/]+/?$}, false]
119
+ ]
120
+ )
121
+ transcoder.transcode request_pb
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2024 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 "gapic/rest"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/discovery_engine/v1/version"
24
+
25
+ require "google/cloud/discovery_engine/v1/grounded_generation_service/credentials"
26
+ require "google/cloud/discovery_engine/v1/grounded_generation_service/paths"
27
+ require "google/cloud/discovery_engine/v1/grounded_generation_service/rest/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module DiscoveryEngine
32
+ module V1
33
+ ##
34
+ # Service for grounded generation.
35
+ #
36
+ # To load this service and instantiate a REST client:
37
+ #
38
+ # require "google/cloud/discovery_engine/v1/grounded_generation_service/rest"
39
+ # client = ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client.new
40
+ #
41
+ module GroundedGenerationService
42
+ # Client for the REST transport
43
+ module Rest
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ helper_path = ::File.join __dir__, "rest", "helpers.rb"
52
+ require "google/cloud/discovery_engine/v1/grounded_generation_service/rest/helpers" if ::File.file? helper_path
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2024 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 "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/discovery_engine/v1/version"
24
+
25
+ require "google/cloud/discovery_engine/v1/grounded_generation_service/credentials"
26
+ require "google/cloud/discovery_engine/v1/grounded_generation_service/paths"
27
+ require "google/cloud/discovery_engine/v1/grounded_generation_service/client"
28
+ require "google/cloud/discovery_engine/v1/grounded_generation_service/rest"
29
+
30
+ module Google
31
+ module Cloud
32
+ module DiscoveryEngine
33
+ module V1
34
+ ##
35
+ # Service for grounded generation.
36
+ #
37
+ # @example Load this service and instantiate a gRPC client
38
+ #
39
+ # require "google/cloud/discovery_engine/v1/grounded_generation_service"
40
+ # client = ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Client.new
41
+ #
42
+ # @example Load this service and instantiate a REST client
43
+ #
44
+ # require "google/cloud/discovery_engine/v1/grounded_generation_service/rest"
45
+ # client = ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client.new
46
+ #
47
+ module GroundedGenerationService
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ helper_path = ::File.join __dir__, "grounded_generation_service", "helpers.rb"
55
+ require "google/cloud/discovery_engine/v1/grounded_generation_service/helpers" if ::File.file? helper_path