Cloud TPU API v1 - Package cloud.google.com/go/tpu/apiv1 (v1.8.4)

Note: To get more information about this package, such as access to older versions, viewthis package on pkg.go.dev.

Package tpu is an auto-generated package for theCloud TPU API.

TPU API provides customers with access to Google TPU technology.

General documentation

For information that is relevant for all client libraries please referencehttps://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on thispage includes:

Example usage

To get started with this package, create a client.

// go get cloud.google.com/go/tpu/apiv1@latestctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()

The client will use your default application credentials. Clients should be reused instead of created as needed.The methods of Client are safe for concurrent use by multiple goroutines.The returned client must be Closed when it is done being used.

Using the Client

The following is an example of making an API call with the newly created client, mentioned above.

req:=&tpupb.CreateNodeRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#CreateNodeRequest.}op,err:=c.CreateNode(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp

Use of Context

The ctx passed to NewClient is used for authentication requests andfor creating the underlying connection, but is not used for subsequent calls.Individual methods on the client use the ctx given to them.

To close the open connection, use the Close() method.

Functions

func DefaultAuthScopes

funcDefaultAuthScopes()[]string

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

AcceleratorTypeIterator

typeAcceleratorTypeIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*tpupb.AcceleratorType,nextPageTokenstring,errerror)// contains filtered or unexported fields}

AcceleratorTypeIterator manages a stream of *tpupb.AcceleratorType.

func (*AcceleratorTypeIterator) All

func(it*AcceleratorTypeIterator)All()iter.Seq2[*tpupb.AcceleratorType,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*AcceleratorTypeIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*AcceleratorTypeIterator) PageInfo

func(it*AcceleratorTypeIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

CallOptions

typeCallOptionsstruct{ListNodes[]gax.CallOptionGetNode[]gax.CallOptionCreateNode[]gax.CallOptionDeleteNode[]gax.CallOptionReimageNode[]gax.CallOptionStopNode[]gax.CallOptionStartNode[]gax.CallOptionListTensorFlowVersions[]gax.CallOptionGetTensorFlowVersion[]gax.CallOptionListAcceleratorTypes[]gax.CallOptionGetAcceleratorType[]gax.CallOptionGetLocation[]gax.CallOptionListLocations[]gax.CallOptionCancelOperation[]gax.CallOptionDeleteOperation[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}

CallOptions contains the retry settings for each method of Client.

Client

typeClientstruct{// The call options for this service.CallOptions*CallOptions// LROClient is used internally to handle long-running operations.// It is exposed so that its CallOptions can be modified if required.// Users should not Close this client.LROClient*lroauto.OperationsClient// contains filtered or unexported fields}

Client is a client for interacting with Cloud TPU API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

Manages TPU nodes and other resources

TPU API v1

func NewClient

funcNewClient(ctxcontext.Context,opts...option.ClientOption)(*Client,error)

NewClient creates a new tpu client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.

Manages TPU nodes and other resources

TPU API v1

Example

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}

func (*Client) CancelOperation

CancelOperation is a utility method from google.longrunning.Operations.

Example

packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"tpu"cloud.google.com/go/tpu/apiv1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.CancelOperationRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.}err=c.CancelOperation(ctx,req)iferr!=nil{// TODO: Handle error.}}

func (*Client) Close

func(c*Client)Close()error

Close closes the connection to the API service. The user should invoke this whenthe client is no longer required.

func (*Client) Connection (deprecated)

func(c*Client)Connection()*grpc.ClientConn

Connection returns a connection to the API service.

Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.

func (*Client) CreateNode

CreateNode creates a node.

Example

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.CreateNodeRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#CreateNodeRequest.}op,err:=c.CreateNode(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) CreateNodeOperation

func(c*Client)CreateNodeOperation(namestring)*CreateNodeOperation

CreateNodeOperation returns a new CreateNodeOperation from a given name.The name must be that of a previously created CreateNodeOperation, possibly from a different process.

func (*Client) DeleteNode

DeleteNode deletes a node.

Example

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.DeleteNodeRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#DeleteNodeRequest.}op,err:=c.DeleteNode(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) DeleteNodeOperation

func(c*Client)DeleteNodeOperation(namestring)*DeleteNodeOperation

DeleteNodeOperation returns a new DeleteNodeOperation from a given name.The name must be that of a previously created DeleteNodeOperation, possibly from a different process.

func (*Client) DeleteOperation

DeleteOperation is a utility method from google.longrunning.Operations.

Example

packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"tpu"cloud.google.com/go/tpu/apiv1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.DeleteOperationRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.}err=c.DeleteOperation(ctx,req)iferr!=nil{// TODO: Handle error.}}

func (*Client) GetAcceleratorType

GetAcceleratorType gets AcceleratorType.

Example

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.GetAcceleratorTypeRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#GetAcceleratorTypeRequest.}resp,err:=c.GetAcceleratorType(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) GetLocation

GetLocation gets information about a location.

Example

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"locationpb"google.golang.org/genproto/googleapis/cloud/location")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&locationpb.GetLocationRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.}resp,err:=c.GetLocation(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) GetNode

GetNode gets the details of a node.

Example

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.GetNodeRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#GetNodeRequest.}resp,err:=c.GetNode(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) GetOperation

GetOperation is a utility method from google.longrunning.Operations.

Example

packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"tpu"cloud.google.com/go/tpu/apiv1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.GetOperationRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.}resp,err:=c.GetOperation(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) GetTensorFlowVersion

GetTensorFlowVersion gets TensorFlow Version.

Example

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.GetTensorFlowVersionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#GetTensorFlowVersionRequest.}resp,err:=c.GetTensorFlowVersion(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) ListAcceleratorTypes

ListAcceleratorTypes lists accelerator types supported by this API.

Examples

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb""google.golang.org/api/iterator")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.ListAcceleratorTypesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#ListAcceleratorTypesRequest.}it:=c.ListAcceleratorTypes(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*tpupb.ListAcceleratorTypesResponse)}}
all
packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.ListAcceleratorTypesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#ListAcceleratorTypesRequest.}forresp,err:=rangec.ListAcceleratorTypes(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*Client) ListLocations

ListLocations lists information about the supported locations for this service.

Examples

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1""google.golang.org/api/iterator"locationpb"google.golang.org/genproto/googleapis/cloud/location")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&locationpb.ListLocationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.}it:=c.ListLocations(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*locationpb.ListLocationsResponse)}}
all
packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"locationpb"google.golang.org/genproto/googleapis/cloud/location")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&locationpb.ListLocationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.}forresp,err:=rangec.ListLocations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*Client) ListNodes

ListNodes lists nodes.

Examples

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb""google.golang.org/api/iterator")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.ListNodesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#ListNodesRequest.}it:=c.ListNodes(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*tpupb.ListNodesResponse)}}
all
packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.ListNodesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#ListNodesRequest.}forresp,err:=rangec.ListNodes(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*Client) ListOperations

ListOperations is a utility method from google.longrunning.Operations.

Examples

packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"tpu"cloud.google.com/go/tpu/apiv1""google.golang.org/api/iterator")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*longrunningpb.ListOperationsResponse)}}
all
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"tpu"cloud.google.com/go/tpu/apiv1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*Client) ListTensorFlowVersions

