google-cloud-ai_platform-v1 1.20.0 → 1.21.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.
@@ -0,0 +1,50 @@
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 AIPlatform
23
+ module V1
24
+ module DataFoundryService
25
+ # Path helper methods for the DataFoundryService API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified Location resource string.
29
+ #
30
+ # The resource will be in the following format:
31
+ #
32
+ # `projects/{project}/locations/{location}`
33
+ #
34
+ # @param project [String]
35
+ # @param location [String]
36
+ #
37
+ # @return [::String]
38
+ def location_path project:, location:
39
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
40
+
41
+ "projects/#{project}/locations/#{location}"
42
+ end
43
+
44
+ extend self
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,476 @@
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/aiplatform/v1/data_foundry_service_pb"
21
+ require "google/cloud/ai_platform/v1/data_foundry_service/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+ require "google/iam/v1/rest"
24
+
25
+ module Google
26
+ module Cloud
27
+ module AIPlatform
28
+ module V1
29
+ module DataFoundryService
30
+ module Rest
31
+ ##
32
+ # REST client for the DataFoundryService service.
33
+ #
34
+ # Service for generating and preparing datasets for Gen AI evaluation.
35
+ #
36
+ class Client
37
+ # @private
38
+ API_VERSION = ""
39
+
40
+ # @private
41
+ DEFAULT_ENDPOINT_TEMPLATE = "aiplatform.$UNIVERSE_DOMAIN$"
42
+
43
+ include Paths
44
+
45
+ # @private
46
+ attr_reader :data_foundry_service_stub
47
+
48
+ ##
49
+ # Configure the DataFoundryService Client class.
50
+ #
51
+ # See {::Google::Cloud::AIPlatform::V1::DataFoundryService::Rest::Client::Configuration}
52
+ # for a description of the configuration fields.
53
+ #
54
+ # @example
55
+ #
56
+ # # Modify the configuration for all DataFoundryService clients
57
+ # ::Google::Cloud::AIPlatform::V1::DataFoundryService::Rest::Client.configure do |config|
58
+ # config.timeout = 10.0
59
+ # end
60
+ #
61
+ # @yield [config] Configure the Client client.
62
+ # @yieldparam config [Client::Configuration]
63
+ #
64
+ # @return [Client::Configuration]
65
+ #
66
+ def self.configure
67
+ @configure ||= begin
68
+ namespace = ["Google", "Cloud", "AIPlatform", "V1"]
69
+ parent_config = while namespace.any?
70
+ parent_name = namespace.join "::"
71
+ parent_const = const_get parent_name
72
+ break parent_const.configure if parent_const.respond_to? :configure
73
+ namespace.pop
74
+ end
75
+ default_config = Client::Configuration.new parent_config
76
+
77
+ default_config
78
+ end
79
+ yield @configure if block_given?
80
+ @configure
81
+ end
82
+
83
+ ##
84
+ # Configure the DataFoundryService Client instance.
85
+ #
86
+ # The configuration is set to the derived mode, meaning that values can be changed,
87
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
88
+ # should be made on {Client.configure}.
89
+ #
90
+ # See {::Google::Cloud::AIPlatform::V1::DataFoundryService::Rest::Client::Configuration}
91
+ # for a description of the configuration fields.
92
+ #
93
+ # @yield [config] Configure the Client client.
94
+ # @yieldparam config [Client::Configuration]
95
+ #
96
+ # @return [Client::Configuration]
97
+ #
98
+ def configure
99
+ yield @config if block_given?
100
+ @config
101
+ end
102
+
103
+ ##
104
+ # The effective universe domain
105
+ #
106
+ # @return [String]
107
+ #
108
+ def universe_domain
109
+ @data_foundry_service_stub.universe_domain
110
+ end
111
+
112
+ ##
113
+ # Create a new DataFoundryService REST client object.
114
+ #
115
+ # @example
116
+ #
117
+ # # Create a client using the default configuration
118
+ # client = ::Google::Cloud::AIPlatform::V1::DataFoundryService::Rest::Client.new
119
+ #
120
+ # # Create a client using a custom configuration
121
+ # client = ::Google::Cloud::AIPlatform::V1::DataFoundryService::Rest::Client.new do |config|
122
+ # config.timeout = 10.0
123
+ # end
124
+ #
125
+ # @yield [config] Configure the DataFoundryService client.
126
+ # @yieldparam config [Client::Configuration]
127
+ #
128
+ def initialize
129
+ # Create the configuration object
130
+ @config = Configuration.new Client.configure
131
+
132
+ # Yield the configuration if needed
133
+ yield @config if block_given?
134
+
135
+ # Create credentials
136
+ credentials = @config.credentials
137
+ # Use self-signed JWT if the endpoint is unchanged from default,
138
+ # but only if the default endpoint does not have a region prefix.
139
+ enable_self_signed_jwt = @config.endpoint.nil? ||
140
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
141
+ !@config.endpoint.split(".").first.include?("-"))
142
+ credentials ||= Credentials.default scope: @config.scope,
143
+ enable_self_signed_jwt: enable_self_signed_jwt
144
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
145
+ credentials = Credentials.new credentials, scope: @config.scope
146
+ end
147
+
148
+ @quota_project_id = @config.quota_project
149
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
150
+
151
+ @data_foundry_service_stub = ::Google::Cloud::AIPlatform::V1::DataFoundryService::Rest::ServiceStub.new(
152
+ endpoint: @config.endpoint,
153
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
154
+ universe_domain: @config.universe_domain,
155
+ credentials: credentials,
156
+ logger: @config.logger
157
+ )
158
+
159
+ @data_foundry_service_stub.logger(stub: true)&.info do |entry|
160
+ entry.set_system_name
161
+ entry.set_service
162
+ entry.message = "Created client for #{entry.service}"
163
+ entry.set_credentials_fields credentials
164
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
165
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
166
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
167
+ end
168
+
169
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
170
+ config.credentials = credentials
171
+ config.quota_project = @quota_project_id
172
+ config.endpoint = @data_foundry_service_stub.endpoint
173
+ config.universe_domain = @data_foundry_service_stub.universe_domain
174
+ config.bindings_override = @config.bindings_override
175
+ config.logger = @data_foundry_service_stub.logger if config.respond_to? :logger=
176
+ end
177
+
178
+ @iam_policy_client = Google::Iam::V1::IAMPolicy::Rest::Client.new do |config|
179
+ config.credentials = credentials
180
+ config.quota_project = @quota_project_id
181
+ config.endpoint = @data_foundry_service_stub.endpoint
182
+ config.universe_domain = @data_foundry_service_stub.universe_domain
183
+ config.bindings_override = @config.bindings_override
184
+ config.logger = @data_foundry_service_stub.logger if config.respond_to? :logger=
185
+ end
186
+ end
187
+
188
+ ##
189
+ # Get the associated client for mix-in of the Locations.
190
+ #
191
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
192
+ #
193
+ attr_reader :location_client
194
+
195
+ ##
196
+ # Get the associated client for mix-in of the IAMPolicy.
197
+ #
198
+ # @return [Google::Iam::V1::IAMPolicy::Rest::Client]
199
+ #
200
+ attr_reader :iam_policy_client
201
+
202
+ ##
203
+ # The logger used for request/response debug logging.
204
+ #
205
+ # @return [Logger]
206
+ #
207
+ def logger
208
+ @data_foundry_service_stub.logger
209
+ end
210
+
211
+ # Service calls
212
+
213
+ ##
214
+ # Generates synthetic data based on the provided configuration.
215
+ #
216
+ # @overload generate_synthetic_data(request, options = nil)
217
+ # Pass arguments to `generate_synthetic_data` via a request object, either of type
218
+ # {::Google::Cloud::AIPlatform::V1::GenerateSyntheticDataRequest} or an equivalent Hash.
219
+ #
220
+ # @param request [::Google::Cloud::AIPlatform::V1::GenerateSyntheticDataRequest, ::Hash]
221
+ # A request object representing the call parameters. Required. To specify no
222
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
223
+ # @param options [::Gapic::CallOptions, ::Hash]
224
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
225
+ #
226
+ # @overload generate_synthetic_data(task_description: nil, location: nil, count: nil, output_field_specs: nil, examples: nil)
227
+ # Pass arguments to `generate_synthetic_data` via keyword arguments. Note that at
228
+ # least one keyword argument is required. To specify no parameters, or to keep all
229
+ # the default parameter values, pass an empty Hash as a request object (see above).
230
+ #
231
+ # @param task_description [::Google::Cloud::AIPlatform::V1::TaskDescriptionStrategy, ::Hash]
232
+ # Generate data from a high-level task description.
233
+ # @param location [::String]
234
+ # Required. The resource name of the Location to run the job.
235
+ # Format: `projects/{project}/locations/{location}`
236
+ # @param count [::Integer]
237
+ # Required. The number of synthetic examples to generate.
238
+ # For this stateless API, the count is limited to a small number.
239
+ # @param output_field_specs [::Array<::Google::Cloud::AIPlatform::V1::OutputFieldSpec, ::Hash>]
240
+ # Required. The schema of the desired output, defined by a list of fields.
241
+ # @param examples [::Array<::Google::Cloud::AIPlatform::V1::SyntheticExample, ::Hash>]
242
+ # Optional. A list of few-shot examples to guide the model's output style
243
+ # and format.
244
+ # @yield [result, operation] Access the result along with the TransportOperation object
245
+ # @yieldparam result [::Google::Cloud::AIPlatform::V1::GenerateSyntheticDataResponse]
246
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
247
+ #
248
+ # @return [::Google::Cloud::AIPlatform::V1::GenerateSyntheticDataResponse]
249
+ #
250
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
251
+ #
252
+ # @example Basic example
253
+ # require "google/cloud/ai_platform/v1"
254
+ #
255
+ # # Create a client object. The client can be reused for multiple calls.
256
+ # client = Google::Cloud::AIPlatform::V1::DataFoundryService::Rest::Client.new
257
+ #
258
+ # # Create a request. To set request fields, pass in keyword arguments.
259
+ # request = Google::Cloud::AIPlatform::V1::GenerateSyntheticDataRequest.new
260
+ #
261
+ # # Call the generate_synthetic_data method.
262
+ # result = client.generate_synthetic_data request
263
+ #
264
+ # # The returned object is of type Google::Cloud::AIPlatform::V1::GenerateSyntheticDataResponse.
265
+ # p result
266
+ #
267
+ def generate_synthetic_data request, options = nil
268
+ raise ::ArgumentError, "request must be provided" if request.nil?
269
+
270
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::GenerateSyntheticDataRequest
271
+
272
+ # Converts hash and nil to an options object
273
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
274
+
275
+ # Customize the options with defaults
276
+ call_metadata = @config.rpcs.generate_synthetic_data.metadata.to_h
277
+
278
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
279
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
280
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
281
+ gapic_version: ::Google::Cloud::AIPlatform::V1::VERSION,
282
+ transports_version_send: [:rest]
283
+
284
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
285
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
286
+
287
+ options.apply_defaults timeout: @config.rpcs.generate_synthetic_data.timeout,
288
+ metadata: call_metadata,
289
+ retry_policy: @config.rpcs.generate_synthetic_data.retry_policy
290
+
291
+ options.apply_defaults timeout: @config.timeout,
292
+ metadata: @config.metadata,
293
+ retry_policy: @config.retry_policy
294
+
295
+ @data_foundry_service_stub.generate_synthetic_data request, options do |result, operation|
296
+ yield result, operation if block_given?
297
+ end
298
+ rescue ::Gapic::Rest::Error => e
299
+ raise ::Google::Cloud::Error.from_error(e)
300
+ end
301
+
302
+ ##
303
+ # Configuration class for the DataFoundryService REST API.
304
+ #
305
+ # This class represents the configuration for DataFoundryService REST,
306
+ # providing control over timeouts, retry behavior, logging, transport
307
+ # parameters, and other low-level controls. Certain parameters can also be
308
+ # applied individually to specific RPCs. See
309
+ # {::Google::Cloud::AIPlatform::V1::DataFoundryService::Rest::Client::Configuration::Rpcs}
310
+ # for a list of RPCs that can be configured independently.
311
+ #
312
+ # Configuration can be applied globally to all clients, or to a single client
313
+ # on construction.
314
+ #
315
+ # @example
316
+ #
317
+ # # Modify the global config, setting the timeout for
318
+ # # generate_synthetic_data to 20 seconds,
319
+ # # and all remaining timeouts to 10 seconds.
320
+ # ::Google::Cloud::AIPlatform::V1::DataFoundryService::Rest::Client.configure do |config|
321
+ # config.timeout = 10.0
322
+ # config.rpcs.generate_synthetic_data.timeout = 20.0
323
+ # end
324
+ #
325
+ # # Apply the above configuration only to a new client.
326
+ # client = ::Google::Cloud::AIPlatform::V1::DataFoundryService::Rest::Client.new do |config|
327
+ # config.timeout = 10.0
328
+ # config.rpcs.generate_synthetic_data.timeout = 20.0
329
+ # end
330
+ #
331
+ # @!attribute [rw] endpoint
332
+ # A custom service endpoint, as a hostname or hostname:port. The default is
333
+ # nil, indicating to use the default endpoint in the current universe domain.
334
+ # @return [::String,nil]
335
+ # @!attribute [rw] credentials
336
+ # Credentials to send with calls. You may provide any of the following types:
337
+ # * (`String`) The path to a service account key file in JSON format
338
+ # * (`Hash`) A service account key as a Hash
339
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
340
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
341
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
342
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
343
+ # * (`nil`) indicating no credentials
344
+ #
345
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
346
+ # external source for authentication to Google Cloud, you must validate it before
347
+ # providing it to a Google API client library. Providing an unvalidated credential
348
+ # configuration to Google APIs can compromise the security of your systems and data.
349
+ # For more information, refer to [Validate credential configurations from external
350
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
351
+ # @return [::Object]
352
+ # @!attribute [rw] scope
353
+ # The OAuth scopes
354
+ # @return [::Array<::String>]
355
+ # @!attribute [rw] lib_name
356
+ # The library name as recorded in instrumentation and logging
357
+ # @return [::String]
358
+ # @!attribute [rw] lib_version
359
+ # The library version as recorded in instrumentation and logging
360
+ # @return [::String]
361
+ # @!attribute [rw] timeout
362
+ # The call timeout in seconds.
363
+ # @return [::Numeric]
364
+ # @!attribute [rw] metadata
365
+ # Additional headers to be sent with the call.
366
+ # @return [::Hash{::Symbol=>::String}]
367
+ # @!attribute [rw] retry_policy
368
+ # The retry policy. The value is a hash with the following keys:
369
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
370
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
371
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
372
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
373
+ # trigger a retry.
374
+ # @return [::Hash]
375
+ # @!attribute [rw] quota_project
376
+ # A separate project against which to charge quota.
377
+ # @return [::String]
378
+ # @!attribute [rw] universe_domain
379
+ # The universe domain within which to make requests. This determines the
380
+ # default endpoint URL. The default value of nil uses the environment
381
+ # universe (usually the default "googleapis.com" universe).
382
+ # @return [::String,nil]
383
+ # @!attribute [rw] logger
384
+ # A custom logger to use for request/response debug logging, or the value
385
+ # `:default` (the default) to construct a default logger, or `nil` to
386
+ # explicitly disable logging.
387
+ # @return [::Logger,:default,nil]
388
+ #
389
+ class Configuration
390
+ extend ::Gapic::Config
391
+
392
+ # @private
393
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
394
+ DEFAULT_ENDPOINT = "aiplatform.googleapis.com"
395
+
396
+ config_attr :endpoint, nil, ::String, nil
397
+ config_attr :credentials, nil do |value|
398
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
399
+ allowed.any? { |klass| klass === value }
400
+ end
401
+ config_attr :scope, nil, ::String, ::Array, nil
402
+ config_attr :lib_name, nil, ::String, nil
403
+ config_attr :lib_version, nil, ::String, nil
404
+ config_attr :timeout, nil, ::Numeric, nil
405
+ config_attr :metadata, nil, ::Hash, nil
406
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
407
+ config_attr :quota_project, nil, ::String, nil
408
+ config_attr :universe_domain, nil, ::String, nil
409
+
410
+ # @private
411
+ # Overrides for http bindings for the RPCs of this service
412
+ # are only used when this service is used as mixin, and only
413
+ # by the host service.
414
+ # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
415
+ config_attr :bindings_override, {}, ::Hash, nil
416
+ config_attr :logger, :default, ::Logger, nil, :default
417
+
418
+ # @private
419
+ def initialize parent_config = nil
420
+ @parent_config = parent_config unless parent_config.nil?
421
+
422
+ yield self if block_given?
423
+ end
424
+
425
+ ##
426
+ # Configurations for individual RPCs
427
+ # @return [Rpcs]
428
+ #
429
+ def rpcs
430
+ @rpcs ||= begin
431
+ parent_rpcs = nil
432
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
433
+ Rpcs.new parent_rpcs
434
+ end
435
+ end
436
+
437
+ ##
438
+ # Configuration RPC class for the DataFoundryService API.
439
+ #
440
+ # Includes fields providing the configuration for each RPC in this service.
441
+ # Each configuration object is of type `Gapic::Config::Method` and includes
442
+ # the following configuration fields:
443
+ #
444
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
445
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
446
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
447
+ # include the following keys:
448
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
449
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
450
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
451
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
452
+ # trigger a retry.
453
+ #
454
+ class Rpcs
455
+ ##
456
+ # RPC-specific configuration for `generate_synthetic_data`
457
+ # @return [::Gapic::Config::Method]
458
+ #
459
+ attr_reader :generate_synthetic_data
460
+
461
+ # @private
462
+ def initialize parent_rpcs = nil
463
+ generate_synthetic_data_config = parent_rpcs.generate_synthetic_data if parent_rpcs.respond_to? :generate_synthetic_data
464
+ @generate_synthetic_data = ::Gapic::Config::Method.new generate_synthetic_data_config
465
+
466
+ yield self if block_given?
467
+ end
468
+ end
469
+ end
470
+ end
471
+ end
472
+ end
473
+ end
474
+ end
475
+ end
476
+ end
@@ -0,0 +1,143 @@
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/aiplatform/v1/data_foundry_service_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module AIPlatform
24
+ module V1
25
+ module DataFoundryService
26
+ module Rest
27
+ ##
28
+ # REST service stub for the DataFoundryService service.
29
+ # Service stub contains baseline method implementations
30
+ # including transcoding, making the REST call, and deserialing the response.
31
+ #
32
+ class ServiceStub
33
+ # @private
34
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:, logger:
35
+ # These require statements are intentionally placed here to initialize
36
+ # the REST modules only when it's required.
37
+ require "gapic/rest"
38
+
39
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint,
40
+ endpoint_template: endpoint_template,
41
+ universe_domain: universe_domain,
42
+ credentials: credentials,
43
+ numeric_enums: true,
44
+ service_name: self.class,
45
+ raise_faraday_errors: false,
46
+ logger: logger
47
+ end
48
+
49
+ ##
50
+ # The effective universe domain
51
+ #
52
+ # @return [String]
53
+ #
54
+ def universe_domain
55
+ @client_stub.universe_domain
56
+ end
57
+
58
+ ##
59
+ # The effective endpoint
60
+ #
61
+ # @return [String]
62
+ #
63
+ def endpoint
64
+ @client_stub.endpoint
65
+ end
66
+
67
+ ##
68
+ # The logger used for request/response debug logging.
69
+ #
70
+ # @return [Logger]
71
+ #
72
+ def logger stub: false
73
+ stub ? @client_stub.stub_logger : @client_stub.logger
74
+ end
75
+
76
+ ##
77
+ # Baseline implementation for the generate_synthetic_data REST call
78
+ #
79
+ # @param request_pb [::Google::Cloud::AIPlatform::V1::GenerateSyntheticDataRequest]
80
+ # A request object representing the call parameters. Required.
81
+ # @param options [::Gapic::CallOptions]
82
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
83
+ #
84
+ # @yield [result, operation] Access the result along with the TransportOperation object
85
+ # @yieldparam result [::Google::Cloud::AIPlatform::V1::GenerateSyntheticDataResponse]
86
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
87
+ #
88
+ # @return [::Google::Cloud::AIPlatform::V1::GenerateSyntheticDataResponse]
89
+ # A result object deserialized from the server's reply
90
+ def generate_synthetic_data request_pb, options = nil
91
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
92
+
93
+ verb, uri, query_string_params, body = ServiceStub.transcode_generate_synthetic_data_request request_pb
94
+ query_string_params = if query_string_params.any?
95
+ query_string_params.to_h { |p| p.split "=", 2 }
96
+ else
97
+ {}
98
+ end
99
+
100
+ response = @client_stub.make_http_request(
101
+ verb,
102
+ uri: uri,
103
+ body: body || "",
104
+ params: query_string_params,
105
+ method_name: "generate_synthetic_data",
106
+ options: options
107
+ )
108
+ operation = ::Gapic::Rest::TransportOperation.new response
109
+ result = ::Google::Cloud::AIPlatform::V1::GenerateSyntheticDataResponse.decode_json response.body, ignore_unknown_fields: true
110
+ catch :response do
111
+ yield result, operation if block_given?
112
+ result
113
+ end
114
+ end
115
+
116
+ ##
117
+ # @private
118
+ #
119
+ # GRPC transcoding helper method for the generate_synthetic_data REST call
120
+ #
121
+ # @param request_pb [::Google::Cloud::AIPlatform::V1::GenerateSyntheticDataRequest]
122
+ # A request object representing the call parameters. Required.
123
+ # @return [Array(String, [String, nil], Hash{String => String})]
124
+ # Uri, Body, Query string parameters
125
+ def self.transcode_generate_synthetic_data_request request_pb
126
+ transcoder = Gapic::Rest::GrpcTranscoder.new
127
+ .with_bindings(
128
+ uri_method: :post,
129
+ uri_template: "/v1/{location}:generateSyntheticData",
130
+ body: "*",
131
+ matches: [
132
+ ["location", %r{^projects/[^/]+/locations/[^/]+/?$}, false]
133
+ ]
134
+ )
135
+ transcoder.transcode request_pb
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end