google-cloud-scheduler-v1 0.6.0 → 0.7.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,943 @@
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/scheduler/v1/cloudscheduler_pb"
21
+ require "google/cloud/scheduler/v1/cloud_scheduler/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+
24
+ module Google
25
+ module Cloud
26
+ module Scheduler
27
+ module V1
28
+ module CloudScheduler
29
+ module Rest
30
+ ##
31
+ # REST client for the CloudScheduler service.
32
+ #
33
+ # The Cloud Scheduler API allows external entities to reliably
34
+ # schedule asynchronous jobs.
35
+ #
36
+ class Client
37
+ include Paths
38
+
39
+ # @private
40
+ attr_reader :cloud_scheduler_stub
41
+
42
+ ##
43
+ # Configure the CloudScheduler Client class.
44
+ #
45
+ # See {::Google::Cloud::Scheduler::V1::CloudScheduler::Rest::Client::Configuration}
46
+ # for a description of the configuration fields.
47
+ #
48
+ # @example
49
+ #
50
+ # # Modify the configuration for all CloudScheduler clients
51
+ # ::Google::Cloud::Scheduler::V1::CloudScheduler::Rest::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", "Scheduler", "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.list_jobs.timeout = 600.0
72
+ default_config.rpcs.list_jobs.retry_policy = {
73
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
74
+ }
75
+
76
+ default_config.rpcs.get_job.timeout = 600.0
77
+ default_config.rpcs.get_job.retry_policy = {
78
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
79
+ }
80
+
81
+ default_config.rpcs.create_job.timeout = 600.0
82
+
83
+ default_config.rpcs.update_job.timeout = 600.0
84
+
85
+ default_config.rpcs.delete_job.timeout = 600.0
86
+ default_config.rpcs.delete_job.retry_policy = {
87
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
88
+ }
89
+
90
+ default_config.rpcs.pause_job.timeout = 600.0
91
+
92
+ default_config.rpcs.resume_job.timeout = 600.0
93
+
94
+ default_config.rpcs.run_job.timeout = 600.0
95
+
96
+ default_config
97
+ end
98
+ yield @configure if block_given?
99
+ @configure
100
+ end
101
+
102
+ ##
103
+ # Configure the CloudScheduler Client instance.
104
+ #
105
+ # The configuration is set to the derived mode, meaning that values can be changed,
106
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
107
+ # should be made on {Client.configure}.
108
+ #
109
+ # See {::Google::Cloud::Scheduler::V1::CloudScheduler::Rest::Client::Configuration}
110
+ # for a description of the configuration fields.
111
+ #
112
+ # @yield [config] Configure the Client client.
113
+ # @yieldparam config [Client::Configuration]
114
+ #
115
+ # @return [Client::Configuration]
116
+ #
117
+ def configure
118
+ yield @config if block_given?
119
+ @config
120
+ end
121
+
122
+ ##
123
+ # Create a new CloudScheduler REST client object.
124
+ #
125
+ # @example
126
+ #
127
+ # # Create a client using the default configuration
128
+ # client = ::Google::Cloud::Scheduler::V1::CloudScheduler::Rest::Client.new
129
+ #
130
+ # # Create a client using a custom configuration
131
+ # client = ::Google::Cloud::Scheduler::V1::CloudScheduler::Rest::Client.new do |config|
132
+ # config.timeout = 10.0
133
+ # end
134
+ #
135
+ # @yield [config] Configure the CloudScheduler client.
136
+ # @yieldparam config [Client::Configuration]
137
+ #
138
+ def initialize
139
+ # Create the configuration object
140
+ @config = Configuration.new Client.configure
141
+
142
+ # Yield the configuration if needed
143
+ yield @config if block_given?
144
+
145
+ # Create credentials
146
+ credentials = @config.credentials
147
+ # Use self-signed JWT if the endpoint is unchanged from default,
148
+ # but only if the default endpoint does not have a region prefix.
149
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
150
+ !@config.endpoint.split(".").first.include?("-")
151
+ credentials ||= Credentials.default scope: @config.scope,
152
+ enable_self_signed_jwt: enable_self_signed_jwt
153
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
154
+ credentials = Credentials.new credentials, scope: @config.scope
155
+ end
156
+
157
+ @quota_project_id = @config.quota_project
158
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
159
+
160
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
161
+ config.credentials = credentials
162
+ config.quota_project = @quota_project_id
163
+ config.endpoint = @config.endpoint
164
+ config.bindings_override = @config.bindings_override
165
+ end
166
+
167
+ @cloud_scheduler_stub = ::Google::Cloud::Scheduler::V1::CloudScheduler::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
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
+ # Lists jobs.
181
+ #
182
+ # @overload list_jobs(request, options = nil)
183
+ # Pass arguments to `list_jobs` via a request object, either of type
184
+ # {::Google::Cloud::Scheduler::V1::ListJobsRequest} or an equivalent Hash.
185
+ #
186
+ # @param request [::Google::Cloud::Scheduler::V1::ListJobsRequest, ::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 list_jobs(parent: nil, page_size: nil, page_token: nil)
193
+ # Pass arguments to `list_jobs` 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 parent [::String]
198
+ # Required. The location name. For example:
199
+ # `projects/PROJECT_ID/locations/LOCATION_ID`.
200
+ # @param page_size [::Integer]
201
+ # Requested page size.
202
+ #
203
+ # The maximum page size is 500. If unspecified, the page size will
204
+ # be the maximum. Fewer jobs than requested might be returned,
205
+ # even if more jobs exist; use next_page_token to determine if more
206
+ # jobs exist.
207
+ # @param page_token [::String]
208
+ # A token identifying a page of results the server will return. To
209
+ # request the first page results, page_token must be empty. To
210
+ # request the next page of results, page_token must be the value of
211
+ # {::Google::Cloud::Scheduler::V1::ListJobsResponse#next_page_token next_page_token}
212
+ # returned from the previous call to
213
+ # {::Google::Cloud::Scheduler::V1::CloudScheduler::Rest::Client#list_jobs ListJobs}. It is an
214
+ # error to switch the value of
215
+ # [filter][google.cloud.scheduler.v1.ListJobsRequest.filter] or
216
+ # [order_by][google.cloud.scheduler.v1.ListJobsRequest.order_by] while
217
+ # iterating through pages.
218
+ # @yield [result, operation] Access the result along with the TransportOperation object
219
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Scheduler::V1::Job>]
220
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
221
+ #
222
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Scheduler::V1::Job>]
223
+ #
224
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
225
+ def list_jobs request, options = nil
226
+ raise ::ArgumentError, "request must be provided" if request.nil?
227
+
228
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1::ListJobsRequest
229
+
230
+ # Converts hash and nil to an options object
231
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
232
+
233
+ # Customize the options with defaults
234
+ call_metadata = @config.rpcs.list_jobs.metadata.to_h
235
+
236
+ # Set x-goog-api-client and x-goog-user-project headers
237
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
238
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
239
+ gapic_version: ::Google::Cloud::Scheduler::V1::VERSION,
240
+ transports_version_send: [:rest]
241
+
242
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
243
+
244
+ options.apply_defaults timeout: @config.rpcs.list_jobs.timeout,
245
+ metadata: call_metadata,
246
+ retry_policy: @config.rpcs.list_jobs.retry_policy
247
+
248
+ options.apply_defaults timeout: @config.timeout,
249
+ metadata: @config.metadata,
250
+ retry_policy: @config.retry_policy
251
+
252
+ @cloud_scheduler_stub.list_jobs request, options do |result, operation|
253
+ result = ::Gapic::Rest::PagedEnumerable.new @cloud_scheduler_stub, :list_jobs, "jobs", request, result, options
254
+ yield result, operation if block_given?
255
+ return result
256
+ end
257
+ rescue ::Gapic::Rest::Error => e
258
+ raise ::Google::Cloud::Error.from_error(e)
259
+ end
260
+
261
+ ##
262
+ # Gets a job.
263
+ #
264
+ # @overload get_job(request, options = nil)
265
+ # Pass arguments to `get_job` via a request object, either of type
266
+ # {::Google::Cloud::Scheduler::V1::GetJobRequest} or an equivalent Hash.
267
+ #
268
+ # @param request [::Google::Cloud::Scheduler::V1::GetJobRequest, ::Hash]
269
+ # A request object representing the call parameters. Required. To specify no
270
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
271
+ # @param options [::Gapic::CallOptions, ::Hash]
272
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
273
+ #
274
+ # @overload get_job(name: nil)
275
+ # Pass arguments to `get_job` via keyword arguments. Note that at
276
+ # least one keyword argument is required. To specify no parameters, or to keep all
277
+ # the default parameter values, pass an empty Hash as a request object (see above).
278
+ #
279
+ # @param name [::String]
280
+ # Required. The job name. For example:
281
+ # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
282
+ # @yield [result, operation] Access the result along with the TransportOperation object
283
+ # @yieldparam result [::Google::Cloud::Scheduler::V1::Job]
284
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
285
+ #
286
+ # @return [::Google::Cloud::Scheduler::V1::Job]
287
+ #
288
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
289
+ def get_job request, options = nil
290
+ raise ::ArgumentError, "request must be provided" if request.nil?
291
+
292
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1::GetJobRequest
293
+
294
+ # Converts hash and nil to an options object
295
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
296
+
297
+ # Customize the options with defaults
298
+ call_metadata = @config.rpcs.get_job.metadata.to_h
299
+
300
+ # Set x-goog-api-client and x-goog-user-project headers
301
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
302
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
303
+ gapic_version: ::Google::Cloud::Scheduler::V1::VERSION,
304
+ transports_version_send: [:rest]
305
+
306
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
307
+
308
+ options.apply_defaults timeout: @config.rpcs.get_job.timeout,
309
+ metadata: call_metadata,
310
+ retry_policy: @config.rpcs.get_job.retry_policy
311
+
312
+ options.apply_defaults timeout: @config.timeout,
313
+ metadata: @config.metadata,
314
+ retry_policy: @config.retry_policy
315
+
316
+ @cloud_scheduler_stub.get_job request, options do |result, operation|
317
+ yield result, operation if block_given?
318
+ return result
319
+ end
320
+ rescue ::Gapic::Rest::Error => e
321
+ raise ::Google::Cloud::Error.from_error(e)
322
+ end
323
+
324
+ ##
325
+ # Creates a job.
326
+ #
327
+ # @overload create_job(request, options = nil)
328
+ # Pass arguments to `create_job` via a request object, either of type
329
+ # {::Google::Cloud::Scheduler::V1::CreateJobRequest} or an equivalent Hash.
330
+ #
331
+ # @param request [::Google::Cloud::Scheduler::V1::CreateJobRequest, ::Hash]
332
+ # A request object representing the call parameters. Required. To specify no
333
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
334
+ # @param options [::Gapic::CallOptions, ::Hash]
335
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
336
+ #
337
+ # @overload create_job(parent: nil, job: nil)
338
+ # Pass arguments to `create_job` via keyword arguments. Note that at
339
+ # least one keyword argument is required. To specify no parameters, or to keep all
340
+ # the default parameter values, pass an empty Hash as a request object (see above).
341
+ #
342
+ # @param parent [::String]
343
+ # Required. The location name. For example:
344
+ # `projects/PROJECT_ID/locations/LOCATION_ID`.
345
+ # @param job [::Google::Cloud::Scheduler::V1::Job, ::Hash]
346
+ # Required. The job to add. The user can optionally specify a name for the
347
+ # job in {::Google::Cloud::Scheduler::V1::Job#name name}.
348
+ # {::Google::Cloud::Scheduler::V1::Job#name name} cannot be the same as an
349
+ # existing job. If a name is not specified then the system will
350
+ # generate a random unique name that will be returned
351
+ # ({::Google::Cloud::Scheduler::V1::Job#name name}) in the response.
352
+ # @yield [result, operation] Access the result along with the TransportOperation object
353
+ # @yieldparam result [::Google::Cloud::Scheduler::V1::Job]
354
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
355
+ #
356
+ # @return [::Google::Cloud::Scheduler::V1::Job]
357
+ #
358
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
359
+ def create_job request, options = nil
360
+ raise ::ArgumentError, "request must be provided" if request.nil?
361
+
362
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1::CreateJobRequest
363
+
364
+ # Converts hash and nil to an options object
365
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
366
+
367
+ # Customize the options with defaults
368
+ call_metadata = @config.rpcs.create_job.metadata.to_h
369
+
370
+ # Set x-goog-api-client and x-goog-user-project headers
371
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
372
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
373
+ gapic_version: ::Google::Cloud::Scheduler::V1::VERSION,
374
+ transports_version_send: [:rest]
375
+
376
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
377
+
378
+ options.apply_defaults timeout: @config.rpcs.create_job.timeout,
379
+ metadata: call_metadata,
380
+ retry_policy: @config.rpcs.create_job.retry_policy
381
+
382
+ options.apply_defaults timeout: @config.timeout,
383
+ metadata: @config.metadata,
384
+ retry_policy: @config.retry_policy
385
+
386
+ @cloud_scheduler_stub.create_job request, options do |result, operation|
387
+ yield result, operation if block_given?
388
+ return result
389
+ end
390
+ rescue ::Gapic::Rest::Error => e
391
+ raise ::Google::Cloud::Error.from_error(e)
392
+ end
393
+
394
+ ##
395
+ # Updates a job.
396
+ #
397
+ # If successful, the updated {::Google::Cloud::Scheduler::V1::Job Job} is
398
+ # returned. If the job does not exist, `NOT_FOUND` is returned.
399
+ #
400
+ # If UpdateJob does not successfully return, it is possible for the
401
+ # job to be in an
402
+ # {::Google::Cloud::Scheduler::V1::Job::State::UPDATE_FAILED Job.State.UPDATE_FAILED}
403
+ # state. A job in this state may not be executed. If this happens, retry the
404
+ # UpdateJob request until a successful response is received.
405
+ #
406
+ # @overload update_job(request, options = nil)
407
+ # Pass arguments to `update_job` via a request object, either of type
408
+ # {::Google::Cloud::Scheduler::V1::UpdateJobRequest} or an equivalent Hash.
409
+ #
410
+ # @param request [::Google::Cloud::Scheduler::V1::UpdateJobRequest, ::Hash]
411
+ # A request object representing the call parameters. Required. To specify no
412
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
413
+ # @param options [::Gapic::CallOptions, ::Hash]
414
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
415
+ #
416
+ # @overload update_job(job: nil, update_mask: nil)
417
+ # Pass arguments to `update_job` via keyword arguments. Note that at
418
+ # least one keyword argument is required. To specify no parameters, or to keep all
419
+ # the default parameter values, pass an empty Hash as a request object (see above).
420
+ #
421
+ # @param job [::Google::Cloud::Scheduler::V1::Job, ::Hash]
422
+ # Required. The new job properties.
423
+ # {::Google::Cloud::Scheduler::V1::Job#name name} must be specified.
424
+ #
425
+ # Output only fields cannot be modified using UpdateJob.
426
+ # Any value specified for an output only field will be ignored.
427
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
428
+ # A mask used to specify which fields of the job are being updated.
429
+ # @yield [result, operation] Access the result along with the TransportOperation object
430
+ # @yieldparam result [::Google::Cloud::Scheduler::V1::Job]
431
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
432
+ #
433
+ # @return [::Google::Cloud::Scheduler::V1::Job]
434
+ #
435
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
436
+ def update_job request, options = nil
437
+ raise ::ArgumentError, "request must be provided" if request.nil?
438
+
439
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1::UpdateJobRequest
440
+
441
+ # Converts hash and nil to an options object
442
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
443
+
444
+ # Customize the options with defaults
445
+ call_metadata = @config.rpcs.update_job.metadata.to_h
446
+
447
+ # Set x-goog-api-client and x-goog-user-project headers
448
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
449
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
450
+ gapic_version: ::Google::Cloud::Scheduler::V1::VERSION,
451
+ transports_version_send: [:rest]
452
+
453
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
454
+
455
+ options.apply_defaults timeout: @config.rpcs.update_job.timeout,
456
+ metadata: call_metadata,
457
+ retry_policy: @config.rpcs.update_job.retry_policy
458
+
459
+ options.apply_defaults timeout: @config.timeout,
460
+ metadata: @config.metadata,
461
+ retry_policy: @config.retry_policy
462
+
463
+ @cloud_scheduler_stub.update_job request, options do |result, operation|
464
+ yield result, operation if block_given?
465
+ return result
466
+ end
467
+ rescue ::Gapic::Rest::Error => e
468
+ raise ::Google::Cloud::Error.from_error(e)
469
+ end
470
+
471
+ ##
472
+ # Deletes a job.
473
+ #
474
+ # @overload delete_job(request, options = nil)
475
+ # Pass arguments to `delete_job` via a request object, either of type
476
+ # {::Google::Cloud::Scheduler::V1::DeleteJobRequest} or an equivalent Hash.
477
+ #
478
+ # @param request [::Google::Cloud::Scheduler::V1::DeleteJobRequest, ::Hash]
479
+ # A request object representing the call parameters. Required. To specify no
480
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
481
+ # @param options [::Gapic::CallOptions, ::Hash]
482
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
483
+ #
484
+ # @overload delete_job(name: nil)
485
+ # Pass arguments to `delete_job` via keyword arguments. Note that at
486
+ # least one keyword argument is required. To specify no parameters, or to keep all
487
+ # the default parameter values, pass an empty Hash as a request object (see above).
488
+ #
489
+ # @param name [::String]
490
+ # Required. The job name. For example:
491
+ # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
492
+ # @yield [result, operation] Access the result along with the TransportOperation object
493
+ # @yieldparam result [::Google::Protobuf::Empty]
494
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
495
+ #
496
+ # @return [::Google::Protobuf::Empty]
497
+ #
498
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
499
+ def delete_job request, options = nil
500
+ raise ::ArgumentError, "request must be provided" if request.nil?
501
+
502
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1::DeleteJobRequest
503
+
504
+ # Converts hash and nil to an options object
505
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
506
+
507
+ # Customize the options with defaults
508
+ call_metadata = @config.rpcs.delete_job.metadata.to_h
509
+
510
+ # Set x-goog-api-client and x-goog-user-project headers
511
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
512
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
513
+ gapic_version: ::Google::Cloud::Scheduler::V1::VERSION,
514
+ transports_version_send: [:rest]
515
+
516
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
517
+
518
+ options.apply_defaults timeout: @config.rpcs.delete_job.timeout,
519
+ metadata: call_metadata,
520
+ retry_policy: @config.rpcs.delete_job.retry_policy
521
+
522
+ options.apply_defaults timeout: @config.timeout,
523
+ metadata: @config.metadata,
524
+ retry_policy: @config.retry_policy
525
+
526
+ @cloud_scheduler_stub.delete_job request, options do |result, operation|
527
+ yield result, operation if block_given?
528
+ return result
529
+ end
530
+ rescue ::Gapic::Rest::Error => e
531
+ raise ::Google::Cloud::Error.from_error(e)
532
+ end
533
+
534
+ ##
535
+ # Pauses a job.
536
+ #
537
+ # If a job is paused then the system will stop executing the job
538
+ # until it is re-enabled via
539
+ # {::Google::Cloud::Scheduler::V1::CloudScheduler::Rest::Client#resume_job ResumeJob}. The state
540
+ # of the job is stored in {::Google::Cloud::Scheduler::V1::Job#state state}; if
541
+ # paused it will be set to
542
+ # {::Google::Cloud::Scheduler::V1::Job::State::PAUSED Job.State.PAUSED}. A job must
543
+ # be in {::Google::Cloud::Scheduler::V1::Job::State::ENABLED Job.State.ENABLED} to
544
+ # be paused.
545
+ #
546
+ # @overload pause_job(request, options = nil)
547
+ # Pass arguments to `pause_job` via a request object, either of type
548
+ # {::Google::Cloud::Scheduler::V1::PauseJobRequest} or an equivalent Hash.
549
+ #
550
+ # @param request [::Google::Cloud::Scheduler::V1::PauseJobRequest, ::Hash]
551
+ # A request object representing the call parameters. Required. To specify no
552
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
553
+ # @param options [::Gapic::CallOptions, ::Hash]
554
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
555
+ #
556
+ # @overload pause_job(name: nil)
557
+ # Pass arguments to `pause_job` via keyword arguments. Note that at
558
+ # least one keyword argument is required. To specify no parameters, or to keep all
559
+ # the default parameter values, pass an empty Hash as a request object (see above).
560
+ #
561
+ # @param name [::String]
562
+ # Required. The job name. For example:
563
+ # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
564
+ # @yield [result, operation] Access the result along with the TransportOperation object
565
+ # @yieldparam result [::Google::Cloud::Scheduler::V1::Job]
566
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
567
+ #
568
+ # @return [::Google::Cloud::Scheduler::V1::Job]
569
+ #
570
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
571
+ def pause_job request, options = nil
572
+ raise ::ArgumentError, "request must be provided" if request.nil?
573
+
574
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1::PauseJobRequest
575
+
576
+ # Converts hash and nil to an options object
577
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
578
+
579
+ # Customize the options with defaults
580
+ call_metadata = @config.rpcs.pause_job.metadata.to_h
581
+
582
+ # Set x-goog-api-client and x-goog-user-project headers
583
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
584
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
585
+ gapic_version: ::Google::Cloud::Scheduler::V1::VERSION,
586
+ transports_version_send: [:rest]
587
+
588
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
589
+
590
+ options.apply_defaults timeout: @config.rpcs.pause_job.timeout,
591
+ metadata: call_metadata,
592
+ retry_policy: @config.rpcs.pause_job.retry_policy
593
+
594
+ options.apply_defaults timeout: @config.timeout,
595
+ metadata: @config.metadata,
596
+ retry_policy: @config.retry_policy
597
+
598
+ @cloud_scheduler_stub.pause_job request, options do |result, operation|
599
+ yield result, operation if block_given?
600
+ return result
601
+ end
602
+ rescue ::Gapic::Rest::Error => e
603
+ raise ::Google::Cloud::Error.from_error(e)
604
+ end
605
+
606
+ ##
607
+ # Resume a job.
608
+ #
609
+ # This method reenables a job after it has been
610
+ # {::Google::Cloud::Scheduler::V1::Job::State::PAUSED Job.State.PAUSED}. The state
611
+ # of a job is stored in {::Google::Cloud::Scheduler::V1::Job#state Job.state};
612
+ # after calling this method it will be set to
613
+ # {::Google::Cloud::Scheduler::V1::Job::State::ENABLED Job.State.ENABLED}. A job
614
+ # must be in {::Google::Cloud::Scheduler::V1::Job::State::PAUSED Job.State.PAUSED}
615
+ # to be resumed.
616
+ #
617
+ # @overload resume_job(request, options = nil)
618
+ # Pass arguments to `resume_job` via a request object, either of type
619
+ # {::Google::Cloud::Scheduler::V1::ResumeJobRequest} or an equivalent Hash.
620
+ #
621
+ # @param request [::Google::Cloud::Scheduler::V1::ResumeJobRequest, ::Hash]
622
+ # A request object representing the call parameters. Required. To specify no
623
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
624
+ # @param options [::Gapic::CallOptions, ::Hash]
625
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
626
+ #
627
+ # @overload resume_job(name: nil)
628
+ # Pass arguments to `resume_job` via keyword arguments. Note that at
629
+ # least one keyword argument is required. To specify no parameters, or to keep all
630
+ # the default parameter values, pass an empty Hash as a request object (see above).
631
+ #
632
+ # @param name [::String]
633
+ # Required. The job name. For example:
634
+ # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
635
+ # @yield [result, operation] Access the result along with the TransportOperation object
636
+ # @yieldparam result [::Google::Cloud::Scheduler::V1::Job]
637
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
638
+ #
639
+ # @return [::Google::Cloud::Scheduler::V1::Job]
640
+ #
641
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
642
+ def resume_job request, options = nil
643
+ raise ::ArgumentError, "request must be provided" if request.nil?
644
+
645
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1::ResumeJobRequest
646
+
647
+ # Converts hash and nil to an options object
648
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
649
+
650
+ # Customize the options with defaults
651
+ call_metadata = @config.rpcs.resume_job.metadata.to_h
652
+
653
+ # Set x-goog-api-client and x-goog-user-project headers
654
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
655
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
656
+ gapic_version: ::Google::Cloud::Scheduler::V1::VERSION,
657
+ transports_version_send: [:rest]
658
+
659
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
660
+
661
+ options.apply_defaults timeout: @config.rpcs.resume_job.timeout,
662
+ metadata: call_metadata,
663
+ retry_policy: @config.rpcs.resume_job.retry_policy
664
+
665
+ options.apply_defaults timeout: @config.timeout,
666
+ metadata: @config.metadata,
667
+ retry_policy: @config.retry_policy
668
+
669
+ @cloud_scheduler_stub.resume_job request, options do |result, operation|
670
+ yield result, operation if block_given?
671
+ return result
672
+ end
673
+ rescue ::Gapic::Rest::Error => e
674
+ raise ::Google::Cloud::Error.from_error(e)
675
+ end
676
+
677
+ ##
678
+ # Forces a job to run now.
679
+ #
680
+ # When this method is called, Cloud Scheduler will dispatch the job, even
681
+ # if the job is already running.
682
+ #
683
+ # @overload run_job(request, options = nil)
684
+ # Pass arguments to `run_job` via a request object, either of type
685
+ # {::Google::Cloud::Scheduler::V1::RunJobRequest} or an equivalent Hash.
686
+ #
687
+ # @param request [::Google::Cloud::Scheduler::V1::RunJobRequest, ::Hash]
688
+ # A request object representing the call parameters. Required. To specify no
689
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
690
+ # @param options [::Gapic::CallOptions, ::Hash]
691
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
692
+ #
693
+ # @overload run_job(name: nil)
694
+ # Pass arguments to `run_job` via keyword arguments. Note that at
695
+ # least one keyword argument is required. To specify no parameters, or to keep all
696
+ # the default parameter values, pass an empty Hash as a request object (see above).
697
+ #
698
+ # @param name [::String]
699
+ # Required. The job name. For example:
700
+ # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
701
+ # @yield [result, operation] Access the result along with the TransportOperation object
702
+ # @yieldparam result [::Google::Cloud::Scheduler::V1::Job]
703
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
704
+ #
705
+ # @return [::Google::Cloud::Scheduler::V1::Job]
706
+ #
707
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
708
+ def run_job request, options = nil
709
+ raise ::ArgumentError, "request must be provided" if request.nil?
710
+
711
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1::RunJobRequest
712
+
713
+ # Converts hash and nil to an options object
714
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
715
+
716
+ # Customize the options with defaults
717
+ call_metadata = @config.rpcs.run_job.metadata.to_h
718
+
719
+ # Set x-goog-api-client and x-goog-user-project headers
720
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
721
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
722
+ gapic_version: ::Google::Cloud::Scheduler::V1::VERSION,
723
+ transports_version_send: [:rest]
724
+
725
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
726
+
727
+ options.apply_defaults timeout: @config.rpcs.run_job.timeout,
728
+ metadata: call_metadata,
729
+ retry_policy: @config.rpcs.run_job.retry_policy
730
+
731
+ options.apply_defaults timeout: @config.timeout,
732
+ metadata: @config.metadata,
733
+ retry_policy: @config.retry_policy
734
+
735
+ @cloud_scheduler_stub.run_job request, options do |result, operation|
736
+ yield result, operation if block_given?
737
+ return result
738
+ end
739
+ rescue ::Gapic::Rest::Error => e
740
+ raise ::Google::Cloud::Error.from_error(e)
741
+ end
742
+
743
+ ##
744
+ # Configuration class for the CloudScheduler REST API.
745
+ #
746
+ # This class represents the configuration for CloudScheduler REST,
747
+ # providing control over timeouts, retry behavior, logging, transport
748
+ # parameters, and other low-level controls. Certain parameters can also be
749
+ # applied individually to specific RPCs. See
750
+ # {::Google::Cloud::Scheduler::V1::CloudScheduler::Rest::Client::Configuration::Rpcs}
751
+ # for a list of RPCs that can be configured independently.
752
+ #
753
+ # Configuration can be applied globally to all clients, or to a single client
754
+ # on construction.
755
+ #
756
+ # @example
757
+ #
758
+ # # Modify the global config, setting the timeout for
759
+ # # list_jobs to 20 seconds,
760
+ # # and all remaining timeouts to 10 seconds.
761
+ # ::Google::Cloud::Scheduler::V1::CloudScheduler::Rest::Client.configure do |config|
762
+ # config.timeout = 10.0
763
+ # config.rpcs.list_jobs.timeout = 20.0
764
+ # end
765
+ #
766
+ # # Apply the above configuration only to a new client.
767
+ # client = ::Google::Cloud::Scheduler::V1::CloudScheduler::Rest::Client.new do |config|
768
+ # config.timeout = 10.0
769
+ # config.rpcs.list_jobs.timeout = 20.0
770
+ # end
771
+ #
772
+ # @!attribute [rw] endpoint
773
+ # The hostname or hostname:port of the service endpoint.
774
+ # Defaults to `"cloudscheduler.googleapis.com"`.
775
+ # @return [::String]
776
+ # @!attribute [rw] credentials
777
+ # Credentials to send with calls. You may provide any of the following types:
778
+ # * (`String`) The path to a service account key file in JSON format
779
+ # * (`Hash`) A service account key as a Hash
780
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
781
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
782
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
783
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
784
+ # * (`nil`) indicating no credentials
785
+ # @return [::Object]
786
+ # @!attribute [rw] scope
787
+ # The OAuth scopes
788
+ # @return [::Array<::String>]
789
+ # @!attribute [rw] lib_name
790
+ # The library name as recorded in instrumentation and logging
791
+ # @return [::String]
792
+ # @!attribute [rw] lib_version
793
+ # The library version as recorded in instrumentation and logging
794
+ # @return [::String]
795
+ # @!attribute [rw] timeout
796
+ # The call timeout in seconds.
797
+ # @return [::Numeric]
798
+ # @!attribute [rw] metadata
799
+ # Additional headers to be sent with the call.
800
+ # @return [::Hash{::Symbol=>::String}]
801
+ # @!attribute [rw] retry_policy
802
+ # The retry policy. The value is a hash with the following keys:
803
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
804
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
805
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
806
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
807
+ # trigger a retry.
808
+ # @return [::Hash]
809
+ # @!attribute [rw] quota_project
810
+ # A separate project against which to charge quota.
811
+ # @return [::String]
812
+ #
813
+ class Configuration
814
+ extend ::Gapic::Config
815
+
816
+ config_attr :endpoint, "cloudscheduler.googleapis.com", ::String
817
+ config_attr :credentials, nil do |value|
818
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
819
+ allowed.any? { |klass| klass === value }
820
+ end
821
+ config_attr :scope, nil, ::String, ::Array, nil
822
+ config_attr :lib_name, nil, ::String, nil
823
+ config_attr :lib_version, nil, ::String, nil
824
+ config_attr :timeout, nil, ::Numeric, nil
825
+ config_attr :metadata, nil, ::Hash, nil
826
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
827
+ config_attr :quota_project, nil, ::String, nil
828
+
829
+ # @private
830
+ # Overrides for http bindings for the RPCs of this service
831
+ # are only used when this service is used as mixin, and only
832
+ # by the host service.
833
+ # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
834
+ config_attr :bindings_override, {}, ::Hash, nil
835
+
836
+ # @private
837
+ def initialize parent_config = nil
838
+ @parent_config = parent_config unless parent_config.nil?
839
+
840
+ yield self if block_given?
841
+ end
842
+
843
+ ##
844
+ # Configurations for individual RPCs
845
+ # @return [Rpcs]
846
+ #
847
+ def rpcs
848
+ @rpcs ||= begin
849
+ parent_rpcs = nil
850
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
851
+ Rpcs.new parent_rpcs
852
+ end
853
+ end
854
+
855
+ ##
856
+ # Configuration RPC class for the CloudScheduler API.
857
+ #
858
+ # Includes fields providing the configuration for each RPC in this service.
859
+ # Each configuration object is of type `Gapic::Config::Method` and includes
860
+ # the following configuration fields:
861
+ #
862
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
863
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
864
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
865
+ # include the following keys:
866
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
867
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
868
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
869
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
870
+ # trigger a retry.
871
+ #
872
+ class Rpcs
873
+ ##
874
+ # RPC-specific configuration for `list_jobs`
875
+ # @return [::Gapic::Config::Method]
876
+ #
877
+ attr_reader :list_jobs
878
+ ##
879
+ # RPC-specific configuration for `get_job`
880
+ # @return [::Gapic::Config::Method]
881
+ #
882
+ attr_reader :get_job
883
+ ##
884
+ # RPC-specific configuration for `create_job`
885
+ # @return [::Gapic::Config::Method]
886
+ #
887
+ attr_reader :create_job
888
+ ##
889
+ # RPC-specific configuration for `update_job`
890
+ # @return [::Gapic::Config::Method]
891
+ #
892
+ attr_reader :update_job
893
+ ##
894
+ # RPC-specific configuration for `delete_job`
895
+ # @return [::Gapic::Config::Method]
896
+ #
897
+ attr_reader :delete_job
898
+ ##
899
+ # RPC-specific configuration for `pause_job`
900
+ # @return [::Gapic::Config::Method]
901
+ #
902
+ attr_reader :pause_job
903
+ ##
904
+ # RPC-specific configuration for `resume_job`
905
+ # @return [::Gapic::Config::Method]
906
+ #
907
+ attr_reader :resume_job
908
+ ##
909
+ # RPC-specific configuration for `run_job`
910
+ # @return [::Gapic::Config::Method]
911
+ #
912
+ attr_reader :run_job
913
+
914
+ # @private
915
+ def initialize parent_rpcs = nil
916
+ list_jobs_config = parent_rpcs.list_jobs if parent_rpcs.respond_to? :list_jobs
917
+ @list_jobs = ::Gapic::Config::Method.new list_jobs_config
918
+ get_job_config = parent_rpcs.get_job if parent_rpcs.respond_to? :get_job
919
+ @get_job = ::Gapic::Config::Method.new get_job_config
920
+ create_job_config = parent_rpcs.create_job if parent_rpcs.respond_to? :create_job
921
+ @create_job = ::Gapic::Config::Method.new create_job_config
922
+ update_job_config = parent_rpcs.update_job if parent_rpcs.respond_to? :update_job
923
+ @update_job = ::Gapic::Config::Method.new update_job_config
924
+ delete_job_config = parent_rpcs.delete_job if parent_rpcs.respond_to? :delete_job
925
+ @delete_job = ::Gapic::Config::Method.new delete_job_config
926
+ pause_job_config = parent_rpcs.pause_job if parent_rpcs.respond_to? :pause_job
927
+ @pause_job = ::Gapic::Config::Method.new pause_job_config
928
+ resume_job_config = parent_rpcs.resume_job if parent_rpcs.respond_to? :resume_job
929
+ @resume_job = ::Gapic::Config::Method.new resume_job_config
930
+ run_job_config = parent_rpcs.run_job if parent_rpcs.respond_to? :run_job
931
+ @run_job = ::Gapic::Config::Method.new run_job_config
932
+
933
+ yield self if block_given?
934
+ end
935
+ end
936
+ end
937
+ end
938
+ end
939
+ end
940
+ end
941
+ end
942
+ end
943
+ end