Class: Google::Cloud::Scheduler::V1beta1::CloudScheduler::Rest::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb

Overview

REST client for the CloudScheduler service.

The Cloud Scheduler API allows external entities to reliably schedule asynchronous jobs.

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#job_path, #location_path, #topic_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new CloudScheduler REST client object.

Examples:


# Create a client using the default configuration
client = ::Google::Cloud::Scheduler::V1beta1::CloudScheduler::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Scheduler::V1beta1::CloudScheduler::Rest::Client.new do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the CloudScheduler client.

Yield Parameters:



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb', line 159

def initialize
  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint.nil? ||
                           (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
                           !@config.endpoint.split(".").first.include?("-"))
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end

  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @cloud_scheduler_stub = ::Google::Cloud::Scheduler::V1beta1::CloudScheduler::Rest::ServiceStub.new(
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    credentials: credentials
  )

  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @cloud_scheduler_stub.endpoint
    config.universe_domain = @cloud_scheduler_stub.universe_domain
    config.bindings_override = @config.bindings_override
  end
end

Instance Attribute Details

#location_clientGoogle::Cloud::Location::Locations::Rest::Client (readonly)

Get the associated client for mix-in of the Locations.

Returns:

  • (Google::Cloud::Location::Locations::Rest::Client)


203
204
205
# File 'lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb', line 203

def location_client
  @location_client
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the CloudScheduler Client class.

See Configuration for a description of the configuration fields.

Examples:


# Modify the configuration for all CloudScheduler clients
::Google::Cloud::Scheduler::V1beta1::CloudScheduler::Rest::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb', line 66

def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "Scheduler", "V1beta1"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.rpcs.list_jobs.timeout = 600.0
    default_config.rpcs.list_jobs.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_job.timeout = 600.0
    default_config.rpcs.get_job.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.create_job.timeout = 600.0

    default_config.rpcs.update_job.timeout = 600.0

    default_config.rpcs.delete_job.timeout = 600.0
    default_config.rpcs.delete_job.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.pause_job.timeout = 600.0
    default_config.rpcs.pause_job.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.resume_job.timeout = 600.0
    default_config.rpcs.resume_job.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.run_job.timeout = 600.0

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#configure {|config| ... } ⇒ Client::Configuration

Configure the CloudScheduler Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



129
130
131
132
# File 'lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb', line 129

def configure
  yield @config if block_given?
  @config
end

#create_job(request, options = nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job #create_job(parent: nil, job: nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

Creates a job.

Examples:

Basic example

require "google/cloud/scheduler/v1beta1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Scheduler::V1beta1::CloudScheduler::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Scheduler::V1beta1::CreateJobRequest.new

# Call the create_job method.
result = client.create_job request

# The returned object is of type Google::Cloud::Scheduler::V1beta1::Job.
p result

Overloads:

  • #create_job(request, options = nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

    Pass arguments to create_job via a request object, either of type Google::Cloud::Scheduler::V1beta1::CreateJobRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Scheduler::V1beta1::CreateJobRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #create_job(parent: nil, job: nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

    Pass arguments to create_job via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The location name. For example: projects/PROJECT_ID/locations/LOCATION_ID.

    • job (::Google::Cloud::Scheduler::V1beta1::Job, ::Hash) (defaults to: nil)

      Required. The job to add. The user can optionally specify a name for the job in name. name cannot be the same as an existing job. If a name is not specified then the system will generate a random unique name that will be returned (name) in the response.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb', line 454

