Cloud TPU V1 API - Class Google::Cloud::Tpu::V1::Tpu::Client (v0.2.0)

Reference documentation and code samples for the Cloud TPU V1 API class Google::Cloud::Tpu::V1::Tpu::Client.

Client for the Tpu service.

Manages TPU nodes and other resources

TPU API v1

Inherits

  • Object

Methods

.configure

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

Configure the Tpu 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 Tpu clients
::Google::Cloud::Tpu::V1::Tpu::Client.configure do |config|
  config.timeout = 10.0
end

#configure

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

Configure the Tpu 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_node

def create_node(request, options = nil) -> ::Gapic::Operation
def create_node(parent: nil, node_id: nil, node: nil) -> ::Gapic::Operation

Creates a node.

Overloads
def create_node(request, options = nil) -> ::Gapic::Operation
Pass arguments to create_node via a request object, either of type CreateNodeRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Tpu::V1::CreateNodeRequest, ::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_node(parent: nil, node_id: nil, node: nil) -> ::Gapic::Operation
Pass arguments to create_node 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.
  • node_id (::String) — The unqualified resource name.
  • node (::Google::Cloud::Tpu::V1::Node, ::Hash) — Required. The node.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/tpu/v1"

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

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

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

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

#delete_node

def delete_node(request, options = nil) -> ::Gapic::Operation
def delete_node(name: nil) -> ::Gapic::Operation

Deletes a node.

Overloads
def delete_node(request, options = nil) -> ::Gapic::Operation
Pass arguments to delete_node via a request object, either of type DeleteNodeRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Tpu::V1::DeleteNodeRequest, ::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_node(name: nil) -> ::Gapic::Operation
Pass arguments to delete_node 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. The resource name.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/tpu/v1"

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

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

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

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

#get_accelerator_type

def get_accelerator_type(request, options = nil) -> ::Google::Cloud::Tpu::V1::AcceleratorType
def get_accelerator_type(name: nil) -> ::Google::Cloud::Tpu::V1::AcceleratorType

Gets AcceleratorType.

Overloads
def get_accelerator_type(request, options = nil) -> ::Google::Cloud::Tpu::V1::AcceleratorType
Pass arguments to get_accelerator_type via a request object, either of type GetAcceleratorTypeRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Tpu::V1::GetAcceleratorTypeRequest, ::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_accelerator_type(name: nil) -> ::Google::Cloud::Tpu::V1::AcceleratorType
Pass arguments to get_accelerator_type 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. The resource name.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/tpu/v1"

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

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

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

# The returned object is of type Google::Cloud::Tpu::V1::AcceleratorType.
p result

#get_node

def get_node(request, options = nil) -> ::Google::Cloud::Tpu::V1::Node
def get_node(name: nil) -> ::Google::Cloud::Tpu::V1::Node

Gets the details of a node.

Overloads
def get_node(request, options = nil) -> ::Google::Cloud::Tpu::V1::Node
Pass arguments to get_node via a request object, either of type GetNodeRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Tpu::V1::GetNodeRequest, ::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_node(name: nil) -> ::Google::Cloud::Tpu::V1::Node
Pass arguments to get_node 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. The resource name.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/tpu/v1"

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

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

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

# The returned object is of type Google::Cloud::Tpu::V1::Node.
p result

#get_tensor_flow_version

def get_tensor_flow_version(request, options = nil) -> ::Google::Cloud::Tpu::V1::TensorFlowVersion
def get_tensor_flow_version(name: nil) -> ::Google::Cloud::Tpu::V1::TensorFlowVersion

Gets TensorFlow Version.

Overloads
def get_tensor_flow_version(request, options = nil) -> ::Google::Cloud::Tpu::V1::TensorFlowVersion
Pass arguments to get_tensor_flow_version via a request object, either of type GetTensorFlowVersionRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Tpu::V1::GetTensorFlowVersionRequest, ::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_tensor_flow_version(name: nil) -> ::Google::Cloud::Tpu::V1::TensorFlowVersion
Pass arguments to get_tensor_flow_version 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. The resource name.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/tpu/v1"

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

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

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

# The returned object is of type Google::Cloud::Tpu::V1::TensorFlowVersion.
p result

#initialize

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

Create a new Tpu client object.

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

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