ListTensorFlowVersions list TensorFlow versions supported by this API.

Examples

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb""google.golang.org/api/iterator")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.ListTensorFlowVersionsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#ListTensorFlowVersionsRequest.}it:=c.ListTensorFlowVersions(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*tpupb.ListTensorFlowVersionsResponse)}}
all
packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.ListTensorFlowVersionsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#ListTensorFlowVersionsRequest.}forresp,err:=rangec.ListTensorFlowVersions(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*Client) ReimageNode

ReimageNode reimages a node’s OS.

Example

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.ReimageNodeRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#ReimageNodeRequest.}op,err:=c.ReimageNode(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) ReimageNodeOperation

func(c*Client)ReimageNodeOperation(namestring)*ReimageNodeOperation

ReimageNodeOperation returns a new ReimageNodeOperation from a given name.The name must be that of a previously created ReimageNodeOperation, possibly from a different process.

func (*Client) StartNode

StartNode starts a node.

Example

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.StartNodeRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#StartNodeRequest.}op,err:=c.StartNode(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) StartNodeOperation

func(c*Client)StartNodeOperation(namestring)*StartNodeOperation

StartNodeOperation returns a new StartNodeOperation from a given name.The name must be that of a previously created StartNodeOperation, possibly from a different process.

func (*Client) StopNode

StopNode stops a node, this operation is only available with single TPU nodes.

Example

