google-cloud-scheduler-v1beta1 0.5.0 → 0.7.0

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