google-cloud-scheduler 0.1.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.
Files changed (24) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +9 -0
  3. data/LICENSE +201 -0
  4. data/README.md +68 -0
  5. data/lib/google/cloud/scheduler.rb +141 -0
  6. data/lib/google/cloud/scheduler/v1beta1.rb +139 -0
  7. data/lib/google/cloud/scheduler/v1beta1/cloud_scheduler_client.rb +609 -0
  8. data/lib/google/cloud/scheduler/v1beta1/cloud_scheduler_client_config.json +66 -0
  9. data/lib/google/cloud/scheduler/v1beta1/cloudscheduler_pb.rb +62 -0
  10. data/lib/google/cloud/scheduler/v1beta1/cloudscheduler_services_pb.rb +84 -0
  11. data/lib/google/cloud/scheduler/v1beta1/credentials.rb +41 -0
  12. data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/cloudscheduler.rb +142 -0
  13. data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/job.rb +199 -0
  14. data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/target.rb +280 -0
  15. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/any.rb +130 -0
  16. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/duration.rb +91 -0
  17. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/empty.rb +29 -0
  18. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/field_mask.rb +230 -0
  19. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/timestamp.rb +109 -0
  20. data/lib/google/cloud/scheduler/v1beta1/doc/google/rpc/status.rb +84 -0
  21. data/lib/google/cloud/scheduler/v1beta1/helpers.rb +48 -0
  22. data/lib/google/cloud/scheduler/v1beta1/job_pb.rb +56 -0
  23. data/lib/google/cloud/scheduler/v1beta1/target_pb.rb +58 -0
  24. metadata +149 -0
