Package storagetransfer is an auto-generated package for the Storage Transfer API.
Transfers data from external data sources to a Google Cloud Storage bucket or between Google Cloud Storage buckets.
General documentation
For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage
To get started with this package, create a client.
// go get cloud.google.com/go/storagetransfer/apiv1@latest 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_Options c, err := storagetransfer.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.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 := &storagetransferpb.CreateAgentPoolRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#CreateAgentPoolRequest. } resp, err := c.CreateAgentPool(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context
The ctx passed to NewClient is used for authentication requests and for 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
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
AgentPoolIterator
type AgentPoolIterator struct {
// 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.
Response interface{}
// 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.
InternalFetch func(pageSize int, pageToken string) (results []*storagetransferpb.AgentPool, nextPageToken string, err error)
// contains filtered or unexported fields
}
AgentPoolIterator manages a stream of *storagetransferpb.AgentPool.
func (*AgentPoolIterator) All
func (it *AgentPoolIterator) All() iter.Seq2[*storagetransferpb.AgentPool, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*AgentPoolIterator) Next
func (it *AgentPoolIterator) Next() (*storagetransferpb.AgentPool, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*AgentPoolIterator) PageInfo
func (it *AgentPoolIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
CallOptions
type CallOptions struct {
GetGoogleServiceAccount []gax.CallOption
CreateTransferJob []gax.CallOption
UpdateTransferJob []gax.CallOption
GetTransferJob []gax.CallOption
ListTransferJobs []gax.CallOption
PauseTransferOperation []gax.CallOption
ResumeTransferOperation []gax.CallOption
RunTransferJob []gax.CallOption
DeleteTransferJob []gax.CallOption
CreateAgentPool []gax.CallOption
UpdateAgentPool []gax.CallOption
GetAgentPool []gax.CallOption
ListAgentPools []gax.CallOption
DeleteAgentPool []gax.CallOption
CancelOperation []gax.CallOption
GetOperation []gax.CallOption
ListOperations []gax.CallOption
}
CallOptions contains the retry settings for each method of Client.
Client
type Client struct {
// 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 Storage Transfer API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Storage Transfer Service and its protos. Transfers data between between Google Cloud Storage buckets or from a data source external to Google to a Cloud Storage bucket.
func NewClient
NewClient creates a new storage transfer service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Storage Transfer Service and its protos. Transfers data between between Google Cloud Storage buckets or from a data source external to Google to a Cloud Storage bucket.
Example
package main
import (
"context"
storagetransfer "cloud.google.com/go/storagetransfer/apiv1"
)
func main() {
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_Options
c, err := storagetransfer.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewRESTClient
NewRESTClient creates a new storage transfer service rest client.
Storage Transfer Service and its protos. Transfers data between between Google Cloud Storage buckets or from a data source external to Google to a Cloud Storage bucket.
Example
package main
import (
"context"
storagetransfer "cloud.google.com/go/storagetransfer/apiv1"
)
func main() {
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_Options
c, err := storagetransfer.NewRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*Client) CancelOperation
func (c *Client) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error
CancelOperation cancels a transfer. Use the transferOperations.get method to check if the cancellation succeeded or if the operation completed despite the cancel request.
When you cancel an operation, the currently running transfer is interrupted. For recurring transfer jobs, the next instance of the transfer job will still run. For example, if your job is configured to run every day at 1pm and you cancel Monday’s operation at 1:05pm, Monday’s transfer will stop. However, a transfer job will still be attempted on Tuesday.
This applies only to currently running operations. If an operation is not currently running, cancel does nothing.
When you cancel a job, the next job computes a delta of files and may repair any inconsistent state. For instance, if you run a job every day, and today’s job found 10 new files and transferred five files before you canceled the job, tomorrow’s transfer operation will compute a new delta with the five files that were not copied today plus any new files discovered tomorrow.
Example
package main
import (
"context"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
storagetransfer "cloud.google.com/go/storagetransfer/apiv1"
)
func main() {
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_Options
c, err := storagetransfer.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.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)
if err != nil {
// TODO: Handle error.
}
}
func (*Client) Close
Close closes the connection to the API service. The user should invoke this when the 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 always return the same resource.
func (*Client) CreateAgentPool
func (c *Client) CreateAgentPool(ctx context.Context, req *storagetransferpb.CreateAgentPoolRequest, opts ...gax.CallOption) (*storagetransferpb.AgentPool, error)
CreateAgentPool creates an agent pool resource.
Example
package main
import (
"context"
storagetransfer "cloud.google.com/go/storagetransfer/apiv1"
storagetransferpb "cloud.google.com/go/storagetransfer/apiv1/storagetransferpb"
)
func main() {
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_Options
c, err := storagetransfer.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &storagetransferpb.CreateAgentPoolRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#CreateAgentPoolRequest.
}
resp, err := c.CreateAgentPool(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}