google-cloud-life_sciences-v2beta 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,411 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/lifesciences/v2beta/workflows_pb"
21
+ require "google/cloud/life_sciences/v2beta/workflows_service/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+
24
+ module Google
25
+ module Cloud
26
+ module LifeSciences
27
+ module V2beta
28
+ module WorkflowsService
29
+ module Rest
30
+ ##
31
+ # REST client for the WorkflowsService service.
32
+ #
33
+ # A service for running workflows, such as pipelines consisting of Docker
34
+ # containers.
35
+ #
36
+ class Client
37
+ # @private
38
+ attr_reader :workflows_service_stub
39
+
40
+ ##
41
+ # Configure the WorkflowsService Client class.
42
+ #
43
+ # See {::Google::Cloud::LifeSciences::V2beta::WorkflowsService::Rest::Client::Configuration}
44
+ # for a description of the configuration fields.
45
+ #
46
+ # @example
47
+ #
48
+ # # Modify the configuration for all WorkflowsService clients
49
+ # ::Google::Cloud::LifeSciences::V2beta::WorkflowsService::Rest::Client.configure do |config|
50
+ # config.timeout = 10.0
51
+ # end
52
+ #
53
+ # @yield [config] Configure the Client client.
54
+ # @yieldparam config [Client::Configuration]
55
+ #
56
+ # @return [Client::Configuration]
57
+ #
58
+ def self.configure
59
+ @configure ||= begin
60
+ namespace = ["Google", "Cloud", "LifeSciences", "V2beta"]
61
+ parent_config = while namespace.any?
62
+ parent_name = namespace.join "::"
63
+ parent_const = const_get parent_name
64
+ break parent_const.configure if parent_const.respond_to? :configure
65
+ namespace.pop
66
+ end
67
+ default_config = Client::Configuration.new parent_config
68
+
69
+ default_config.timeout = 60.0
70
+
71
+ default_config
72
+ end
73
+ yield @configure if block_given?
74
+ @configure
75
+ end
76
+
77
+ ##
78
+ # Configure the WorkflowsService Client instance.
79
+ #
80
+ # The configuration is set to the derived mode, meaning that values can be changed,
81
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
82
+ # should be made on {Client.configure}.
83
+ #
84
+ # See {::Google::Cloud::LifeSciences::V2beta::WorkflowsService::Rest::Client::Configuration}
85
+ # for a description of the configuration fields.
86
+ #
87
+ # @yield [config] Configure the Client client.
88
+ # @yieldparam config [Client::Configuration]
89
+ #
90
+ # @return [Client::Configuration]
91
+ #
92
+ def configure
93
+ yield @config if block_given?
94
+ @config
95
+ end
96
+
97
+ ##
98
+ # Create a new WorkflowsService REST client object.
99
+ #
100
+ # @example
101
+ #
102
+ # # Create a client using the default configuration
103
+ # client = ::Google::Cloud::LifeSciences::V2beta::WorkflowsService::Rest::Client.new
104
+ #
105
+ # # Create a client using a custom configuration
106
+ # client = ::Google::Cloud::LifeSciences::V2beta::WorkflowsService::Rest::Client.new do |config|
107
+ # config.timeout = 10.0
108
+ # end
109
+ #
110
+ # @yield [config] Configure the WorkflowsService client.
111
+ # @yieldparam config [Client::Configuration]
112
+ #
113
+ def initialize
114
+ # Create the configuration object
115
+ @config = Configuration.new Client.configure
116
+
117
+ # Yield the configuration if needed
118
+ yield @config if block_given?
119
+
120
+ # Create credentials
121
+ credentials = @config.credentials
122
+ # Use self-signed JWT if the endpoint is unchanged from default,
123
+ # but only if the default endpoint does not have a region prefix.
124
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
125
+ !@config.endpoint.split(".").first.include?("-")
126
+ credentials ||= Credentials.default scope: @config.scope,
127
+ enable_self_signed_jwt: enable_self_signed_jwt
128
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
129
+ credentials = Credentials.new credentials, scope: @config.scope
130
+ end
131
+
132
+ @quota_project_id = @config.quota_project
133
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
134
+
135
+ @operations_client = ::Google::Cloud::LifeSciences::V2beta::WorkflowsService::Rest::Operations.new do |config|
136
+ config.credentials = credentials
137
+ config.quota_project = @quota_project_id
138
+ config.endpoint = @config.endpoint
139
+ end
140
+
141
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
142
+ config.credentials = credentials
143
+ config.quota_project = @quota_project_id
144
+ config.endpoint = @config.endpoint
145
+ config.bindings_override = @config.bindings_override
146
+ end
147
+
148
+ @workflows_service_stub = ::Google::Cloud::LifeSciences::V2beta::WorkflowsService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
149
+ end
150
+
151
+ ##
152
+ # Get the associated client for long-running operations.
153
+ #
154
+ # @return [::Google::Cloud::LifeSciences::V2beta::WorkflowsService::Rest::Operations]
155
+ #
156
+ attr_reader :operations_client
157
+
158
+ ##
159
+ # Get the associated client for mix-in of the Locations.
160
+ #
161
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
162
+ #
163
+ attr_reader :location_client
164
+
165
+ # Service calls
166
+
167
+ ##
168
+ # Runs a pipeline. The returned Operation's [metadata]
169
+ # [google.longrunning.Operation.metadata] field will contain a
170
+ # {::Google::Cloud::LifeSciences::V2beta::Metadata google.cloud.lifesciences.v2beta.Metadata}
171
+ # object describing the status of the pipeline execution. The
172
+ # {::Google::Longrunning::Operation#response response} field will contain a
173
+ # {::Google::Cloud::LifeSciences::V2beta::RunPipelineResponse google.cloud.lifesciences.v2beta.RunPipelineResponse}
174
+ # object if the pipeline completes successfully.
175
+ #
176
+ # **Note:** Before you can use this method, the *Life Sciences Service Agent*
177
+ # must have access to your project. This is done automatically when the
178
+ # Cloud Life Sciences API is first enabled, but if you delete this permission
179
+ # you must disable and re-enable the API to grant the Life Sciences
180
+ # Service Agent the required permissions.
181
+ # Authorization requires the following [Google
182
+ # IAM](https://cloud.google.com/iam/) permission:
183
+ #
184
+ # * `lifesciences.workflows.run`
185
+ #
186
+ # @overload run_pipeline(request, options = nil)
187
+ # Pass arguments to `run_pipeline` via a request object, either of type
188
+ # {::Google::Cloud::LifeSciences::V2beta::RunPipelineRequest} or an equivalent Hash.
189
+ #
190
+ # @param request [::Google::Cloud::LifeSciences::V2beta::RunPipelineRequest, ::Hash]
191
+ # A request object representing the call parameters. Required. To specify no
192
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
193
+ # @param options [::Gapic::CallOptions, ::Hash]
194
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
195
+ #
196
+ # @overload run_pipeline(parent: nil, pipeline: nil, labels: nil, pub_sub_topic: nil)
197
+ # Pass arguments to `run_pipeline` via keyword arguments. Note that at
198
+ # least one keyword argument is required. To specify no parameters, or to keep all
199
+ # the default parameter values, pass an empty Hash as a request object (see above).
200
+ #
201
+ # @param parent [::String]
202
+ # The project and location that this request should be executed against.
203
+ # @param pipeline [::Google::Cloud::LifeSciences::V2beta::Pipeline, ::Hash]
204
+ # Required. The description of the pipeline to run.
205
+ # @param labels [::Hash{::String => ::String}]
206
+ # User-defined labels to associate with the returned operation. These
207
+ # labels are not propagated to any Google Cloud Platform resources used by
208
+ # the operation, and can be modified at any time.
209
+ #
210
+ # To associate labels with resources created while executing the operation,
211
+ # see the appropriate resource message (for example, `VirtualMachine`).
212
+ # @param pub_sub_topic [::String]
213
+ # The name of an existing Pub/Sub topic. The server will publish
214
+ # messages to this topic whenever the status of the operation changes.
215
+ # The Life Sciences Service Agent account must have publisher permissions to
216
+ # the specified topic or notifications will not be sent.
217
+ # @yield [result, operation] Access the result along with the TransportOperation object
218
+ # @yieldparam result [::Gapic::Operation]
219
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
220
+ #
221
+ # @return [::Gapic::Operation]
222
+ #
223
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
224
+ def run_pipeline request, options = nil
225
+ raise ::ArgumentError, "request must be provided" if request.nil?
226
+
227
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::LifeSciences::V2beta::RunPipelineRequest
228
+
229
+ # Converts hash and nil to an options object
230
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
231
+
232
+ # Customize the options with defaults
233
+ call_metadata = @config.rpcs.run_pipeline.metadata.to_h
234
+
235
+ # Set x-goog-api-client and x-goog-user-project headers
236
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
237
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
238
+ gapic_version: ::Google::Cloud::LifeSciences::V2beta::VERSION,
239
+ transports_version_send: [:rest]
240
+
241
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
242
+
243
+ options.apply_defaults timeout: @config.rpcs.run_pipeline.timeout,
244
+ metadata: call_metadata,
245
+ retry_policy: @config.rpcs.run_pipeline.retry_policy
246
+
247
+ options.apply_defaults timeout: @config.timeout,
248
+ metadata: @config.metadata,
249
+ retry_policy: @config.retry_policy
250
+
251
+ @workflows_service_stub.run_pipeline request, options do |result, operation|
252
+ result = ::Gapic::Operation.new result, @operations_client, options: options
253
+ yield result, operation if block_given?
254
+ return result
255
+ end
256
+ rescue ::Gapic::Rest::Error => e
257
+ raise ::Google::Cloud::Error.from_error(e)
258
+ end
259
+
260
+ ##
261
+ # Configuration class for the WorkflowsService REST API.
262
+ #
263
+ # This class represents the configuration for WorkflowsService REST,
264
+ # providing control over timeouts, retry behavior, logging, transport
265
+ # parameters, and other low-level controls. Certain parameters can also be
266
+ # applied individually to specific RPCs. See
267
+ # {::Google::Cloud::LifeSciences::V2beta::WorkflowsService::Rest::Client::Configuration::Rpcs}
268
+ # for a list of RPCs that can be configured independently.
269
+ #
270
+ # Configuration can be applied globally to all clients, or to a single client
271
+ # on construction.
272
+ #
273
+ # @example
274
+ #
275
+ # # Modify the global config, setting the timeout for
276
+ # # run_pipeline to 20 seconds,
277
+ # # and all remaining timeouts to 10 seconds.
278
+ # ::Google::Cloud::LifeSciences::V2beta::WorkflowsService::Rest::Client.configure do |config|
279
+ # config.timeout = 10.0
280
+ # config.rpcs.run_pipeline.timeout = 20.0
281
+ # end
282
+ #
283
+ # # Apply the above configuration only to a new client.
284
+ # client = ::Google::Cloud::LifeSciences::V2beta::WorkflowsService::Rest::Client.new do |config|
285
+ # config.timeout = 10.0
286
+ # config.rpcs.run_pipeline.timeout = 20.0
287
+ # end
288
+ #
289
+ # @!attribute [rw] endpoint
290
+ # The hostname or hostname:port of the service endpoint.
291
+ # Defaults to `"lifesciences.googleapis.com"`.
292
+ # @return [::String]
293
+ # @!attribute [rw] credentials
294
+ # Credentials to send with calls. You may provide any of the following types:
295
+ # * (`String`) The path to a service account key file in JSON format
296
+ # * (`Hash`) A service account key as a Hash
297
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
298
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
299
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
300
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
301
+ # * (`nil`) indicating no credentials
302
+ # @return [::Object]
303
+ # @!attribute [rw] scope
304
+ # The OAuth scopes
305
+ # @return [::Array<::String>]
306
+ # @!attribute [rw] lib_name
307
+ # The library name as recorded in instrumentation and logging
308
+ # @return [::String]
309
+ # @!attribute [rw] lib_version
310
+ # The library version as recorded in instrumentation and logging
311
+ # @return [::String]
312
+ # @!attribute [rw] timeout
313
+ # The call timeout in seconds.
314
+ # @return [::Numeric]
315
+ # @!attribute [rw] metadata
316
+ # Additional headers to be sent with the call.
317
+ # @return [::Hash{::Symbol=>::String}]
318
+ # @!attribute [rw] retry_policy
319
+ # The retry policy. The value is a hash with the following keys:
320
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
321
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
322
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
323
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
324
+ # trigger a retry.
325
+ # @return [::Hash]
326
+ # @!attribute [rw] quota_project
327
+ # A separate project against which to charge quota.
328
+ # @return [::String]
329
+ #
330
+ class Configuration
331
+ extend ::Gapic::Config
332
+
333
+ config_attr :endpoint, "lifesciences.googleapis.com", ::String
334
+ config_attr :credentials, nil do |value|
335
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
336
+ allowed.any? { |klass| klass === value }
337
+ end
338
+ config_attr :scope, nil, ::String, ::Array, nil
339
+ config_attr :lib_name, nil, ::String, nil
340
+ config_attr :lib_version, nil, ::String, nil
341
+ config_attr :timeout, nil, ::Numeric, nil
342
+ config_attr :metadata, nil, ::Hash, nil
343
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
344
+ config_attr :quota_project, nil, ::String, nil
345
+
346
+ # @private
347
+ # Overrides for http bindings for the RPCs of this service
348
+ # are only used when this service is used as mixin, and only
349
+ # by the host service.
350
+ # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
351
+ config_attr :bindings_override, {}, ::Hash, nil
352
+
353
+ # @private
354
+ def initialize parent_config = nil
355
+ @parent_config = parent_config unless parent_config.nil?
356
+
357
+ yield self if block_given?
358
+ end
359
+
360
+ ##
361
+ # Configurations for individual RPCs
362
+ # @return [Rpcs]
363
+ #
364
+ def rpcs
365
+ @rpcs ||= begin
366
+ parent_rpcs = nil
367
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
368
+ Rpcs.new parent_rpcs
369
+ end
370
+ end
371
+
372
+ ##
373
+ # Configuration RPC class for the WorkflowsService API.
374
+ #
375
+ # Includes fields providing the configuration for each RPC in this service.
376
+ # Each configuration object is of type `Gapic::Config::Method` and includes
377
+ # the following configuration fields:
378
+ #
379
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
380
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
381
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
382
+ # include the following keys:
383
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
384
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
385
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
386
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
387
+ # trigger a retry.
388
+ #
389
+ class Rpcs
390
+ ##
391
+ # RPC-specific configuration for `run_pipeline`
392
+ # @return [::Gapic::Config::Method]
393
+ #
394
+ attr_reader :run_pipeline
395
+
396
+ # @private
397
+ def initialize parent_rpcs = nil
398
+ run_pipeline_config = parent_rpcs.run_pipeline if parent_rpcs.respond_to? :run_pipeline
399
+ @run_pipeline = ::Gapic::Config::Method.new run_pipeline_config
400
+
401
+ yield self if block_given?
402
+ end
403
+ end
404
+ end
405
+ end
406
+ end
407
+ end
408
+ end
409
+ end
410
+ end
411
+ end