google-cloud-batch-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +149 -0
  4. data/LICENSE.md +201 -0
  5. data/README.md +141 -0
  6. data/lib/google/cloud/batch/v1/batch_pb.rb +84 -0
  7. data/lib/google/cloud/batch/v1/batch_service/client.rb +994 -0
  8. data/lib/google/cloud/batch/v1/batch_service/credentials.rb +47 -0
  9. data/lib/google/cloud/batch/v1/batch_service/operations.rb +767 -0
  10. data/lib/google/cloud/batch/v1/batch_service/paths.rb +113 -0
  11. data/lib/google/cloud/batch/v1/batch_service.rb +52 -0
  12. data/lib/google/cloud/batch/v1/batch_services_pb.rb +57 -0
  13. data/lib/google/cloud/batch/v1/job_pb.rb +170 -0
  14. data/lib/google/cloud/batch/v1/task_pb.rb +121 -0
  15. data/lib/google/cloud/batch/v1/version.rb +28 -0
  16. data/lib/google/cloud/batch/v1/volume_pb.rb +37 -0
  17. data/lib/google/cloud/batch/v1.rb +40 -0
  18. data/lib/google-cloud-batch-v1.rb +21 -0
  19. data/proto_docs/README.md +4 -0
  20. data/proto_docs/google/api/field_behavior.rb +71 -0
  21. data/proto_docs/google/api/resource.rb +222 -0
  22. data/proto_docs/google/cloud/batch/v1/batch.rb +209 -0
  23. data/proto_docs/google/cloud/batch/v1/job.rb +490 -0
  24. data/proto_docs/google/cloud/batch/v1/task.rb +329 -0
  25. data/proto_docs/google/cloud/batch/v1/volume.rb +78 -0
  26. data/proto_docs/google/longrunning/operations.rb +164 -0
  27. data/proto_docs/google/protobuf/any.rb +141 -0
  28. data/proto_docs/google/protobuf/duration.rb +98 -0
  29. data/proto_docs/google/protobuf/empty.rb +36 -0
  30. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  31. data/proto_docs/google/protobuf/timestamp.rb +129 -0
  32. data/proto_docs/google/rpc/status.rb +46 -0
  33. data/proto_docs/google/type/expr.rb +75 -0
  34. metadata +266 -0