@@ -0,0 +1,609 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ # EDITING INSTRUCTIONS
16
+ # This file was generated from the file
17
+ # https://github.com/googleapis/googleapis/blob/master/google/cloud/scheduler/v1beta1/cloudscheduler.proto,
18
+ # and updates to that file get reflected here through a refresh process.
19
+ # For the short term, the refresh process will only be runnable by Google
20
+ # engineers.
21
+
22
+
23
+ require "json"
24
+ require "pathname"
25
+
26
+ require "google/gax"
27
+
28
+ require "google/cloud/scheduler/v1beta1/cloudscheduler_pb"
29
+ require "google/cloud/scheduler/v1beta1/credentials"
30
+
31
+ module Google
32
+ module Cloud
33
+ module Scheduler
34
+ module V1beta1
35
+ # The Cloud Scheduler API allows external entities to reliably
36
+ # schedule asynchronous jobs.
37
+ #
38
+ # @!attribute [r] cloud_scheduler_stub
39
+ # @return [Google::Cloud::Scheduler::V1beta1::CloudScheduler::Stub]
40
+ class CloudSchedulerClient
41
+ # @private
42
+ attr_reader :cloud_scheduler_stub
43
+
44
+ # The default address of the service.
45
+ SERVICE_ADDRESS = "cloudscheduler.googleapis.com".freeze
46
+
47
+ # The default port of the service.
48
+ DEFAULT_SERVICE_PORT = 443
49
+
50
+ # The default set of gRPC interceptors.
51
+ GRPC_INTERCEPTORS = []
52
+
53
+ DEFAULT_TIMEOUT = 30
54
+
55
+ PAGE_DESCRIPTORS = {
56
+ "list_jobs" => Google::Gax::PageDescriptor.new(
57
+ "page_token",
58
+ "next_page_token",
59
+ "jobs")
60
+ }.freeze
61
+
62
+ private_constant :PAGE_DESCRIPTORS
63
+
64
+ # The scopes needed to make gRPC calls to all of the methods defined in
65
+ # this service.
66
+ ALL_SCOPES = [
67
+ "https://www.googleapis.com/auth/cloud-platform"
68
+ ].freeze
69
+
70
+
71
+ PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
72
+ "projects/{project}"
73
+ )
74
+
75
+ private_constant :PROJECT_PATH_TEMPLATE
76
+
77
+ LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
78
+ "projects/{project}/locations/{location}"
79
+ )
80
+
81
+ private_constant :LOCATION_PATH_TEMPLATE
82
+
83
+ JOB_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
84
+ "projects/{project}/locations/{location}/jobs/{job}"
85
+ )
86
+
87
+ private_constant :JOB_PATH_TEMPLATE
88
+
89
+ # Returns a fully-qualified project resource name string.
90
+ # @param project [String]
91
+ # @return [String]
92
+ def self.project_path project
93
+ PROJECT_PATH_TEMPLATE.render(
94
+ :"project" => project
95
+ )
96
+ end
97
+
98
+ # Returns a fully-qualified location resource name string.
99
+ # @param project [String]
100
+ # @param location [String]
101
+ # @return [String]
102
+ def self.location_path project, location
103
+ LOCATION_PATH_TEMPLATE.render(
104
+ :"project" => project,
105
+ :"location" => location
106
+ )
107
+ end
108
+
109
+ # Returns a fully-qualified job resource name string.
110
+ # @param project [String]
111
+ # @param location [String]
112
+ # @param job [String]
113
+ # @return [String]
114
+ def self.job_path project, location, job
115
+ JOB_PATH_TEMPLATE.render(
116
+ :"project" => project,
117
+ :"location" => location,
118
+ :"job" => job
119
+ )
120
+ end
121
+
122
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
123
+ # Provides the means for authenticating requests made by the client. This parameter can
124
+ # be many types.
125
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
126
+ # authenticating requests made by this client.
127
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
128
+ # credentials for this client.
129
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
130
+ # credentials for this client.
131
+ # A `GRPC::Core::Channel` will be used to make calls through.
132
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
133
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
134
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
135
+ # metadata for requests, generally, to give OAuth credentials.
136
+ # @param scopes [Array<String>]
137
+ # The OAuth scopes for this service. This parameter is ignored if
138
+ # an updater_proc is supplied.
139
+ # @param client_config [Hash]
140
+ # A Hash for call options for each method. See
141
+ # Google::Gax#construct_settings for the structure of
142
+ # this data. Falls back to the default config if not specified
143
+ # or the specified config is missing data points.
144
+ # @param timeout [Numeric]
145
+ # The default timeout, in seconds, for calls made through this client.
146
+ # @param metadata [Hash]
147
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
148
+ # @param exception_transformer [Proc]
149
+ # An optional proc that intercepts any exceptions raised during an API call to inject
150
+ # custom error handling.
151
+ def initialize \
152
+ credentials: nil,
153
+ scopes: ALL_SCOPES,
154
+ client_config: {},
155
+ timeout: DEFAULT_TIMEOUT,
156
+ metadata: nil,
157
+ exception_transformer: nil,
158
+ lib_name: nil,
159
+ lib_version: ""
160
+ # These require statements are intentionally placed here to initialize
161
+ # the gRPC module only when it's required.
162
+ # See https://github.com/googleapis/toolkit/issues/446
163
+ require "google/gax/grpc"
164
+ require "google/cloud/scheduler/v1beta1/cloudscheduler_services_pb"
165
+
166
+ credentials ||= Google::Cloud::Scheduler::V1beta1::Credentials.default
167
+
168
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
169
+ updater_proc = Google::Cloud::Scheduler::V1beta1::Credentials.new(credentials).updater_proc
170
+ end
171
+ if credentials.is_a?(GRPC::Core::Channel)
172
+ channel = credentials
173
+ end
174
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
175
+ chan_creds = credentials
176
+ end
177
+ if credentials.is_a?(Proc)
178
+ updater_proc = credentials
179
+ end
180
+ if credentials.is_a?(Google::Auth::Credentials)
181
+ updater_proc = credentials.updater_proc
182
+ end
183
+
184
+ package_version = Gem.loaded_specs['google-cloud-scheduler'].version.version
185
+
186
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
187
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
188
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
189
+ google_api_client << " grpc/#{GRPC::VERSION}"
190
+ google_api_client.freeze
191
+
192
+ headers = { :"x-goog-api-client" => google_api_client }
193
+ headers.merge!(metadata) unless metadata.nil?
194
+ client_config_file = Pathname.new(__dir__).join(
195
+ "cloud_scheduler_client_config.json"
196
+ )
197
+ defaults = client_config_file.open do |f|
198
+ Google::Gax.construct_settings(
199
+ "google.cloud.scheduler.v1beta1.CloudScheduler",
200
+ JSON.parse(f.read),
201
+ client_config,
202
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
203
+ timeout,
204
+ page_descriptors: PAGE_DESCRIPTORS,
205
+ errors: Google::Gax::Grpc::API_ERRORS,
206
+ metadata: headers
207
+ )
208
+ end
209
+
210
+ # Allow overriding the service path/port in subclasses.
211
+ service_path = self.class::SERVICE_ADDRESS
212
+ port = self.class::DEFAULT_SERVICE_PORT
213
+ interceptors = self.class::GRPC_INTERCEPTORS
214
+ @cloud_scheduler_stub = Google::Gax::Grpc.create_stub(
215
+ service_path,
216
+ port,
217
+ chan_creds: chan_creds,
218
+ channel: channel,
219
+ updater_proc: updater_proc,
220
+ scopes: scopes,
221
+ interceptors: interceptors,
222
+ &Google::Cloud::Scheduler::V1beta1::CloudScheduler::Stub.method(:new)
223
+ )
224
+
225
+ @list_jobs = Google::Gax.create_api_call(
226
+ @cloud_scheduler_stub.method(:list_jobs),
227
+ defaults["list_jobs"],
228
+ exception_transformer: exception_transformer
229
+ )
230
+ @get_job = Google::Gax.create_api_call(
231
+ @cloud_scheduler_stub.method(:get_job),
232
+ defaults["get_job"],
233
+ exception_transformer: exception_transformer
234
+ )
235
+ @create_job = Google::Gax.create_api_call(
236
+ @cloud_scheduler_stub.method(:create_job),
237
+ defaults["create_job"],
238
+ exception_transformer: exception_transformer
239
+ )
240
+ @update_job = Google::Gax.create_api_call(
241
+ @cloud_scheduler_stub.method(:update_job),
242
+ defaults["update_job"],
243
+ exception_transformer: exception_transformer
244
+ )
245
+ @delete_job = Google::Gax.create_api_call(
246
+ @cloud_scheduler_stub.method(:delete_job),
247
+ defaults["delete_job"],
248
+ exception_transformer: exception_transformer
249
+ )
250
+ @pause_job = Google::Gax.create_api_call(
251
+ @cloud_scheduler_stub.method(:pause_job),
252
+ defaults["pause_job"],
253
+ exception_transformer: exception_transformer
254
+ )
255
+ @resume_job = Google::Gax.create_api_call(
256
+ @cloud_scheduler_stub.method(:resume_job),
257
+ defaults["resume_job"],
258
+ exception_transformer: exception_transformer
259
+ )
260
+ @run_job = Google::Gax.create_api_call(
261
+ @cloud_scheduler_stub.method(:run_job),
262
+ defaults["run_job"],
263
+ exception_transformer: exception_transformer
264
+ )
265
+ end
266
+
267
+ # Service calls
268
+
269
+ # Lists jobs.
270
+ #
271
+ # @param parent [String]
272
+ # Required.
273
+ #
274
+ # The location name. For example:
275
+ # `projects/PROJECT_ID/locations/LOCATION_ID`.
276
+ # @param page_size [Integer]
277
+ # The maximum number of resources contained in the underlying API
278
+ # response. If page streaming is performed per-resource, this
279
+ # parameter does not affect the return value. If page streaming is
280
+ # performed per-page, this determines the maximum number of
281
+ # resources in a page.
282
+ # @param options [Google::Gax::CallOptions]
283
+ # Overrides the default settings for this call, e.g, timeout,
284
+ # retries, etc.
285
+ # @yield [result, operation] Access the result along with the RPC operation
286
+ # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Scheduler::V1beta1::Job>]
287
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
288
+ # @return [Google::Gax::PagedEnumerable<Google::Cloud::Scheduler::V1beta1::Job>]
289
+ # An enumerable of Google::Cloud::Scheduler::V1beta1::Job instances.
290
+ # See Google::Gax::PagedEnumerable documentation for other
291
+ # operations such as per-page iteration or access to the response
292
+ # object.
293
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
294
+ # @example
295
+ # require "google/cloud/scheduler"
296
+ #
297
+ # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1beta1)
298
+ # formatted_parent = Google::Cloud::Scheduler::V1beta1::CloudSchedulerClient.location_path("[PROJECT]", "[LOCATION]")
299
+ #
300
+ # # Iterate over all results.
301
+ # cloud_scheduler_client.list_jobs(formatted_parent).each do |element|
302
+ # # Process element.
303
+ # end
304
+ #
305
+ # # Or iterate over results one page at a time.
306
+ # cloud_scheduler_client.list_jobs(formatted_parent).each_page do |page|
307
+ # # Process each page at a time.
308
+ # page.each do |element|
309
+ # # Process element.
310
+ # end
311
+ # end
312
+
313
+ def list_jobs \
314
+ parent,
315
+ page_size: nil,
316
+ options: nil,
317
+ &block
318
+ req = {
319
+ parent: parent,
320
+ page_size: page_size
321
+ }.delete_if { |_, v| v.nil? }
322
+ req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1beta1::ListJobsRequest)
323
+ @list_jobs.call(req, options, &block)
324
+ end
325
+
326
+ # Gets a job.
327
+ #
328
+ # @param name [String]
329
+ # Required.
330
+ #
331
+ # The job name. For example:
332
+ # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
333
+ # @param options [Google::Gax::CallOptions]
334
+ # Overrides the default settings for this call, e.g, timeout,
335
+ # retries, etc.
336
+ # @yield [result, operation] Access the result along with the RPC operation
337
+ # @yieldparam result [Google::Cloud::Scheduler::V1beta1::Job]
338
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
339
+ # @return [Google::Cloud::Scheduler::V1beta1::Job]
340
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
341
+ # @example
342
+ # require "google/cloud/scheduler"
343
+ #
344
+ # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1beta1)
345
+ # formatted_name = Google::Cloud::Scheduler::V1beta1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
346
+ # response = cloud_scheduler_client.get_job(formatted_name)
347
+
348
+ def get_job \
349
+ name,
350
+ options: nil,
351
+ &block
352
+ req = {
353
+ name: name
354
+ }.delete_if { |_, v| v.nil? }
355
+ req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1beta1::GetJobRequest)
356
+ @get_job.call(req, options, &block)
357
+ end
358
+
359
+ # Creates a job.
360
+ #
361
+ # @param parent [String]
362
+ # Required.
363
+ #
364
+ # The location name. For example:
365
+ # `projects/PROJECT_ID/locations/LOCATION_ID`.
366
+ # @param job [Google::Cloud::Scheduler::V1beta1::Job | Hash]
367
+ # Required.
368
+ #
369
+ # The job to add. The user can optionally specify a name for the
370
+ # job in {Google::Cloud::Scheduler::V1beta1::Job#name name}. {Google::Cloud::Scheduler::V1beta1::Job#name name} cannot be the same as an
371
+ # existing job. If a name is not specified then the system will
372
+ # generate a random unique name that will be returned
373
+ # ({Google::Cloud::Scheduler::V1beta1::Job#name name}) in the response.
374
+ # A hash of the same form as `Google::Cloud::Scheduler::V1beta1::Job`
375
+ # can also be provided.
376
+ # @param options [Google::Gax::CallOptions]
377
+ # Overrides the default settings for this call, e.g, timeout,
378
+ # retries, etc.
379
+ # @yield [result, operation] Access the result along with the RPC operation
380
+ # @yieldparam result [Google::Cloud::Scheduler::V1beta1::Job]
381
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
382
+ # @return [Google::Cloud::Scheduler::V1beta1::Job]
383
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
384
+ # @example
385
+ # require "google/cloud/scheduler"
386
+ #
387
+ # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1beta1)
388
+ # formatted_parent = Google::Cloud::Scheduler::V1beta1::CloudSchedulerClient.location_path("[PROJECT]", "[LOCATION]")
389
+ #
390
+ # # TODO: Initialize `job`:
391
+ # job = {}
392
+ # response = cloud_scheduler_client.create_job(formatted_parent, job)
393
+
394
+ def create_job \
395
+ parent,
396
+ job,
397
+ options: nil,
398
+ &block
399
+ req = {
400
+ parent: parent,
401
+ job: job
402
+ }.delete_if { |_, v| v.nil? }
403
+ req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1beta1::CreateJobRequest)
404
+ @create_job.call(req, options, &block)
405
+ end
406
+
407
+ # Updates a job.
408
+ #
409
+ # If successful, the updated {Google::Cloud::Scheduler::V1beta1::Job Job} is returned. If the job does
410
+ # not exist, `NOT_FOUND` is returned.
411
+ #
412
+ # If UpdateJob does not successfully return, it is possible for the
413
+ # job to be in an {Google::Cloud::Scheduler::V1beta1::Job::State::UPDATE_FAILED Job::State::UPDATE_FAILED} state. A job in this state may
414
+ # not be executed. If this happens, retry the UpdateJob request
415
+ # until a successful response is received.
416
+ #
417
+ # @param job [Google::Cloud::Scheduler::V1beta1::Job | Hash]
418
+ # Required.
419
+ #
420
+ # The new job properties. {Google::Cloud::Scheduler::V1beta1::Job#name name} must be specified.
421
+ #
422
+ # Output only fields cannot be modified using UpdateJob.
423
+ # Any value specified for an output only field will be ignored.
424
+ # A hash of the same form as `Google::Cloud::Scheduler::V1beta1::Job`
425
+ # can also be provided.
426
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
427
+ # A mask used to specify which fields of the job are being updated.
428
+ # A hash of the same form as `Google::Protobuf::FieldMask`
429
+ # can also be provided.
430
+ # @param options [Google::Gax::CallOptions]
431
+ # Overrides the default settings for this call, e.g, timeout,
432
+ # retries, etc.
433
+ # @yield [result, operation] Access the result along with the RPC operation
434
+ # @yieldparam result [Google::Cloud::Scheduler::V1beta1::Job]
435
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
436
+ # @return [Google::Cloud::Scheduler::V1beta1::Job]
437
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
438
+ # @example
439
+ # require "google/cloud/scheduler"
440
+ #
441
+ # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1beta1)
442
+ #
443
+ # # TODO: Initialize `job`:
444
+ # job = {}
445
+ # response = cloud_scheduler_client.update_job(job)
446
+
447
+ def update_job \
448
+ job,
449
+ update_mask: nil,
450
+ options: nil,
451
+ &block
452
+ req = {
453
+ job: job,
454
+ update_mask: update_mask
455
+ }.delete_if { |_, v| v.nil? }
456
+ req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1beta1::UpdateJobRequest)
457
+ @update_job.call(req, options, &block)
458
+ end
459
+
460
+ # Deletes a job.
461
+ #
462
+ # @param name [String]
463
+ # Required.
464
+ #
465
+ # The job name. For example:
466
+ # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
467
+ # @param options [Google::Gax::CallOptions]
468
+ # Overrides the default settings for this call, e.g, timeout,
469
+ # retries, etc.
470
+ # @yield [result, operation] Access the result along with the RPC operation
471
+ # @yieldparam result []
472
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
473
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
474
+ # @example
475
+ # require "google/cloud/scheduler"
476
+ #
477
+ # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1beta1)
478
+ # formatted_name = Google::Cloud::Scheduler::V1beta1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
479
+ # cloud_scheduler_client.delete_job(formatted_name)
480
+
481
+ def delete_job \
482
+ name,
483
+ options: nil,
484
+ &block
485
+ req = {
486
+ name: name
487
+ }.delete_if { |_, v| v.nil? }
488
+ req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1beta1::DeleteJobRequest)
489
+ @delete_job.call(req, options, &block)
490
+ nil
491
+ end
492
+
493
+ # Pauses a job.
494
+ #
495
+ # If a job is paused then the system will stop executing the job
496
+ # until it is re-enabled via {Google::Cloud::Scheduler::V1beta1::CloudScheduler::ResumeJob ResumeJob}. The
497
+ # state of the job is stored in {Google::Cloud::Scheduler::V1beta1::Job#state state}; if paused it
498
+ # will be set to {Google::Cloud::Scheduler::V1beta1::Job::State::PAUSED Job::State::PAUSED}. A job must be in {Google::Cloud::Scheduler::V1beta1::Job::State::ENABLED Job::State::ENABLED}
499
+ # to be paused.
500
+ #
501
+ # @param name [String]
502
+ # Required.
503
+ #
504
+ # The job name. For example:
505
+ # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
506
+ # @param options [Google::Gax::CallOptions]
507
+ # Overrides the default settings for this call, e.g, timeout,
508
+ # retries, etc.
509
+ # @yield [result, operation] Access the result along with the RPC operation
510
+ # @yieldparam result [Google::Cloud::Scheduler::V1beta1::Job]
511
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
512
+ # @return [Google::Cloud::Scheduler::V1beta1::Job]
513
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
514
+ # @example
515
+ # require "google/cloud/scheduler"
516
+ #
517
+ # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1beta1)
518
+ # formatted_name = Google::Cloud::Scheduler::V1beta1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
519
+ # response = cloud_scheduler_client.pause_job(formatted_name)
520
+
521
+ def pause_job \
522
+ name,
523
+ options: nil,
524
+ &block
525
+ req = {
526
+ name: name
527
+ }.delete_if { |_, v| v.nil? }
528
+ req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1beta1::PauseJobRequest)
529
+ @pause_job.call(req, options, &block)
530
+ end
531
+
532
+ # Resume a job.
533
+ #
534
+ # This method reenables a job after it has been {Google::Cloud::Scheduler::V1beta1::Job::State::PAUSED Job::State::PAUSED}. The
535
+ # state of a job is stored in {Google::Cloud::Scheduler::V1beta1::Job#state Job#state}; after calling this method it
536
+ # will be set to {Google::Cloud::Scheduler::V1beta1::Job::State::ENABLED Job::State::ENABLED}. A job must be in
537
+ # {Google::Cloud::Scheduler::V1beta1::Job::State::PAUSED Job::State::PAUSED} to be resumed.
538
+ #
539
+ # @param name [String]
540
+ # Required.
541
+ #
542
+ # The job name. For example:
543
+ # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
544
+ # @param options [Google::Gax::CallOptions]
545
+ # Overrides the default settings for this call, e.g, timeout,
546
+ # retries, etc.
547
+ # @yield [result, operation] Access the result along with the RPC operation
548
+ # @yieldparam result [Google::Cloud::Scheduler::V1beta1::Job]
549
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
550
+ # @return [Google::Cloud::Scheduler::V1beta1::Job]
551
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
552
+ # @example
553
+ # require "google/cloud/scheduler"
554
+ #
555
+ # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1beta1)
556
+ # formatted_name = Google::Cloud::Scheduler::V1beta1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
557
+ # response = cloud_scheduler_client.resume_job(formatted_name)
558
+
559
+ def resume_job \
560
+ name,
561
+ options: nil,
562
+ &block
563
+ req = {
564
+ name: name
565
+ }.delete_if { |_, v| v.nil? }
566
+ req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1beta1::ResumeJobRequest)
567
+ @resume_job.call(req, options, &block)
568
+ end
569
+
570
+ # Forces a job to run now.
571
+ #
572
+ # When this method is called, Cloud Scheduler will dispatch the job, even
573
+ # if the job is already running.
574
+ #
575
+ # @param name [String]
576
+ # Required.
577
+ #
578
+ # The job name. For example:
579
+ # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
580
+ # @param options [Google::Gax::CallOptions]
581
+ # Overrides the default settings for this call, e.g, timeout,
582
+ # retries, etc.
583
+ # @yield [result, operation] Access the result along with the RPC operation
584
+ # @yieldparam result [Google::Cloud::Scheduler::V1beta1::Job]
585
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
586
+ # @return [Google::Cloud::Scheduler::V1beta1::Job]
587
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
588
+ # @example
589
+ # require "google/cloud/scheduler"
590
+ #
591
+ # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1beta1)
592
+ # formatted_name = Google::Cloud::Scheduler::V1beta1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
593
+ # response = cloud_scheduler_client.run_job(formatted_name)
594
+
595
+ def run_job \
596
+ name,
597
+ options: nil,
598
+ &block
599
+ req = {
600
+ name: name
601
+ }.delete_if { |_, v| v.nil? }
602
+ req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1beta1::RunJobRequest)
603
+ @run_job.call(req, options, &block)
604
+ end
605
+ end
606
+ end
607
+ end
608
+ end
609
+ end