Batch V1 API - Class Google::Cloud::Batch::V1::BatchService::Rest::Client (v0.18.0)

Reference documentation and code samples for the Batch V1 API class Google::Cloud::Batch::V1::BatchService::Rest::Client.

REST client for the BatchService service.

Google Batch Service. The service manages user submitted batch jobs and allocates Google Compute Engine VM instances to run the jobs.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the BatchService Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all BatchService clients
::Google::Cloud::Batch::V1::BatchService::Rest::Client.configure do |config|
  config.timeout = 10.0
end

#configure

def configure() { |config| ... } -> Client::Configuration

Configure the BatchService 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 Client.configure.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#create_job

def create_job(request, options = nil) -> ::Google::Cloud::Batch::V1::Job
def create_job(parent: nil, job_id: nil, job: nil, request_id: nil) -> ::Google::Cloud::Batch::V1::Job

Create a Job.

Overloads
def create_job(request, options = nil) -> ::Google::Cloud::Batch::V1::Job
Pass arguments to create_job via a request object, either of type CreateJobRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Batch::V1::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) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def create_job(parent: nil, job_id: nil, job: nil, request_id: nil) -> ::Google::Cloud::Batch::V1::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) — Required. The parent resource name where the Job will be created. Pattern: "projects/{project}/locations/{location}"
  • job_id (::String) — ID used to uniquely identify the Job within its parent scope. This field should contain at most 63 characters and must start with lowercase characters. Only lowercase characters, numbers and '-' are accepted. The '-' character cannot be the first or the last one. A system generated ID will be used if the field is not set.

    The job.name field in the request will be ignored and the created resource name of the Job will be "{parent}/jobs/{job_id}".

  • job (::Google::Cloud::Batch::V1::Job, ::Hash) — Required. The Job to create.
  • request_id (::String) — Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request.

    For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments.

    The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).

Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/batch/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Batch::V1::BatchService::Rest::Client.new

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

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

# The returned object is of type Google::Cloud::Batch::V1::Job.
p result

#delete_job

def delete_job(request, options = nil) -> ::Gapic::Operation
def delete_job(name: nil, reason: nil, request_id: nil) -> ::Gapic::Operation

Delete a Job.

Overloads
def delete_job(request, options = nil) -> ::Gapic::Operation
Pass arguments to delete_job via a request object, either of type DeleteJobRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Batch::V1::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) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def delete_job(name: nil, reason: nil, request_id: nil) -> ::Gapic::Operation
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) — Job name.
  • reason (::String) — Optional. Reason for this deletion.
  • request_id (::String) — Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes after the first request.

    For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments.

    The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).

Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/batch/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Batch::V1::BatchService::Rest::Client.new

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

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

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#get_job

def get_job(request, options = nil) -> ::Google::Cloud::Batch::V1::Job
def get_job(name: nil) -> ::Google::Cloud::Batch::V1::Job

Get a Job specified by its resource name.

Overloads
def get_job(request, options = nil) -> ::Google::Cloud::Batch::V1::Job
Pass arguments to get_job via a request object, either of type GetJobRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Batch::V1::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) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def get_job(name: nil) -> ::Google::Cloud::Batch::V1::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).
Parameter
  • name (::String) — Required. Job name.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/batch/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Batch::V1::BatchService::Rest::Client.new

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

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

# The returned object is of type Google::Cloud::Batch::V1::Job.
p result

#get_task

def get_task(request, options = nil) -> ::Google::Cloud::Batch::V1::Task
def get_task(name: nil) -> ::Google::Cloud::Batch::V1::Task

Return a single Task.

Overloads
def get_task(request, options = nil) -> ::Google::Cloud::Batch::V1::Task
Pass arguments to get_task via a request object, either of type GetTaskRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Batch::V1::GetTaskRequest, ::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) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def get_task(name: nil) -> ::Google::Cloud::Batch::V1::Task
Pass arguments to get_task 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).
Parameter
  • name (::String) — Required. Task name.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/batch/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Batch::V1::BatchService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Batch::V1::GetTaskRequest.new

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

# The returned object is of type Google::Cloud::Batch::V1::Task.
p result

#initialize

def initialize() { |config| ... } -> Client

Create a new BatchService REST client object.

Yields
  • (config) — Configure the BatchService client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::Batch::V1::BatchService::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Batch::V1::BatchService::Rest::Client.new do |config|
  config.timeout = 10.0
end

#list_jobs

def list_jobs(request, options = nil) -> ::Google::Cloud::Batch::V1::ListJobsResponse
def list_jobs(parent: nil, filter: nil, order_by: nil, page_size: nil, page_token: nil) -> ::Google::Cloud::Batch::V1::ListJobsResponse

List all Jobs for a project within a region.

Overloads
def list_jobs(request, options = nil) -> ::Google::Cloud::Batch::V1::ListJobsResponse
Pass arguments to list_jobs via a request object, either of type ListJobsRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Batch::V1::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) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def list_jobs(parent: nil, filter: nil, order_by: nil, page_size: nil, page_token: nil) -> ::Google::Cloud::Batch::V1::ListJobsResponse
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) — Parent path.
  • filter (::String) — List filter.
  • order_by (::String) — Optional. Sort results. Supported are "name", "name desc", "create_time", and "create_time desc".
  • page_size (::Integer) — Page size.
  • page_token (::String) — Page token.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/batch/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Batch::V1::BatchService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Batch::V1::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::Batch::V1::Job.
  p item
end

#list_tasks

def list_tasks(request, options = nil) -> ::Google::Cloud::Batch::V1::ListTasksResponse
def list_tasks(parent: nil, filter: nil, page_size: nil, page_token: nil) -> ::Google::Cloud::Batch::V1::ListTasksResponse

List Tasks associated with a job.

Overloads
def list_tasks(request, options = nil) -> ::Google::Cloud::Batch::V1::ListTasksResponse
Pass arguments to list_tasks via a request object, either of type ListTasksRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Batch::V1::ListTasksRequest, ::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) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def list_tasks(parent: nil, filter: nil, page_size: nil, page_token: nil) -> ::Google::Cloud::Batch::V1::ListTasksResponse
Pass arguments to list_tasks 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) — Required. Name of a TaskGroup from which Tasks are being requested. Pattern: "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}"
  • filter (::String) — Task filter, null filter matches all Tasks. Filter string should be of the format State=TaskStatus.State e.g. State=RUNNING
  • page_size (::Integer) — Page size.
  • page_token (::String) — Page token.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/batch/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Batch::V1::BatchService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Batch::V1::ListTasksRequest.new

# Call the list_tasks method.
result = client.list_tasks 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::Batch::V1::Task.
  p item
end

#location_client

def location_client() -> Google::Cloud::Location::Locations::Rest::Client

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

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

#operations_client

def operations_client() -> ::Google::Cloud::Batch::V1::BatchService::Rest::Operations

Get the associated client for long-running operations.

#universe_domain

def universe_domain() -> String

The effective universe domain

Returns
  • (String)