packagemainimport("context"tpu"cloud.google.com/go/tpu/apiv1"tpupb"cloud.google.com/go/tpu/apiv1/tpupb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=tpu.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&tpupb.StopNodeRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/tpu/apiv1/tpupb#StopNodeRequest.}op,err:=c.StopNode(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) StopNodeOperation

func(c*Client)StopNodeOperation(namestring)*StopNodeOperation

StopNodeOperation returns a new StopNodeOperation from a given name.The name must be that of a previously created StopNodeOperation, possibly from a different process.

CreateNodeOperation

typeCreateNodeOperationstruct{// contains filtered or unexported fields}

CreateNodeOperation manages a long-running operation from CreateNode.

func (*CreateNodeOperation) Done

Done reports whether the long-running operation has completed.

func (*CreateNodeOperation) Metadata

Metadata returns metadata associated with the long-running operation.Metadata itself does not contact the server, but Poll does.To get the latest metadata, call this method after a successful call to Poll.If the metadata is not available, the returned metadata and error are both nil.

func (*CreateNodeOperation) Name

Name returns the name of the long-running operation.The name is assigned by the server and is unique within the service from which the operation is created.

func (*CreateNodeOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds andthe operation has completed with failure, the error is returned and op.Done will return true.If Poll succeeds and the operation has completed successfully,op.Done will return true, and the response of the operation is returned.If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*CreateNodeOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

DeleteNodeOperation

typeDeleteNodeOperationstruct{// contains filtered or unexported fields}

DeleteNodeOperation manages a long-running operation from DeleteNode.

func (*DeleteNodeOperation) Done

Done reports whether the long-running operation has completed.

func (*DeleteNodeOperation) Metadata

Metadata returns metadata associated with the long-running operation.Metadata itself does not contact the server, but Poll does.To get the latest metadata, call this method after a successful call to Poll.If the metadata is not available, the returned metadata and error are both nil.

func (*DeleteNodeOperation) Name

Name returns the name of the long-running operation.The name is assigned by the server and is unique within the service from which the operation is created.

func (*DeleteNodeOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds andthe operation has completed with failure, the error is returned and op.Done will return true.If Poll succeeds and the operation has completed successfully,op.Done will return true, and the response of the operation is returned.If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*DeleteNodeOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

LocationIterator

typeLocationIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*locationpb.Location,nextPageTokenstring,errerror)// contains filtered or unexported fields}

LocationIterator manages a stream of *locationpb.Location.

func (*LocationIterator) All

func(it*LocationIterator)All()iter.Seq2[*locationpb.Location,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*LocationIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*LocationIterator) PageInfo

func(it*LocationIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

NodeIterator

typeNodeIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*tpupb.Node,nextPageTokenstring,errerror)// contains filtered or unexported fields}

NodeIterator manages a stream of *tpupb.Node.

func (*NodeIterator) All

func(it*NodeIterator)All()iter.Seq2[*tpupb.Node,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*NodeIterator) Next

func(it*NodeIterator)Next()(*tpupb.Node,error)

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*NodeIterator) PageInfo

func(it*NodeIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

OperationIterator

typeOperationIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*longrunningpb.Operation,nextPageTokenstring,errerror)// contains filtered or unexported fields}

OperationIterator manages a stream of *longrunningpb.Operation.

func (*OperationIterator) All

func(it*OperationIterator)All()iter.Seq2[*longrunningpb.Operation,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*OperationIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*OperationIterator) PageInfo

func(it*OperationIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

ReimageNodeOperation

typeReimageNodeOperationstruct{// contains filtered or unexported fields}

ReimageNodeOperation manages a long-running operation from ReimageNode.

func (*ReimageNodeOperation) Done

Done reports whether the long-running operation has completed.

func (*ReimageNodeOperation) Metadata

Metadata returns metadata associated with the long-running operation.Metadata itself does not contact the server, but Poll does.To get the latest metadata, call this method after a successful call to Poll.If the metadata is not available, the returned metadata and error are both nil.

func (*ReimageNodeOperation) Name

Name returns the name of the long-running operation.The name is assigned by the server and is unique within the service from which the operation is created.

func (*ReimageNodeOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds andthe operation has completed with failure, the error is returned and op.Done will return true.If Poll succeeds and the operation has completed successfully,op.Done will return true, and the response of the operation is returned.If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*ReimageNodeOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

StartNodeOperation

typeStartNodeOperationstruct{// contains filtered or unexported fields}

StartNodeOperation manages a long-running operation from StartNode.

func (*StartNodeOperation) Done

func(op*StartNodeOperation)Done()bool

Done reports whether the long-running operation has completed.

func (*StartNodeOperation) Metadata

Metadata returns metadata associated with the long-running operation.Metadata itself does not contact the server, but Poll does.To get the latest metadata, call this method after a successful call to Poll.If the metadata is not available, the returned metadata and error are both nil.

func (*StartNodeOperation) Name

Name returns the name of the long-running operation.The name is assigned by the server and is unique within the service from which the operation is created.

func (*StartNodeOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds andthe operation has completed with failure, the error is returned and op.Done will return true.If Poll succeeds and the operation has completed successfully,op.Done will return true, and the response of the operation is returned.If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*StartNodeOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

StopNodeOperation

typeStopNodeOperationstruct{// contains filtered or unexported fields}

StopNodeOperation manages a long-running operation from StopNode.

func (*StopNodeOperation) Done

func(op*StopNodeOperation)Done()bool

Done reports whether the long-running operation has completed.

func (*StopNodeOperation) Metadata

Metadata returns metadata associated with the long-running operation.Metadata itself does not contact the server, but Poll does.To get the latest metadata, call this method after a successful call to Poll.If the metadata is not available, the returned metadata and error are both nil.

func (*StopNodeOperation) Name

Name returns the name of the long-running operation.The name is assigned by the server and is unique within the service from which the operation is created.

func (*StopNodeOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds andthe operation has completed with failure, the error is returned and op.Done will return true.If Poll succeeds and the operation has completed successfully,op.Done will return true, and the response of the operation is returned.If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*StopNodeOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

TensorFlowVersionIterator

typeTensorFlowVersionIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*tpupb.TensorFlowVersion,nextPageTokenstring,errerror)// contains filtered or unexported fields}

TensorFlowVersionIterator manages a stream of *tpupb.TensorFlowVersion.

func (*TensorFlowVersionIterator) All

func(it*TensorFlowVersionIterator)All()iter.Seq2[*tpupb.TensorFlowVersion,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*TensorFlowVersionIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*TensorFlowVersionIterator) PageInfo

func(it*TensorFlowVersionIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-30 UTC.