def create_job request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1beta1::CreateJobRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_job..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Scheduler::V1beta1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.create_job.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_job.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_scheduler_stub.create_job request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_job(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_job(name: nil, legacy_app_engine_cron: nil) ⇒ ::Google::Protobuf::Empty

Deletes a job.

Examples:

Basic example

require "google/cloud/scheduler/v1beta1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Scheduler::V1beta1::CloudScheduler::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Scheduler::V1beta1::DeleteJobRequest.new

# Call the delete_job method.
result = client.delete_job request

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #delete_job(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_job via a request object, either of type DeleteJobRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Scheduler::V1beta1::DeleteJobRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #delete_job(name: nil, legacy_app_engine_cron: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_job via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

    • legacy_app_engine_cron (::Boolean) (defaults to: nil)

      This field is used to manage the legacy App Engine Cron jobs using the Cloud Scheduler API. If the field is set to true, the job in the __cron queue with the corresponding name will be deleted instead.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
# File 'lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb', line 632

def delete_job request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1beta1::DeleteJobRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_job..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Scheduler::V1beta1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.delete_job.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_job.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_scheduler_stub.delete_job request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_job(request, options = nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job #get_job(name: nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

Gets a job.

Examples:

Basic example

require "google/cloud/scheduler/v1beta1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Scheduler::V1beta1::CloudScheduler::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Scheduler::V1beta1::GetJobRequest.new

# Call the get_job method.
result = client.get_job request

# The returned object is of type Google::Cloud::Scheduler::V1beta1::Job.
p result

Overloads:

  • #get_job(request, options = nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

    Pass arguments to get_job via a request object, either of type GetJobRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Scheduler::V1beta1::GetJobRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_job(name: nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

    Pass arguments to get_job via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# File 'lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb', line 367

def get_job request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1beta1::GetJobRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_job..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Scheduler::V1beta1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.get_job.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_job.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_scheduler_stub.get_job request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_jobs(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Scheduler::V1beta1::Job> #list_jobs(parent: nil, filter: nil, page_size: nil, page_token: nil, legacy_app_engine_cron: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Scheduler::V1beta1::Job>

Lists jobs.

Examples:

Basic example

require "google/cloud/scheduler/v1beta1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Scheduler::V1beta1::CloudScheduler::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Scheduler::V1beta1::ListJobsRequest.new

# Call the list_jobs method.
result = client.list_jobs request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Scheduler::V1beta1::Job.
  p item
end

Overloads:

  • #list_jobs(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Scheduler::V1beta1::Job>

    Pass arguments to list_jobs via a request object, either of type ListJobsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Scheduler::V1beta1::ListJobsRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_jobs(parent: nil, filter: nil, page_size: nil, page_token: nil, legacy_app_engine_cron: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Scheduler::V1beta1::Job>

    Pass arguments to list_jobs via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The location name. For example: projects/PROJECT_ID/locations/LOCATION_ID.

    • filter (::String) (defaults to: nil)

      filter can be used to specify a subset of jobs.

      If filter equals target_config="HttpConfig", then the http target jobs are retrieved. If filter equals target_config="PubSubConfig", then the Pub/Sub target jobs are retrieved. If filter equals labels.foo=value1 labels.foo=value2 then only jobs which are labeled with foo=value1 AND foo=value2 will be returned.

    • page_size (::Integer) (defaults to: nil)

      Requested page size.

      The maximum page size is 500. If unspecified, the page size will be the maximum. Fewer jobs than requested might be returned, even if more jobs exist; use next_page_token to determine if more jobs exist.

    • page_token (::String) (defaults to: nil)

      A token identifying a page of results the server will return. To request the first page results, page_token must be empty. To request the next page of results, page_token must be the value of next_page_token returned from the previous call to ListJobs. It is an error to switch the value of filter or [order_by][google.cloud.scheduler.v1beta1.ListJobsRequest.order_by] while iterating through pages.

    • legacy_app_engine_cron (::Boolean) (defaults to: nil)

      This field is used to manage the legacy App Engine Cron jobs using the Cloud Scheduler API. If the field is set to true, the jobs in the __cron queue will be listed instead.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb', line 286

def list_jobs request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1beta1::ListJobsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_jobs..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Scheduler::V1beta1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.list_jobs.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_jobs.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_scheduler_stub.list_jobs request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @cloud_scheduler_stub, :list_jobs, "jobs", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#pause_job(request, options = nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job #pause_job(name: nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

Pauses a job.

If a job is paused then the system will stop executing the job until it is re-enabled via ResumeJob. The state of the job is stored in state; if paused it will be set to Job.State.PAUSED. A job must be in Job.State.ENABLED to be paused.

Examples:

Basic example

require "google/cloud/scheduler/v1beta1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Scheduler::V1beta1::CloudScheduler::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Scheduler::V1beta1::PauseJobRequest.new

# Call the pause_job method.
result = client.pause_job request

# The returned object is of type Google::Cloud::Scheduler::V1beta1::Job.
p result

Overloads:

  • #pause_job(request, options = nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

    Pass arguments to pause_job via a request object, either of type PauseJobRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Scheduler::V1beta1::PauseJobRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #pause_job(name: nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

    Pass arguments to pause_job via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
# File 'lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb', line 722

def pause_job request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1beta1::PauseJobRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.pause_job..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Scheduler::V1beta1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.pause_job.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.pause_job.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_scheduler_stub.pause_job request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#resume_job(request, options = nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job #resume_job(name: nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

Resume a job.

This method reenables a job after it has been Job.State.PAUSED. The state of a job is stored in Job.state; after calling this method it will be set to Job.State.ENABLED. A job must be in Job.State.PAUSED to be resumed.

Examples:

Basic example

require "google/cloud/scheduler/v1beta1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Scheduler::V1beta1::CloudScheduler::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Scheduler::V1beta1::ResumeJobRequest.new

# Call the resume_job method.
result = client.resume_job request

# The returned object is of type Google::Cloud::Scheduler::V1beta1::Job.
p result

Overloads:

  • #resume_job(request, options = nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

    Pass arguments to resume_job via a request object, either of type ResumeJobRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Scheduler::V1beta1::ResumeJobRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #resume_job(name: nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

    Pass arguments to resume_job via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
# File 'lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb', line 812

def resume_job request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1beta1::ResumeJobRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.resume_job..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Scheduler::V1beta1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.resume_job.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.resume_job.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_scheduler_stub.resume_job request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#run_job(request, options = nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job #run_job(name: nil, legacy_app_engine_cron: nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

Forces a job to run now.

When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.

Examples:

Basic example

require "google/cloud/scheduler/v1beta1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Scheduler::V1beta1::CloudScheduler::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Scheduler::V1beta1::RunJobRequest.new

# Call the run_job method.
result = client.run_job request

# The returned object is of type Google::Cloud::Scheduler::V1beta1::Job.
p result

Overloads:

  • #run_job(request, options = nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

    Pass arguments to run_job via a request object, either of type RunJobRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Scheduler::V1beta1::RunJobRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #run_job(name: nil, legacy_app_engine_cron: nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

    Pass arguments to run_job via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The job name. For example: projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID.

    • legacy_app_engine_cron (::Boolean) (defaults to: nil)

      This field is used to manage the legacy App Engine Cron jobs using the Cloud Scheduler API. If the field is set to true, the job in the __cron queue with the corresponding name will be forced to run instead.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
# File 'lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb', line 899

def run_job request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1beta1::RunJobRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.run_job..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Scheduler::V1beta1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.run_job.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.run_job.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_scheduler_stub.run_job request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


139
140
141
# File 'lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb', line 139

def universe_domain
  @cloud_scheduler_stub.universe_domain
end

#update_job(request, options = nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job #update_job(job: nil, update_mask: nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

Updates a job.

If successful, the updated Job is returned. If the job does not exist, NOT_FOUND is returned.

If UpdateJob does not successfully return, it is possible for the job to be in an Job.State.UPDATE_FAILED state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.

Examples:

Basic example

require "google/cloud/scheduler/v1beta1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Scheduler::V1beta1::CloudScheduler::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Scheduler::V1beta1::UpdateJobRequest.new

# Call the update_job method.
result = client.update_job request

# The returned object is of type Google::Cloud::Scheduler::V1beta1::Job.
p result

Overloads:

  • #update_job(request, options = nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

    Pass arguments to update_job via a request object, either of type UpdateJobRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Scheduler::V1beta1::UpdateJobRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_job(job: nil, update_mask: nil) ⇒ ::Google::Cloud::Scheduler::V1beta1::Job

    Pass arguments to update_job via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • job (::Google::Cloud::Scheduler::V1beta1::Job, ::Hash) (defaults to: nil)

      Required. The new job properties. name must be specified.

      Output only fields cannot be modified using UpdateJob. Any value specified for an output only field will be ignored.

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      A mask used to specify which fields of the job are being updated.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
# File 'lib/google/cloud/scheduler/v1beta1/cloud_scheduler/rest/client.rb', line 548

def update_job request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Scheduler::V1beta1::UpdateJobRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_job..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Scheduler::V1beta1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.update_job.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_job.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_scheduler_stub.update_job request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end