#list_accelerator_types

def list_accelerator_types(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Tpu::V1::AcceleratorType>
def list_accelerator_types(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Tpu::V1::AcceleratorType>

Lists accelerator types supported by this API.

Overloads
def list_accelerator_types(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Tpu::V1::AcceleratorType>
Pass arguments to list_accelerator_types via a request object, either of type ListAcceleratorTypesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Tpu::V1::ListAcceleratorTypesRequest, ::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_accelerator_types(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Tpu::V1::AcceleratorType>
Pass arguments to list_accelerator_types 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.
  • page_size (::Integer) — The maximum number of items to return.
  • page_token (::String) — The next_page_token value returned from a previous List request, if any.
  • filter (::String) — List filter.
  • order_by (::String) — Sort results.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/tpu/v1"

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

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

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

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Tpu::V1::AcceleratorType.
  p response
end

#list_nodes

def list_nodes(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Tpu::V1::Node>
def list_nodes(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Tpu::V1::Node>

Lists nodes.

Overloads
def list_nodes(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Tpu::V1::Node>
Pass arguments to list_nodes via a request object, either of type ListNodesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Tpu::V1::ListNodesRequest, ::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_nodes(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Tpu::V1::Node>
Pass arguments to list_nodes 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.
  • page_size (::Integer) — The maximum number of items to return.
  • page_token (::String) — The next_page_token value returned from a previous List request, if any.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/tpu/v1"

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

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

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

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Tpu::V1::Node.
  p response
end

#list_tensor_flow_versions

def list_tensor_flow_versions(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Tpu::V1::TensorFlowVersion>
def list_tensor_flow_versions(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Tpu::V1::TensorFlowVersion>

List TensorFlow versions supported by this API.

Overloads
def list_tensor_flow_versions(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Tpu::V1::TensorFlowVersion>
Pass arguments to list_tensor_flow_versions via a request object, either of type ListTensorFlowVersionsRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Tpu::V1::ListTensorFlowVersionsRequest, ::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_tensor_flow_versions(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Tpu::V1::TensorFlowVersion>
Pass arguments to list_tensor_flow_versions 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.
  • page_size (::Integer) — The maximum number of items to return.
  • page_token (::String) — The next_page_token value returned from a previous List request, if any.
  • filter (::String) — List filter.
  • order_by (::String) — Sort results.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/tpu/v1"

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

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

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

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Tpu::V1::TensorFlowVersion.
  p response
end

#operations_client

def operations_client() -> ::Google::Cloud::Tpu::V1::Tpu::Operations

Get the associated client for long-running operations.

#reimage_node

def reimage_node(request, options = nil) -> ::Gapic::Operation
def reimage_node(name: nil, tensorflow_version: nil) -> ::Gapic::Operation

Reimages a node's OS.

Overloads
def reimage_node(request, options = nil) -> ::Gapic::Operation
Pass arguments to reimage_node via a request object, either of type ReimageNodeRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Tpu::V1::ReimageNodeRequest, ::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 reimage_node(name: nil, tensorflow_version: nil) -> ::Gapic::Operation
Pass arguments to reimage_node 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) — The resource name.
  • tensorflow_version (::String) — The version for reimage to create.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/tpu/v1"

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

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

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

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

#start_node

def start_node(request, options = nil) -> ::Gapic::Operation
def start_node(name: nil) -> ::Gapic::Operation

Starts a node.

Overloads
def start_node(request, options = nil) -> ::Gapic::Operation
Pass arguments to start_node via a request object, either of type StartNodeRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Tpu::V1::StartNodeRequest, ::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 start_node(name: nil) -> ::Gapic::Operation
Pass arguments to start_node 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) — The resource name.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/tpu/v1"

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

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

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

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

#stop_node

def stop_node(request, options = nil) -> ::Gapic::Operation
def stop_node(name: nil) -> ::Gapic::Operation

Stops a node.

Overloads
def stop_node(request, options = nil) -> ::Gapic::Operation
Pass arguments to stop_node via a request object, either of type StopNodeRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Tpu::V1::StopNodeRequest, ::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 stop_node(name: nil) -> ::Gapic::Operation
Pass arguments to stop_node 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) — The resource name.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/tpu/v1"

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

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

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

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