@@ -0,0 +1,994 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2022 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/batch/v1/batch_pb"
21
+ require "google/cloud/location"
22
+ require "google/iam/v1/iam_policy"
23
+
24
+ module Google
25
+ module Cloud
26
+ module Batch
27
+ module V1
28
+ module BatchService
29
+ ##
30
+ # Client for the BatchService service.
31
+ #
32
+ # Google Batch Service.
33
+ # The service manages user submitted batch jobs and allocates Google Compute
34
+ # Engine VM instances to run the jobs.
35
+ #
36
+ class Client
37
+ include Paths
38
+
39
+ # @private
40
+ attr_reader :batch_service_stub
41
+
42
+ ##
43
+ # Configure the BatchService Client class.
44
+ #
45
+ # See {::Google::Cloud::Batch::V1::BatchService::Client::Configuration}
46
+ # for a description of the configuration fields.
47
+ #
48
+ # @example
49
+ #
50
+ # # Modify the configuration for all BatchService clients
51
+ # ::Google::Cloud::Batch::V1::BatchService::Client.configure do |config|
52
+ # config.timeout = 10.0
53
+ # end
54
+ #
55
+ # @yield [config] Configure the Client client.
56
+ # @yieldparam config [Client::Configuration]
57
+ #
58
+ # @return [Client::Configuration]
59
+ #
60
+ def self.configure
61
+ @configure ||= begin
62
+ namespace = ["Google", "Cloud", "Batch", "V1"]
63
+ parent_config = while namespace.any?
64
+ parent_name = namespace.join "::"
65
+ parent_const = const_get parent_name
66
+ break parent_const.configure if parent_const.respond_to? :configure
67
+ namespace.pop
68
+ end
69
+ default_config = Client::Configuration.new parent_config
70
+
71
+ default_config.rpcs.create_job.timeout = 60.0
72
+
73
+ default_config.rpcs.get_job.timeout = 60.0
74
+ default_config.rpcs.get_job.retry_policy = {
75
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
76
+ }
77
+
78
+ default_config.rpcs.delete_job.timeout = 60.0
79
+
80
+ default_config.rpcs.list_jobs.timeout = 60.0
81
+ default_config.rpcs.list_jobs.retry_policy = {
82
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
83
+ }
84
+
85
+ default_config.rpcs.get_task.timeout = 60.0
86
+ default_config.rpcs.get_task.retry_policy = {
87
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
88
+ }
89
+
90
+ default_config.rpcs.list_tasks.timeout = 60.0
91
+ default_config.rpcs.list_tasks.retry_policy = {
92
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
93
+ }
94
+
95
+ default_config
96
+ end
97
+ yield @configure if block_given?
98
+ @configure
99
+ end
100
+
101
+ ##
102
+ # Configure the BatchService Client instance.
103
+ #
104
+ # The configuration is set to the derived mode, meaning that values can be changed,
105
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
106
+ # should be made on {Client.configure}.
107
+ #
108
+ # See {::Google::Cloud::Batch::V1::BatchService::Client::Configuration}
109
+ # for a description of the configuration fields.
110
+ #
111
+ # @yield [config] Configure the Client client.
112
+ # @yieldparam config [Client::Configuration]
113
+ #
114
+ # @return [Client::Configuration]
115
+ #
116
+ def configure
117
+ yield @config if block_given?
118
+ @config
119
+ end
120
+
121
+ ##
122
+ # Create a new BatchService client object.
123
+ #
124
+ # @example
125
+ #
126
+ # # Create a client using the default configuration
127
+ # client = ::Google::Cloud::Batch::V1::BatchService::Client.new
128
+ #
129
+ # # Create a client using a custom configuration
130
+ # client = ::Google::Cloud::Batch::V1::BatchService::Client.new do |config|
131
+ # config.timeout = 10.0
132
+ # end
133
+ #
134
+ # @yield [config] Configure the BatchService client.
135
+ # @yieldparam config [Client::Configuration]
136
+ #
137
+ def initialize
138
+ # These require statements are intentionally placed here to initialize
139
+ # the gRPC module only when it's required.
140
+ # See https://github.com/googleapis/toolkit/issues/446
141
+ require "gapic/grpc"
142
+ require "google/cloud/batch/v1/batch_services_pb"
143
+
144
+ # Create the configuration object
145
+ @config = Configuration.new Client.configure
146
+
147
+ # Yield the configuration if needed
148
+ yield @config if block_given?
149
+
150
+ # Create credentials
151
+ credentials = @config.credentials
152
+ # Use self-signed JWT if the endpoint is unchanged from default,
153
+ # but only if the default endpoint does not have a region prefix.
154
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
155
+ !@config.endpoint.split(".").first.include?("-")
156
+ credentials ||= Credentials.default scope: @config.scope,
157
+ enable_self_signed_jwt: enable_self_signed_jwt
158
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
159
+ credentials = Credentials.new credentials, scope: @config.scope
160
+ end
161
+ @quota_project_id = @config.quota_project
162
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
163
+
164
+ @operations_client = Operations.new do |config|
165
+ config.credentials = credentials
166
+ config.quota_project = @quota_project_id
167
+ config.endpoint = @config.endpoint
168
+ end
169
+
170
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
171
+ config.credentials = credentials
172
+ config.quota_project = @quota_project_id
173
+ config.endpoint = @config.endpoint
174
+ end
175
+
176
+ @iam_policy_client = Google::Iam::V1::IAMPolicy::Client.new do |config|
177
+ config.credentials = credentials
178
+ config.quota_project = @quota_project_id
179
+ config.endpoint = @config.endpoint
180
+ end
181
+
182
+ @batch_service_stub = ::Gapic::ServiceStub.new(
183
+ ::Google::Cloud::Batch::V1::BatchService::Stub,
184
+ credentials: credentials,
185
+ endpoint: @config.endpoint,
186
+ channel_args: @config.channel_args,
187
+ interceptors: @config.interceptors
188
+ )
189
+ end
190
+
191
+ ##
192
+ # Get the associated client for long-running operations.
193
+ #
194
+ # @return [::Google::Cloud::Batch::V1::BatchService::Operations]
195
+ #
196
+ attr_reader :operations_client
197
+
198
+ ##
199
+ # Get the associated client for mix-in of the Locations.
200
+ #
201
+ # @return [Google::Cloud::Location::Locations::Client]
202
+ #
203
+ attr_reader :location_client
204
+
205
+ ##
206
+ # Get the associated client for mix-in of the IAMPolicy.
207
+ #
208
+ # @return [Google::Iam::V1::IAMPolicy::Client]
209
+ #
210
+ attr_reader :iam_policy_client
211
+
212
+ # Service calls
213
+
214
+ ##
215
+ # Create a Job.
216
+ #
217
+ # @overload create_job(request, options = nil)
218
+ # Pass arguments to `create_job` via a request object, either of type
219
+ # {::Google::Cloud::Batch::V1::CreateJobRequest} or an equivalent Hash.
220
+ #
221
+ # @param request [::Google::Cloud::Batch::V1::CreateJobRequest, ::Hash]
222
+ # A request object representing the call parameters. Required. To specify no
223
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
224
+ # @param options [::Gapic::CallOptions, ::Hash]
225
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
226
+ #
227
+ # @overload create_job(parent: nil, job_id: nil, job: nil, request_id: nil)
228
+ # Pass arguments to `create_job` via keyword arguments. Note that at
229
+ # least one keyword argument is required. To specify no parameters, or to keep all
230
+ # the default parameter values, pass an empty Hash as a request object (see above).
231
+ #
232
+ # @param parent [::String]
233
+ # Required. The parent resource name where the Job will be created.
234
+ # Pattern: "projects/\\{project}/locations/\\{location}"
235
+ # @param job_id [::String]
236
+ # ID used to uniquely identify the Job within its parent scope.
237
+ # This field should contain at most 63 characters.
238
+ # Only alphanumeric characters or '-' are accepted.
239
+ # The '-' character cannot be the first or the last one.
240
+ # A system generated ID will be used if the field is not set.
241
+ #
242
+ # The job.name field in the request will be ignored and the created resource
243
+ # name of the Job will be "\\{parent}/jobs/\\{job_id}".
244
+ # @param job [::Google::Cloud::Batch::V1::Job, ::Hash]
245
+ # Required. The Job to create.
246
+ # @param request_id [::String]
247
+ # Optional. An optional request ID to identify requests. Specify a unique request ID
248
+ # so that if you must retry your request, the server will know to ignore
249
+ # the request if it has already been completed. The server will guarantee
250
+ # that for at least 60 minutes since the first request.
251
+ #
252
+ # For example, consider a situation where you make an initial request and t
253
+ # he request times out. If you make the request again with the same request
254
+ # ID, the server can check if original operation with the same request ID
255
+ # was received, and if so, will ignore the second request. This prevents
256
+ # clients from accidentally creating duplicate commitments.
257
+ #
258
+ # The request ID must be a valid UUID with the exception that zero UUID is
259
+ # not supported (00000000-0000-0000-0000-000000000000).
260
+ #
261
+ # @yield [response, operation] Access the result along with the RPC operation
262
+ # @yieldparam response [::Google::Cloud::Batch::V1::Job]
263
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
264
+ #
265
+ # @return [::Google::Cloud::Batch::V1::Job]
266
+ #
267
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
268
+ #
269
+ # @example Basic example
270
+ # require "google/cloud/batch/v1"
271
+ #
272
+ # # Create a client object. The client can be reused for multiple calls.
273
+ # client = Google::Cloud::Batch::V1::BatchService::Client.new
274
+ #
275
+ # # Create a request. To set request fields, pass in keyword arguments.
276
+ # request = Google::Cloud::Batch::V1::CreateJobRequest.new
277
+ #
278
+ # # Call the create_job method.
279
+ # result = client.create_job request
280
+ #
281
+ # # The returned object is of type Google::Cloud::Batch::V1::Job.
282
+ # p result
283
+ #
284
+ def create_job request, options = nil
285
+ raise ::ArgumentError, "request must be provided" if request.nil?
286
+
287
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Batch::V1::CreateJobRequest
288
+
289
+ # Converts hash and nil to an options object
290
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
291
+
292
+ # Customize the options with defaults
293
+ metadata = @config.rpcs.create_job.metadata.to_h
294
+
295
+ # Set x-goog-api-client and x-goog-user-project headers
296
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
297
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
298
+ gapic_version: ::Google::Cloud::Batch::V1::VERSION
299
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
300
+
301
+ header_params = {}
302
+ if request.parent
303
+ header_params["parent"] = request.parent
304
+ end
305
+
306
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
307
+ metadata[:"x-goog-request-params"] ||= request_params_header
308
+
309
+ options.apply_defaults timeout: @config.rpcs.create_job.timeout,
310
+ metadata: metadata,
311
+ retry_policy: @config.rpcs.create_job.retry_policy
312
+
313
+ options.apply_defaults timeout: @config.timeout,
314
+ metadata: @config.metadata,
315
+ retry_policy: @config.retry_policy
316
+
317
+ @batch_service_stub.call_rpc :create_job, request, options: options do |response, operation|
318
+ yield response, operation if block_given?
319
+ return response
320
+ end
321
+ rescue ::GRPC::BadStatus => e
322
+ raise ::Google::Cloud::Error.from_error(e)
323
+ end
324
+
325
+ ##
326
+ # Get a Job specified by its resource name.
327
+ #
328
+ # @overload get_job(request, options = nil)
329
+ # Pass arguments to `get_job` via a request object, either of type
330
+ # {::Google::Cloud::Batch::V1::GetJobRequest} or an equivalent Hash.
331
+ #
332
+ # @param request [::Google::Cloud::Batch::V1::GetJobRequest, ::Hash]
333
+ # A request object representing the call parameters. Required. To specify no
334
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
335
+ # @param options [::Gapic::CallOptions, ::Hash]
336
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
337
+ #
338
+ # @overload get_job(name: nil)
339
+ # Pass arguments to `get_job` via keyword arguments. Note that at
340
+ # least one keyword argument is required. To specify no parameters, or to keep all
341
+ # the default parameter values, pass an empty Hash as a request object (see above).
342
+ #
343
+ # @param name [::String]
344
+ # Required. Job name.
345
+ #
346
+ # @yield [response, operation] Access the result along with the RPC operation
347
+ # @yieldparam response [::Google::Cloud::Batch::V1::Job]
348
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
349
+ #
350
+ # @return [::Google::Cloud::Batch::V1::Job]
351
+ #
352
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
353
+ #
354
+ # @example Basic example
355
+ # require "google/cloud/batch/v1"
356
+ #
357
+ # # Create a client object. The client can be reused for multiple calls.
358
+ # client = Google::Cloud::Batch::V1::BatchService::Client.new
359
+ #
360
+ # # Create a request. To set request fields, pass in keyword arguments.
361
+ # request = Google::Cloud::Batch::V1::GetJobRequest.new
362
+ #
363
+ # # Call the get_job method.
364
+ # result = client.get_job request
365
+ #
366
+ # # The returned object is of type Google::Cloud::Batch::V1::Job.
367
+ # p result
368
+ #
369
+ def get_job request, options = nil
370
+ raise ::ArgumentError, "request must be provided" if request.nil?
371
+
372
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Batch::V1::GetJobRequest
373
+
374
+ # Converts hash and nil to an options object
375
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
376
+
377
+ # Customize the options with defaults
378
+ metadata = @config.rpcs.get_job.metadata.to_h
379
+
380
+ # Set x-goog-api-client and x-goog-user-project headers
381
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
382
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
383
+ gapic_version: ::Google::Cloud::Batch::V1::VERSION
384
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
385
+
386
+ header_params = {}
387
+ if request.name
388
+ header_params["name"] = request.name
389
+ end
390
+
391
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
392
+ metadata[:"x-goog-request-params"] ||= request_params_header
393
+
394
+ options.apply_defaults timeout: @config.rpcs.get_job.timeout,
395
+ metadata: metadata,
396
+ retry_policy: @config.rpcs.get_job.retry_policy
397
+
398
+ options.apply_defaults timeout: @config.timeout,
399
+ metadata: @config.metadata,
400
+ retry_policy: @config.retry_policy
401
+
402
+ @batch_service_stub.call_rpc :get_job, request, options: options do |response, operation|
403
+ yield response, operation if block_given?
404
+ return response
405
+ end
406
+ rescue ::GRPC::BadStatus => e
407
+ raise ::Google::Cloud::Error.from_error(e)
408
+ end
409
+
410
+ ##
411
+ # Delete a Job.
412
+ #
413
+ # @overload delete_job(request, options = nil)
414
+ # Pass arguments to `delete_job` via a request object, either of type
415
+ # {::Google::Cloud::Batch::V1::DeleteJobRequest} or an equivalent Hash.
416
+ #
417
+ # @param request [::Google::Cloud::Batch::V1::DeleteJobRequest, ::Hash]
418
+ # A request object representing the call parameters. Required. To specify no
419
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
420
+ # @param options [::Gapic::CallOptions, ::Hash]
421
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
422
+ #
423
+ # @overload delete_job(name: nil, reason: nil, request_id: nil)
424
+ # Pass arguments to `delete_job` via keyword arguments. Note that at
425
+ # least one keyword argument is required. To specify no parameters, or to keep all
426
+ # the default parameter values, pass an empty Hash as a request object (see above).
427
+ #
428
+ # @param name [::String]
429
+ # Job name.
430
+ # @param reason [::String]
431
+ # Optional. Reason for this deletion.
432
+ # @param request_id [::String]
433
+ # Optional. An optional request ID to identify requests. Specify a unique request ID
434
+ # so that if you must retry your request, the server will know to ignore
435
+ # the request if it has already been completed. The server will guarantee
436
+ # that for at least 60 minutes after the first request.
437
+ #
438
+ # For example, consider a situation where you make an initial request and t
439
+ # he request times out. If you make the request again with the same request
440
+ # ID, the server can check if original operation with the same request ID
441
+ # was received, and if so, will ignore the second request. This prevents
442
+ # clients from accidentally creating duplicate commitments.
443
+ #
444
+ # The request ID must be a valid UUID with the exception that zero UUID is
445
+ # not supported (00000000-0000-0000-0000-000000000000).
446
+ #
447
+ # @yield [response, operation] Access the result along with the RPC operation
448
+ # @yieldparam response [::Gapic::Operation]
449
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
450
+ #
451
+ # @return [::Gapic::Operation]
452
+ #
453
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
454
+ #
455
+ # @example Basic example
456
+ # require "google/cloud/batch/v1"
457
+ #
458
+ # # Create a client object. The client can be reused for multiple calls.
459
+ # client = Google::Cloud::Batch::V1::BatchService::Client.new
460
+ #
461
+ # # Create a request. To set request fields, pass in keyword arguments.
462
+ # request = Google::Cloud::Batch::V1::DeleteJobRequest.new
463
+ #
464
+ # # Call the delete_job method.
465
+ # result = client.delete_job request
466
+ #
467
+ # # The returned object is of type Gapic::Operation. You can use this
468
+ # # object to check the status of an operation, cancel it, or wait
469
+ # # for results. Here is how to block until completion:
470
+ # result.wait_until_done! timeout: 60
471
+ # if result.response?
472
+ # p result.response
473
+ # else
474
+ # puts "Error!"
475
+ # end
476
+ #
477
+ def delete_job request, options = nil
478
+ raise ::ArgumentError, "request must be provided" if request.nil?
479
+
480
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Batch::V1::DeleteJobRequest
481
+
482
+ # Converts hash and nil to an options object
483
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
484
+
485
+ # Customize the options with defaults
486
+ metadata = @config.rpcs.delete_job.metadata.to_h
487
+
488
+ # Set x-goog-api-client and x-goog-user-project headers
489
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
490
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
491
+ gapic_version: ::Google::Cloud::Batch::V1::VERSION
492
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
493
+
494
+ header_params = {}
495
+ if request.name
496
+ header_params["name"] = request.name
497
+ end
498
+
499
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
500
+ metadata[:"x-goog-request-params"] ||= request_params_header
501
+
502
+ options.apply_defaults timeout: @config.rpcs.delete_job.timeout,
503
+ metadata: metadata,
504
+ retry_policy: @config.rpcs.delete_job.retry_policy
505
+
506
+ options.apply_defaults timeout: @config.timeout,
507
+ metadata: @config.metadata,
508
+ retry_policy: @config.retry_policy
509
+
510
+ @batch_service_stub.call_rpc :delete_job, request, options: options do |response, operation|
511
+ response = ::Gapic::Operation.new response, @operations_client, options: options
512
+ yield response, operation if block_given?
513
+ return response
514
+ end
515
+ rescue ::GRPC::BadStatus => e
516
+ raise ::Google::Cloud::Error.from_error(e)
517
+ end
518
+
519
+ ##
520
+ # List all Jobs for a project within a region.
521
+ #
522
+ # @overload list_jobs(request, options = nil)
523
+ # Pass arguments to `list_jobs` via a request object, either of type
524
+ # {::Google::Cloud::Batch::V1::ListJobsRequest} or an equivalent Hash.
525
+ #
526
+ # @param request [::Google::Cloud::Batch::V1::ListJobsRequest, ::Hash]
527
+ # A request object representing the call parameters. Required. To specify no
528
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
529
+ # @param options [::Gapic::CallOptions, ::Hash]
530
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
531
+ #
532
+ # @overload list_jobs(parent: nil, filter: nil, page_size: nil, page_token: nil)
533
+ # Pass arguments to `list_jobs` via keyword arguments. Note that at
534
+ # least one keyword argument is required. To specify no parameters, or to keep all
535
+ # the default parameter values, pass an empty Hash as a request object (see above).
536
+ #
537
+ # @param parent [::String]
538
+ # Parent path.
539
+ # @param filter [::String]
540
+ # List filter.
541
+ # @param page_size [::Integer]
542
+ # Page size.
543
+ # @param page_token [::String]
544
+ # Page token.
545
+ #
546
+ # @yield [response, operation] Access the result along with the RPC operation
547
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Batch::V1::Job>]
548
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
549
+ #
550
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Batch::V1::Job>]
551
+ #
552
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
553
+ #
554
+ # @example Basic example
555
+ # require "google/cloud/batch/v1"
556
+ #
557
+ # # Create a client object. The client can be reused for multiple calls.
558
+ # client = Google::Cloud::Batch::V1::BatchService::Client.new
559
+ #
560
+ # # Create a request. To set request fields, pass in keyword arguments.
561
+ # request = Google::Cloud::Batch::V1::ListJobsRequest.new
562
+ #
563
+ # # Call the list_jobs method.
564
+ # result = client.list_jobs request
565
+ #
566
+ # # The returned object is of type Gapic::PagedEnumerable. You can
567
+ # # iterate over all elements by calling #each, and the enumerable
568
+ # # will lazily make API calls to fetch subsequent pages. Other
569
+ # # methods are also available for managing paging directly.
570
+ # result.each do |response|
571
+ # # Each element is of type ::Google::Cloud::Batch::V1::Job.
572
+ # p response
573
+ # end
574
+ #
575
+ def list_jobs request, options = nil
576
+ raise ::ArgumentError, "request must be provided" if request.nil?
577
+
578
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Batch::V1::ListJobsRequest
579
+
580
+ # Converts hash and nil to an options object
581
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
582
+
583
+ # Customize the options with defaults
584
+ metadata = @config.rpcs.list_jobs.metadata.to_h
585
+
586
+ # Set x-goog-api-client and x-goog-user-project headers
587
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
588
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
589
+ gapic_version: ::Google::Cloud::Batch::V1::VERSION
590
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
591
+
592
+ header_params = {}
593
+ if request.parent
594
+ header_params["parent"] = request.parent
595
+ end
596
+
597
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
598
+ metadata[:"x-goog-request-params"] ||= request_params_header
599
+
600
+ options.apply_defaults timeout: @config.rpcs.list_jobs.timeout,
601
+ metadata: metadata,
602
+ retry_policy: @config.rpcs.list_jobs.retry_policy
603
+
604
+ options.apply_defaults timeout: @config.timeout,
605
+ metadata: @config.metadata,
606
+ retry_policy: @config.retry_policy
607
+
608
+ @batch_service_stub.call_rpc :list_jobs, request, options: options do |response, operation|
609
+ response = ::Gapic::PagedEnumerable.new @batch_service_stub, :list_jobs, request, response, operation, options
610
+ yield response, operation if block_given?
611
+ return response
612
+ end
613
+ rescue ::GRPC::BadStatus => e
614
+ raise ::Google::Cloud::Error.from_error(e)
615
+ end
616
+
617
+ ##
618
+ # Return a single Task.
619
+ #
620
+ # @overload get_task(request, options = nil)
621
+ # Pass arguments to `get_task` via a request object, either of type
622
+ # {::Google::Cloud::Batch::V1::GetTaskRequest} or an equivalent Hash.
623
+ #
624
+ # @param request [::Google::Cloud::Batch::V1::GetTaskRequest, ::Hash]
625
+ # A request object representing the call parameters. Required. To specify no
626
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
627
+ # @param options [::Gapic::CallOptions, ::Hash]
628
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
629
+ #
630
+ # @overload get_task(name: nil)
631
+ # Pass arguments to `get_task` via keyword arguments. Note that at
632
+ # least one keyword argument is required. To specify no parameters, or to keep all
633
+ # the default parameter values, pass an empty Hash as a request object (see above).
634
+ #
635
+ # @param name [::String]
636
+ # Required. Task name.
637
+ #
638
+ # @yield [response, operation] Access the result along with the RPC operation
639
+ # @yieldparam response [::Google::Cloud::Batch::V1::Task]
640
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
641
+ #
642
+ # @return [::Google::Cloud::Batch::V1::Task]
643
+ #
644
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
645
+ #
646
+ # @example Basic example
647
+ # require "google/cloud/batch/v1"
648
+ #
649
+ # # Create a client object. The client can be reused for multiple calls.
650
+ # client = Google::Cloud::Batch::V1::BatchService::Client.new
651
+ #
652
+ # # Create a request. To set request fields, pass in keyword arguments.
653
+ # request = Google::Cloud::Batch::V1::GetTaskRequest.new
654
+ #
655
+ # # Call the get_task method.
656
+ # result = client.get_task request
657
+ #
658
+ # # The returned object is of type Google::Cloud::Batch::V1::Task.
659
+ # p result
660
+ #
661
+ def get_task request, options = nil
662
+ raise ::ArgumentError, "request must be provided" if request.nil?
663
+
664
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Batch::V1::GetTaskRequest
665
+
666
+ # Converts hash and nil to an options object
667
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
668
+
669
+ # Customize the options with defaults
670
+ metadata = @config.rpcs.get_task.metadata.to_h
671
+
672
+ # Set x-goog-api-client and x-goog-user-project headers
673
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
674
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
675
+ gapic_version: ::Google::Cloud::Batch::V1::VERSION
676
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
677
+
678
+ header_params = {}
679
+ if request.name
680
+ header_params["name"] = request.name
681
+ end
682
+
683
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
684
+ metadata[:"x-goog-request-params"] ||= request_params_header
685
+
686
+ options.apply_defaults timeout: @config.rpcs.get_task.timeout,
687
+ metadata: metadata,
688
+ retry_policy: @config.rpcs.get_task.retry_policy
689
+
690
+ options.apply_defaults timeout: @config.timeout,
691
+ metadata: @config.metadata,
692
+ retry_policy: @config.retry_policy
693
+
694
+ @batch_service_stub.call_rpc :get_task, request, options: options do |response, operation|
695
+ yield response, operation if block_given?
696
+ return response
697
+ end
698
+ rescue ::GRPC::BadStatus => e
699
+ raise ::Google::Cloud::Error.from_error(e)
700
+ end
701
+
702
+ ##
703
+ # List Tasks associated with a job.
704
+ #
705
+ # @overload list_tasks(request, options = nil)
706
+ # Pass arguments to `list_tasks` via a request object, either of type
707
+ # {::Google::Cloud::Batch::V1::ListTasksRequest} or an equivalent Hash.
708
+ #
709
+ # @param request [::Google::Cloud::Batch::V1::ListTasksRequest, ::Hash]
710
+ # A request object representing the call parameters. Required. To specify no
711
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
712
+ # @param options [::Gapic::CallOptions, ::Hash]
713
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
714
+ #
715
+ # @overload list_tasks(parent: nil, filter: nil, page_size: nil, page_token: nil)
716
+ # Pass arguments to `list_tasks` via keyword arguments. Note that at
717
+ # least one keyword argument is required. To specify no parameters, or to keep all
718
+ # the default parameter values, pass an empty Hash as a request object (see above).
719
+ #
720
+ # @param parent [::String]
721
+ # Required. Name of a TaskGroup from which Tasks are being requested.
722
+ # Pattern:
723
+ # "projects/\\{project}/locations/\\{location}/jobs/\\{job}/taskGroups/\\{task_group}"
724
+ # @param filter [::String]
725
+ # Task filter, null filter matches all Tasks.
726
+ # Filter string should be of the format State=TaskStatus.State e.g.
727
+ # State=RUNNING
728
+ # @param page_size [::Integer]
729
+ # Page size.
730
+ # @param page_token [::String]
731
+ # Page token.
732
+ #
733
+ # @yield [response, operation] Access the result along with the RPC operation
734
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Batch::V1::Task>]
735
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
736
+ #
737
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Batch::V1::Task>]
738
+ #
739
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
740
+ #
741
+ # @example Basic example
742
+ # require "google/cloud/batch/v1"
743
+ #
744
+ # # Create a client object. The client can be reused for multiple calls.
745
+ # client = Google::Cloud::Batch::V1::BatchService::Client.new
746
+ #
747
+ # # Create a request. To set request fields, pass in keyword arguments.
748
+ # request = Google::Cloud::Batch::V1::ListTasksRequest.new
749
+ #
750
+ # # Call the list_tasks method.
751
+ # result = client.list_tasks request
752
+ #
753
+ # # The returned object is of type Gapic::PagedEnumerable. You can
754
+ # # iterate over all elements by calling #each, and the enumerable
755
+ # # will lazily make API calls to fetch subsequent pages. Other
756
+ # # methods are also available for managing paging directly.
757
+ # result.each do |response|
758
+ # # Each element is of type ::Google::Cloud::Batch::V1::Task.
759
+ # p response
760
+ # end
761
+ #
762
+ def list_tasks request, options = nil
763
+ raise ::ArgumentError, "request must be provided" if request.nil?
764
+
765
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Batch::V1::ListTasksRequest
766
+
767
+ # Converts hash and nil to an options object
768
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
769
+
770
+ # Customize the options with defaults
771
+ metadata = @config.rpcs.list_tasks.metadata.to_h
772
+
773
+ # Set x-goog-api-client and x-goog-user-project headers
774
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
775
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
776
+ gapic_version: ::Google::Cloud::Batch::V1::VERSION
777
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
778
+
779
+ header_params = {}
780
+ if request.parent
781
+ header_params["parent"] = request.parent
782
+ end
783
+
784
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
785
+ metadata[:"x-goog-request-params"] ||= request_params_header
786
+
787
+ options.apply_defaults timeout: @config.rpcs.list_tasks.timeout,
788
+ metadata: metadata,
789
+ retry_policy: @config.rpcs.list_tasks.retry_policy
790
+
791
+ options.apply_defaults timeout: @config.timeout,
792
+ metadata: @config.metadata,
793
+ retry_policy: @config.retry_policy
794
+
795
+ @batch_service_stub.call_rpc :list_tasks, request, options: options do |response, operation|
796
+ response = ::Gapic::PagedEnumerable.new @batch_service_stub, :list_tasks, request, response, operation, options
797
+ yield response, operation if block_given?
798
+ return response
799
+ end
800
+ rescue ::GRPC::BadStatus => e
801
+ raise ::Google::Cloud::Error.from_error(e)
802
+ end
803
+
804
+ ##
805
+ # Configuration class for the BatchService API.
806
+ #
807
+ # This class represents the configuration for BatchService,
808
+ # providing control over timeouts, retry behavior, logging, transport
809
+ # parameters, and other low-level controls. Certain parameters can also be
810
+ # applied individually to specific RPCs. See
811
+ # {::Google::Cloud::Batch::V1::BatchService::Client::Configuration::Rpcs}
812
+ # for a list of RPCs that can be configured independently.
813
+ #
814
+ # Configuration can be applied globally to all clients, or to a single client
815
+ # on construction.
816
+ #
817
+ # @example
818
+ #
819
+ # # Modify the global config, setting the timeout for
820
+ # # create_job to 20 seconds,
821
+ # # and all remaining timeouts to 10 seconds.
822
+ # ::Google::Cloud::Batch::V1::BatchService::Client.configure do |config|
823
+ # config.timeout = 10.0
824
+ # config.rpcs.create_job.timeout = 20.0
825
+ # end
826
+ #
827
+ # # Apply the above configuration only to a new client.
828
+ # client = ::Google::Cloud::Batch::V1::BatchService::Client.new do |config|
829
+ # config.timeout = 10.0
830
+ # config.rpcs.create_job.timeout = 20.0
831
+ # end
832
+ #
833
+ # @!attribute [rw] endpoint
834
+ # The hostname or hostname:port of the service endpoint.
835
+ # Defaults to `"batch.googleapis.com"`.
836
+ # @return [::String]
837
+ # @!attribute [rw] credentials
838
+ # Credentials to send with calls. You may provide any of the following types:
839
+ # * (`String`) The path to a service account key file in JSON format
840
+ # * (`Hash`) A service account key as a Hash
841
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
842
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
843
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
844
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
845
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
846
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
847
+ # * (`nil`) indicating no credentials
848
+ # @return [::Object]
849
+ # @!attribute [rw] scope
850
+ # The OAuth scopes
851
+ # @return [::Array<::String>]
852
+ # @!attribute [rw] lib_name
853
+ # The library name as recorded in instrumentation and logging
854
+ # @return [::String]
855
+ # @!attribute [rw] lib_version
856
+ # The library version as recorded in instrumentation and logging
857
+ # @return [::String]
858
+ # @!attribute [rw] channel_args
859
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
860
+ # `GRPC::Core::Channel` object is provided as the credential.
861
+ # @return [::Hash]
862
+ # @!attribute [rw] interceptors
863
+ # An array of interceptors that are run before calls are executed.
864
+ # @return [::Array<::GRPC::ClientInterceptor>]
865
+ # @!attribute [rw] timeout
866
+ # The call timeout in seconds.
867
+ # @return [::Numeric]
868
+ # @!attribute [rw] metadata
869
+ # Additional gRPC headers to be sent with the call.
870
+ # @return [::Hash{::Symbol=>::String}]
871
+ # @!attribute [rw] retry_policy
872
+ # The retry policy. The value is a hash with the following keys:
873
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
874
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
875
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
876
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
877
+ # trigger a retry.
878
+ # @return [::Hash]
879
+ # @!attribute [rw] quota_project
880
+ # A separate project against which to charge quota.
881
+ # @return [::String]
882
+ #
883
+ class Configuration
884
+ extend ::Gapic::Config
885
+
886
+ config_attr :endpoint, "batch.googleapis.com", ::String
887
+ config_attr :credentials, nil do |value|
888
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
889
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
890
+ allowed.any? { |klass| klass === value }
891
+ end
892
+ config_attr :scope, nil, ::String, ::Array, nil
893
+ config_attr :lib_name, nil, ::String, nil
894
+ config_attr :lib_version, nil, ::String, nil
895
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
896
+ config_attr :interceptors, nil, ::Array, nil
897
+ config_attr :timeout, nil, ::Numeric, nil
898
+ config_attr :metadata, nil, ::Hash, nil
899
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
900
+ config_attr :quota_project, nil, ::String, nil
901
+
902
+ # @private
903
+ def initialize parent_config = nil
904
+ @parent_config = parent_config unless parent_config.nil?
905
+
906
+ yield self if block_given?
907
+ end
908
+
909
+ ##
910
+ # Configurations for individual RPCs
911
+ # @return [Rpcs]
912
+ #
913
+ def rpcs
914
+ @rpcs ||= begin
915
+ parent_rpcs = nil
916
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
917
+ Rpcs.new parent_rpcs
918
+ end
919
+ end
920
+
921
+ ##
922
+ # Configuration RPC class for the BatchService API.
923
+ #
924
+ # Includes fields providing the configuration for each RPC in this service.
925
+ # Each configuration object is of type `Gapic::Config::Method` and includes
926
+ # the following configuration fields:
927
+ #
928
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
929
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
930
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
931
+ # include the following keys:
932
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
933
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
934
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
935
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
936
+ # trigger a retry.
937
+ #
938
+ class Rpcs
939
+ ##
940
+ # RPC-specific configuration for `create_job`
941
+ # @return [::Gapic::Config::Method]
942
+ #
943
+ attr_reader :create_job
944
+ ##
945
+ # RPC-specific configuration for `get_job`
946
+ # @return [::Gapic::Config::Method]
947
+ #
948
+ attr_reader :get_job
949
+ ##
950
+ # RPC-specific configuration for `delete_job`
951
+ # @return [::Gapic::Config::Method]
952
+ #
953
+ attr_reader :delete_job
954
+ ##
955
+ # RPC-specific configuration for `list_jobs`
956
+ # @return [::Gapic::Config::Method]
957
+ #
958
+ attr_reader :list_jobs
959
+ ##
960
+ # RPC-specific configuration for `get_task`
961
+ # @return [::Gapic::Config::Method]
962
+ #
963
+ attr_reader :get_task
964
+ ##
965
+ # RPC-specific configuration for `list_tasks`
966
+ # @return [::Gapic::Config::Method]
967
+ #
968
+ attr_reader :list_tasks
969
+
970
+ # @private
971
+ def initialize parent_rpcs = nil
972
+ create_job_config = parent_rpcs.create_job if parent_rpcs.respond_to? :create_job
973
+ @create_job = ::Gapic::Config::Method.new create_job_config
974
+ get_job_config = parent_rpcs.get_job if parent_rpcs.respond_to? :get_job
975
+ @get_job = ::Gapic::Config::Method.new get_job_config
976
+ delete_job_config = parent_rpcs.delete_job if parent_rpcs.respond_to? :delete_job
977
+ @delete_job = ::Gapic::Config::Method.new delete_job_config
978
+ list_jobs_config = parent_rpcs.list_jobs if parent_rpcs.respond_to? :list_jobs
979
+ @list_jobs = ::Gapic::Config::Method.new list_jobs_config
980
+ get_task_config = parent_rpcs.get_task if parent_rpcs.respond_to? :get_task
981
+ @get_task = ::Gapic::Config::Method.new get_task_config
982
+ list_tasks_config = parent_rpcs.list_tasks if parent_rpcs.respond_to? :list_tasks
983
+ @list_tasks = ::Gapic::Config::Method.new list_tasks_config
984
+
985
+ yield self if block_given?
986
+ end
987
+ end
988
+ end
989
+ end
990
+ end
991
+ end
992
+ end
993
+ end
994
+ end