package cluster
import "cloud.google.com/go/redis/cluster/apiv1"
Package cluster is an auto-generated package for the Google Cloud Memorystore for Redis API.
Creates and manages Redis instances on the Google Cloud Platform.
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/redis/cluster/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 := cluster.NewCloudRedisClusterClient(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 := &clusterpb.BackupClusterRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#BackupClusterRequest. } op, err := c.BackupCluster(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context
The ctx passed to NewCloudRedisClusterClient 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.
Index ¶
- func DefaultAuthScopes() []string
- type BackupClusterOperation
- func (op *BackupClusterOperation) Done() bool
- func (op *BackupClusterOperation) Metadata() (*anypb.Any, error)
- func (op *BackupClusterOperation) Name() string
- func (op *BackupClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
- func (op *BackupClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
- type BackupCollectionIterator
- func (it *BackupCollectionIterator) All() iter.Seq2[*clusterpb.BackupCollection, error]
- func (it *BackupCollectionIterator) Next() (*clusterpb.BackupCollection, error)
- func (it *BackupCollectionIterator) PageInfo() *iterator.PageInfo
- type BackupIterator
- func (it *BackupIterator) All() iter.Seq2[*clusterpb.Backup, error]
- func (it *BackupIterator) Next() (*clusterpb.Backup, error)
- func (it *BackupIterator) PageInfo() *iterator.PageInfo
- type CloudRedisClusterCallOptions
- type CloudRedisClusterClient
- func NewCloudRedisClusterClient(ctx context.Context, opts ...option.ClientOption) (*CloudRedisClusterClient, error)
- func NewCloudRedisClusterRESTClient(ctx context.Context, opts ...option.ClientOption) (*CloudRedisClusterClient, error)
- func (c *CloudRedisClusterClient) BackupCluster(ctx context.Context, req *clusterpb.BackupClusterRequest, opts ...gax.CallOption) (*BackupClusterOperation, error)
- func (c *CloudRedisClusterClient) BackupClusterOperation(name string) *BackupClusterOperation
- func (c *CloudRedisClusterClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error
- func (c *CloudRedisClusterClient) Close() error
- func (c *CloudRedisClusterClient) Connection() *grpc.ClientConn
- func (c *CloudRedisClusterClient) CreateCluster(ctx context.Context, req *clusterpb.CreateClusterRequest, opts ...gax.CallOption) (*CreateClusterOperation, error)
- func (c *CloudRedisClusterClient) CreateClusterOperation(name string) *CreateClusterOperation
- func (c *CloudRedisClusterClient) DeleteBackup(ctx context.Context, req *clusterpb.DeleteBackupRequest, opts ...gax.CallOption) (*DeleteBackupOperation, error)
- func (c *CloudRedisClusterClient) DeleteBackupOperation(name string) *DeleteBackupOperation
- func (c *CloudRedisClusterClient) DeleteCluster(ctx context.Context, req *clusterpb.DeleteClusterRequest, opts ...gax.CallOption) (*DeleteClusterOperation, error)
- func (c *CloudRedisClusterClient) DeleteClusterOperation(name string) *DeleteClusterOperation
- func (c *CloudRedisClusterClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error
- func (c *CloudRedisClusterClient) ExportBackup(ctx context.Context, req *clusterpb.ExportBackupRequest, opts ...gax.CallOption) (*ExportBackupOperation, error)
- func (c *CloudRedisClusterClient) ExportBackupOperation(name string) *ExportBackupOperation
- func (c *CloudRedisClusterClient) GetBackup(ctx context.Context, req *clusterpb.GetBackupRequest, opts ...gax.CallOption) (*clusterpb.Backup, error)
- func (c *CloudRedisClusterClient) GetBackupCollection(ctx context.Context, req *clusterpb.GetBackupCollectionRequest, opts ...gax.CallOption) (*clusterpb.BackupCollection, error)
- func (c *CloudRedisClusterClient) GetCluster(ctx context.Context, req *clusterpb.GetClusterRequest, opts ...gax.CallOption) (*clusterpb.Cluster, error)
- func (c *CloudRedisClusterClient) GetClusterCertificateAuthority(ctx context.Context, req *clusterpb.GetClusterCertificateAuthorityRequest, opts ...gax.CallOption) (*clusterpb.CertificateAuthority, error)
- func (c *CloudRedisClusterClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error)
- func (c *CloudRedisClusterClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error)
- func (c *CloudRedisClusterClient) ListBackupCollections(ctx context.Context, req *clusterpb.ListBackupCollectionsRequest, opts ...gax.CallOption) *BackupCollectionIterator
- func (c *CloudRedisClusterClient) ListBackups(ctx context.Context, req *clusterpb.ListBackupsRequest, opts ...gax.CallOption) *BackupIterator
- func (c *CloudRedisClusterClient) ListClusters(ctx context.Context, req *clusterpb.ListClustersRequest, opts ...gax.CallOption) *ClusterIterator
- func (c *CloudRedisClusterClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator
- func (c *CloudRedisClusterClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator
- func (c *CloudRedisClusterClient) RescheduleClusterMaintenance(ctx context.Context, req *clusterpb.RescheduleClusterMaintenanceRequest, opts ...gax.CallOption) (*RescheduleClusterMaintenanceOperation, error)
- func (c *CloudRedisClusterClient) RescheduleClusterMaintenanceOperation(name string) *RescheduleClusterMaintenanceOperation
- func (c *CloudRedisClusterClient) UpdateCluster(ctx context.Context, req *clusterpb.UpdateClusterRequest, opts ...gax.CallOption) (*UpdateClusterOperation, error)
- func (c *CloudRedisClusterClient) UpdateClusterOperation(name string) *UpdateClusterOperation
- type ClusterIterator
- func (it *ClusterIterator) All() iter.Seq2[*clusterpb.Cluster, error]
- func (it *ClusterIterator) Next() (*clusterpb.Cluster, error)
- func (it *ClusterIterator) PageInfo() *iterator.PageInfo
- type CreateClusterOperation
- func (op *CreateClusterOperation) Done() bool
- func (op *CreateClusterOperation) Metadata() (*anypb.Any, error)
- func (op *CreateClusterOperation) Name() string
- func (op *CreateClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
- func (op *CreateClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
- type DeleteBackupOperation
- func (op *DeleteBackupOperation) Done() bool
- func (op *DeleteBackupOperation) Metadata() (*anypb.Any, error)
- func (op *DeleteBackupOperation) Name() string
- func (op *DeleteBackupOperation) Poll(ctx context.Context, opts ...gax.CallOption) error
- func (op *DeleteBackupOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
- type DeleteClusterOperation
- func (op *DeleteClusterOperation) Done() bool
- func (op *DeleteClusterOperation) Metadata() (*anypb.Any, error)
- func (op *DeleteClusterOperation) Name() string
- func (op *DeleteClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) error
- func (op *DeleteClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
- type ExportBackupOperation
- func (op *ExportBackupOperation) Done() bool
- func (op *ExportBackupOperation) Metadata() (*anypb.Any, error)
- func (op *ExportBackupOperation) Name() string
- func (op *ExportBackupOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Backup, error)
- func (op *ExportBackupOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Backup, error)
- type LocationIterator
- func (it *LocationIterator) All() iter.Seq2[*locationpb.Location, error]
- func (it *LocationIterator) Next() (*locationpb.Location, error)
- func (it *LocationIterator) PageInfo() *iterator.PageInfo
- type OperationIterator
- func (it *OperationIterator) All() iter.Seq2[*longrunningpb.Operation, error]
- func (it *OperationIterator) Next() (*longrunningpb.Operation, error)
- func (it *OperationIterator) PageInfo() *iterator.PageInfo
- type RescheduleClusterMaintenanceOperation
- func (op *RescheduleClusterMaintenanceOperation) Done() bool
- func (op *RescheduleClusterMaintenanceOperation) Metadata() (*anypb.Any, error)
- func (op *RescheduleClusterMaintenanceOperation) Name() string
- func (op *RescheduleClusterMaintenanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
- func (op *RescheduleClusterMaintenanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
- type UpdateClusterOperation
- func (op *UpdateClusterOperation) Done() bool
- func (op *UpdateClusterOperation) Metadata() (*anypb.Any, error)
- func (op *UpdateClusterOperation) Name() string
- func (op *UpdateClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
- func (op *UpdateClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
Examples ¶
- CloudRedisClusterClient.BackupCluster
- CloudRedisClusterClient.CancelOperation
- CloudRedisClusterClient.CreateCluster
- CloudRedisClusterClient.DeleteBackup
- CloudRedisClusterClient.DeleteCluster
- CloudRedisClusterClient.DeleteOperation
- CloudRedisClusterClient.ExportBackup
- CloudRedisClusterClient.GetBackup
- CloudRedisClusterClient.GetBackupCollection
- CloudRedisClusterClient.GetCluster
- CloudRedisClusterClient.GetClusterCertificateAuthority
- CloudRedisClusterClient.GetLocation
- CloudRedisClusterClient.GetOperation
- CloudRedisClusterClient.ListBackupCollections
- CloudRedisClusterClient.ListBackupCollections (All)
- CloudRedisClusterClient.ListBackups
- CloudRedisClusterClient.ListBackups (All)
- CloudRedisClusterClient.ListClusters
- CloudRedisClusterClient.ListClusters (All)
- CloudRedisClusterClient.ListLocations
- CloudRedisClusterClient.ListLocations (All)
- CloudRedisClusterClient.ListOperations
- CloudRedisClusterClient.ListOperations (All)
- CloudRedisClusterClient.RescheduleClusterMaintenance
- CloudRedisClusterClient.UpdateCluster
- NewCloudRedisClusterClient
- NewCloudRedisClusterRESTClient
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type BackupClusterOperation ¶
type BackupClusterOperation struct {
// contains filtered or unexported fields
}
BackupClusterOperation manages a long-running operation from BackupCluster.
func (*BackupClusterOperation) Done ¶
func (op *BackupClusterOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*BackupClusterOperation) Metadata ¶
func (op *BackupClusterOperation) Metadata() (*anypb.Any, error)
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 (*BackupClusterOperation) Name ¶
func (op *BackupClusterOperation) Name() string
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 (*BackupClusterOperation) Poll ¶
func (op *BackupClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
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 and the 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 (*BackupClusterOperation) Wait ¶
func (op *BackupClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
type BackupCollectionIterator ¶
type BackupCollectionIterator 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 []*clusterpb.BackupCollection, nextPageToken string, err error) // contains filtered or unexported fields }
BackupCollectionIterator manages a stream of *clusterpb.BackupCollection.
func (*BackupCollectionIterator) All ¶
func (it *BackupCollectionIterator) All() iter.Seq2[*clusterpb.BackupCollection, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*BackupCollectionIterator) Next ¶
func (it *BackupCollectionIterator) Next() (*clusterpb.BackupCollection, 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 (*BackupCollectionIterator) PageInfo ¶
func (it *BackupCollectionIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type BackupIterator ¶
type BackupIterator 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 []*clusterpb.Backup, nextPageToken string, err error) // contains filtered or unexported fields }
BackupIterator manages a stream of *clusterpb.Backup.
func (*BackupIterator) All ¶
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*BackupIterator) Next ¶
func (it *BackupIterator) Next() (*clusterpb.Backup, 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 (*BackupIterator) PageInfo ¶
func (it *BackupIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type CloudRedisClusterCallOptions ¶
type CloudRedisClusterCallOptions struct { ListClusters []gax.CallOption GetCluster []gax.CallOption UpdateCluster []gax.CallOption DeleteCluster []gax.CallOption CreateCluster []gax.CallOption GetClusterCertificateAuthority []gax.CallOption RescheduleClusterMaintenance []gax.CallOption ListBackupCollections []gax.CallOption GetBackupCollection []gax.CallOption ListBackups []gax.CallOption GetBackup []gax.CallOption DeleteBackup []gax.CallOption ExportBackup []gax.CallOption BackupCluster []gax.CallOption GetLocation []gax.CallOption ListLocations []gax.CallOption CancelOperation []gax.CallOption DeleteOperation []gax.CallOption GetOperation []gax.CallOption ListOperations []gax.CallOption }
CloudRedisClusterCallOptions contains the retry settings for each method of CloudRedisClusterClient.
type CloudRedisClusterClient ¶
type CloudRedisClusterClient struct { // The call options for this service. CallOptions *CloudRedisClusterCallOptions // 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 }
CloudRedisClusterClient is a client for interacting with Google Cloud Memorystore for Redis API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Configures and manages Cloud Memorystore for Redis clusters
Google Cloud Memorystore for Redis Cluster
The redis.googleapis.com service implements the Google Cloud Memorystore for Redis API and defines the following resource model for managing Redis clusters:
The service works with a collection of cloud projects, named: /projects/* Each project has a collection of available locations, named: /locations/* Each location has a collection of Redis clusters, named: /clusters/* As such, Redis clusters are resources of the form: /projects/{project_id}/locations/{location_id}/clusters/{instance_id}
Note that location_id must be a GCP region; for example:
projects/redpepper-1290/locations/us-central1/clusters/my-redis
func NewCloudRedisClusterClient ¶
func NewCloudRedisClusterClient(ctx context.Context, opts ...option.ClientOption) (*CloudRedisClusterClient, error)
NewCloudRedisClusterClient creates a new cloud redis cluster client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Configures and manages Cloud Memorystore for Redis clusters
Google Cloud Memorystore for Redis Cluster
The redis.googleapis.com service implements the Google Cloud Memorystore for Redis API and defines the following resource model for managing Redis clusters:
The service works with a collection of cloud projects, named: /projects/* Each project has a collection of available locations, named: /locations/* Each location has a collection of Redis clusters, named: /clusters/* As such, Redis clusters are resources of the form: /projects/{project_id}/locations/{location_id}/clusters/{instance_id}
Note that location_id must be a GCP region; for example:
projects/redpepper-1290/locations/us-central1/clusters/my-redis
Example¶
Code:play
package main import ( "context" cluster "cloud.google.com/go/redis/cluster/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 := cluster.NewCloudRedisClusterClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
func NewCloudRedisClusterRESTClient ¶
func NewCloudRedisClusterRESTClient(ctx context.Context, opts ...option.ClientOption) (*CloudRedisClusterClient, error)
NewCloudRedisClusterRESTClient creates a new cloud redis cluster rest client.
Configures and manages Cloud Memorystore for Redis clusters
Google Cloud Memorystore for Redis Cluster
The redis.googleapis.com service implements the Google Cloud Memorystore for Redis API and defines the following resource model for managing Redis clusters:
The service works with a collection of cloud projects, named: /projects/* Each project has a collection of available locations, named: /locations/* Each location has a collection of Redis clusters, named: /clusters/* As such, Redis clusters are resources of the form: /projects/{project_id}/locations/{location_id}/clusters/{instance_id}
Note that location_id must be a GCP region; for example:
projects/redpepper-1290/locations/us-central1/clusters/my-redis
Example¶
Code:play
package main import ( "context" cluster "cloud.google.com/go/redis/cluster/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 := cluster.NewCloudRedisClusterRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
func (*CloudRedisClusterClient) BackupCluster ¶
func (c *CloudRedisClusterClient) BackupCluster(ctx context.Context, req *clusterpb.BackupClusterRequest, opts ...gax.CallOption) (*BackupClusterOperation, error)
BackupCluster backup Redis Cluster.
If this is the first time a backup is being created, a backup collection
will be created at the backend, and this backup belongs to this collection.
Both collection and backup will have a resource name. Backup will be
executed for each shard. A replica (primary if nonHA) will be selected to
perform the execution. Backup call will be rejected if there is an ongoing
backup or update operation. Be aware that during preview, if the cluster’s
internal software version is too old, critical update will be performed
before actual backup. Once the internal software version is updated to the
minimum version required by the backup feature, subsequent backups will not
require critical update. After preview, there will be no critical update
needed for backup.
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.BackupClusterRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#BackupClusterRequest.
}
op, err := c.BackupCluster(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudRedisClusterClient) BackupClusterOperation ¶
func (c *CloudRedisClusterClient) BackupClusterOperation(name string) *BackupClusterOperation
BackupClusterOperation returns a new BackupClusterOperation from a given name. The name must be that of a previously created BackupClusterOperation, possibly from a different process.
func (*CloudRedisClusterClient) CancelOperation ¶
func (c *CloudRedisClusterClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error
CancelOperation is a utility method from google.longrunning.Operations.
Code:play
Example¶
package main
import (
"context"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
cluster "cloud.google.com/go/redis/cluster/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 := cluster.NewCloudRedisClusterClient(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 (*CloudRedisClusterClient) Close ¶
func (c *CloudRedisClusterClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*CloudRedisClusterClient) Connection ¶
func (c *CloudRedisClusterClient) 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 (*CloudRedisClusterClient) CreateCluster ¶
func (c *CloudRedisClusterClient) CreateCluster(ctx context.Context, req *clusterpb.CreateClusterRequest, opts ...gax.CallOption) (*CreateClusterOperation, error)
CreateCluster creates a Redis cluster based on the specified properties. The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis cluster will be fully functional. The completed longrunning.Operation will contain the new cluster object in the response field.
The returned operation is automatically deleted after a few hours, so there
is no need to call DeleteOperation.
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.CreateClusterRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#CreateClusterRequest.
}
op, err := c.CreateCluster(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudRedisClusterClient) CreateClusterOperation ¶
func (c *CloudRedisClusterClient) CreateClusterOperation(name string) *CreateClusterOperation
CreateClusterOperation returns a new CreateClusterOperation from a given name. The name must be that of a previously created CreateClusterOperation, possibly from a different process.
func (*CloudRedisClusterClient) DeleteBackup ¶
func (c *CloudRedisClusterClient) DeleteBackup(ctx context.Context, req *clusterpb.DeleteBackupRequest, opts ...gax.CallOption) (*DeleteBackupOperation, error)
DeleteBackup deletes a specific backup.
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.DeleteBackupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#DeleteBackupRequest.
}
op, err := c.DeleteBackup(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*CloudRedisClusterClient) DeleteBackupOperation ¶
func (c *CloudRedisClusterClient) DeleteBackupOperation(name string) *DeleteBackupOperation
DeleteBackupOperation returns a new DeleteBackupOperation from a given name. The name must be that of a previously created DeleteBackupOperation, possibly from a different process.
func (*CloudRedisClusterClient) DeleteCluster ¶
func (c *CloudRedisClusterClient) DeleteCluster(ctx context.Context, req *clusterpb.DeleteClusterRequest, opts ...gax.CallOption) (*DeleteClusterOperation, error)
DeleteCluster deletes a specific Redis cluster. Cluster stops serving and data is
deleted.
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.DeleteClusterRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#DeleteClusterRequest.
}
op, err := c.DeleteCluster(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*CloudRedisClusterClient) DeleteClusterOperation ¶
func (c *CloudRedisClusterClient) DeleteClusterOperation(name string) *DeleteClusterOperation
DeleteClusterOperation returns a new DeleteClusterOperation from a given name. The name must be that of a previously created DeleteClusterOperation, possibly from a different process.
func (*CloudRedisClusterClient) DeleteOperation ¶
func (c *CloudRedisClusterClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error
DeleteOperation is a utility method from google.longrunning.Operations.
Code:play
Example¶
package main
import (
"context"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
cluster "cloud.google.com/go/redis/cluster/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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.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)
if err != nil {
// TODO: Handle error.
}
}
func (*CloudRedisClusterClient) ExportBackup ¶
func (c *CloudRedisClusterClient) ExportBackup(ctx context.Context, req *clusterpb.ExportBackupRequest, opts ...gax.CallOption) (*ExportBackupOperation, error)
ExportBackup exports a specific backup to a customer target Cloud Storage URI.
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.ExportBackupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#ExportBackupRequest.
}
op, err := c.ExportBackup(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudRedisClusterClient) ExportBackupOperation ¶
func (c *CloudRedisClusterClient) ExportBackupOperation(name string) *ExportBackupOperation
ExportBackupOperation returns a new ExportBackupOperation from a given name. The name must be that of a previously created ExportBackupOperation, possibly from a different process.
func (*CloudRedisClusterClient) GetBackup ¶
func (c *CloudRedisClusterClient) GetBackup(ctx context.Context, req *clusterpb.GetBackupRequest, opts ...gax.CallOption) (*clusterpb.Backup, error)
GetBackup gets the details of a specific backup.
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.GetBackupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#GetBackupRequest.
}
resp, err := c.GetBackup(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudRedisClusterClient) GetBackupCollection ¶
func (c *CloudRedisClusterClient) GetBackupCollection(ctx context.Context, req *clusterpb.GetBackupCollectionRequest, opts ...gax.CallOption) (*clusterpb.BackupCollection, error)
GetBackupCollection get a backup collection.
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.GetBackupCollectionRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#GetBackupCollectionRequest.
}
resp, err := c.GetBackupCollection(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudRedisClusterClient) GetCluster ¶
func (c *CloudRedisClusterClient) GetCluster(ctx context.Context, req *clusterpb.GetClusterRequest, opts ...gax.CallOption) (*clusterpb.Cluster, error)
GetCluster gets the details of a specific Redis cluster.
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.GetClusterRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#GetClusterRequest.
}
resp, err := c.GetCluster(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudRedisClusterClient) GetClusterCertificateAuthority ¶
func (c *CloudRedisClusterClient) GetClusterCertificateAuthority(ctx context.Context, req *clusterpb.GetClusterCertificateAuthorityRequest, opts ...gax.CallOption) (*clusterpb.CertificateAuthority, error)
GetClusterCertificateAuthority gets the details of certificate authority information for Redis cluster.
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.GetClusterCertificateAuthorityRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#GetClusterCertificateAuthorityRequest.
}
resp, err := c.GetClusterCertificateAuthority(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudRedisClusterClient) GetLocation ¶
func (c *CloudRedisClusterClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error)
GetLocation gets information about a location.
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
locationpb "google.golang.org/genproto/googleapis/cloud/location"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.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)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudRedisClusterClient) GetOperation ¶
func (c *CloudRedisClusterClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error)
GetOperation is a utility method from google.longrunning.Operations.
Code:play
Example¶
package main
import (
"context"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
cluster "cloud.google.com/go/redis/cluster/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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.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)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudRedisClusterClient) ListBackupCollections ¶
func (c *CloudRedisClusterClient) ListBackupCollections(ctx context.Context, req *clusterpb.ListBackupCollectionsRequest, opts ...gax.CallOption) *BackupCollectionIterator
ListBackupCollections lists all backup collections owned by a consumer project in either the specified location (region) or all locations.
If location_id is specified as - (wildcard), then all regions
available to the project are queried, and the results are aggregated.
Code:play
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
"google.golang.org/api/iterator"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.ListBackupCollectionsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#ListBackupCollectionsRequest.
}
it := c.ListBackupCollections(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != 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.(*clusterpb.ListBackupCollectionsResponse)
}
}
Example (All)¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.ListBackupCollectionsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#ListBackupCollectionsRequest.
}
for resp, err := range c.ListBackupCollections(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*CloudRedisClusterClient) ListBackups ¶
func (c *CloudRedisClusterClient) ListBackups(ctx context.Context, req *clusterpb.ListBackupsRequest, opts ...gax.CallOption) *BackupIterator
ListBackups lists all backups owned by a backup collection.
Code:play
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
"google.golang.org/api/iterator"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.ListBackupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#ListBackupsRequest.
}
it := c.ListBackups(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != 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.(*clusterpb.ListBackupsResponse)
}
}
Example (All)¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.ListBackupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#ListBackupsRequest.
}
for resp, err := range c.ListBackups(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*CloudRedisClusterClient) ListClusters ¶
func (c *CloudRedisClusterClient) ListClusters(ctx context.Context, req *clusterpb.ListClustersRequest, opts ...gax.CallOption) *ClusterIterator
ListClusters lists all Redis clusters owned by a project in either the specified location (region) or all locations.
The location should have the following format:
projects/{project_id}/locations/{location_id}
If location_id is specified as - (wildcard), then all regions
available to the project are queried, and the results are aggregated.
Code:play
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
"google.golang.org/api/iterator"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.ListClustersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#ListClustersRequest.
}
it := c.ListClusters(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != 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.(*clusterpb.ListClustersResponse)
}
}
Example (All)¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.ListClustersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#ListClustersRequest.
}
for resp, err := range c.ListClusters(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*CloudRedisClusterClient) ListLocations ¶
func (c *CloudRedisClusterClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator
ListLocations lists information about the supported locations for this service.
Code:play
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
"google.golang.org/api/iterator"
locationpb "google.golang.org/genproto/googleapis/cloud/location"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.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()
if err == iterator.Done {
break
}
if err != 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)
}
}
Example (All)¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
locationpb "google.golang.org/genproto/googleapis/cloud/location"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &locationpb.ListLocationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
}
for resp, err := range c.ListLocations(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*CloudRedisClusterClient) ListOperations ¶
func (c *CloudRedisClusterClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator
ListOperations is a utility method from google.longrunning.Operations.
Code:play
Code:play
Example¶
package main
import (
"context"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
cluster "cloud.google.com/go/redis/cluster/apiv1"
"google.golang.org/api/iterator"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.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()
if err == iterator.Done {
break
}
if err != 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)
}
}
Example (All)¶
package main
import (
"context"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
cluster "cloud.google.com/go/redis/cluster/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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &longrunningpb.ListOperationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
}
for resp, err := range c.ListOperations(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*CloudRedisClusterClient) RescheduleClusterMaintenance ¶
func (c *CloudRedisClusterClient) RescheduleClusterMaintenance(ctx context.Context, req *clusterpb.RescheduleClusterMaintenanceRequest, opts ...gax.CallOption) (*RescheduleClusterMaintenanceOperation, error)
RescheduleClusterMaintenance reschedules upcoming maintenance event.
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.RescheduleClusterMaintenanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#RescheduleClusterMaintenanceRequest.
}
op, err := c.RescheduleClusterMaintenance(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudRedisClusterClient) RescheduleClusterMaintenanceOperation ¶
func (c *CloudRedisClusterClient) RescheduleClusterMaintenanceOperation(name string) *RescheduleClusterMaintenanceOperation
RescheduleClusterMaintenanceOperation returns a new RescheduleClusterMaintenanceOperation from a given name. The name must be that of a previously created RescheduleClusterMaintenanceOperation, possibly from a different process.
func (*CloudRedisClusterClient) UpdateCluster ¶
func (c *CloudRedisClusterClient) UpdateCluster(ctx context.Context, req *clusterpb.UpdateClusterRequest, opts ...gax.CallOption) (*UpdateClusterOperation, error)
UpdateCluster updates the metadata and configuration of a specific Redis cluster.
Completed longrunning.Operation will contain the new cluster object
in the response field. The returned operation is automatically deleted
after a few hours, so there is no need to call DeleteOperation.
Code:play
Example¶
package main
import (
"context"
cluster "cloud.google.com/go/redis/cluster/apiv1"
clusterpb "cloud.google.com/go/redis/cluster/apiv1/clusterpb"
)
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 := cluster.NewCloudRedisClusterClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &clusterpb.UpdateClusterRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/redis/cluster/apiv1/clusterpb#UpdateClusterRequest.
}
op, err := c.UpdateCluster(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudRedisClusterClient) UpdateClusterOperation ¶
func (c *CloudRedisClusterClient) UpdateClusterOperation(name string) *UpdateClusterOperation
UpdateClusterOperation returns a new UpdateClusterOperation from a given name. The name must be that of a previously created UpdateClusterOperation, possibly from a different process.
type ClusterIterator ¶
type ClusterIterator 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 []*clusterpb.Cluster, nextPageToken string, err error) // contains filtered or unexported fields }
ClusterIterator manages a stream of *clusterpb.Cluster.
func (*ClusterIterator) All ¶
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ClusterIterator) Next ¶
func (it *ClusterIterator) Next() (*clusterpb.Cluster, 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 (*ClusterIterator) PageInfo ¶
func (it *ClusterIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type CreateClusterOperation ¶
type CreateClusterOperation struct {
// contains filtered or unexported fields
}
CreateClusterOperation manages a long-running operation from CreateCluster.
func (*CreateClusterOperation) Done ¶
func (op *CreateClusterOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*CreateClusterOperation) Metadata ¶
func (op *CreateClusterOperation) Metadata() (*anypb.Any, error)
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 (*CreateClusterOperation) Name ¶
func (op *CreateClusterOperation) Name() string
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 (*CreateClusterOperation) Poll ¶
func (op *CreateClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
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 and the 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 (*CreateClusterOperation) Wait ¶
func (op *CreateClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
type DeleteBackupOperation ¶
type DeleteBackupOperation struct {
// contains filtered or unexported fields
}
DeleteBackupOperation manages a long-running operation from DeleteBackup.
func (*DeleteBackupOperation) Done ¶
func (op *DeleteBackupOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*DeleteBackupOperation) Metadata ¶
func (op *DeleteBackupOperation) Metadata() (*anypb.Any, error)
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 (*DeleteBackupOperation) Name ¶
func (op *DeleteBackupOperation) Name() string
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 (*DeleteBackupOperation) Poll ¶
func (op *DeleteBackupOperation) Poll(ctx context.Context, opts ...gax.CallOption) error
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 and the 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 (*DeleteBackupOperation) Wait ¶
func (op *DeleteBackupOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
type DeleteClusterOperation ¶
type DeleteClusterOperation struct {
// contains filtered or unexported fields
}
DeleteClusterOperation manages a long-running operation from DeleteCluster.
func (*DeleteClusterOperation) Done ¶
func (op *DeleteClusterOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*DeleteClusterOperation) Metadata ¶
func (op *DeleteClusterOperation) Metadata() (*anypb.Any, error)
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 (*DeleteClusterOperation) Name ¶
func (op *DeleteClusterOperation) Name() string
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 (*DeleteClusterOperation) Poll ¶
func (op *DeleteClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) error
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 and the 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 (*DeleteClusterOperation) Wait ¶
func (op *DeleteClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
type ExportBackupOperation ¶
type ExportBackupOperation struct {
// contains filtered or unexported fields
}
ExportBackupOperation manages a long-running operation from ExportBackup.
func (*ExportBackupOperation) Done ¶
func (op *ExportBackupOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*ExportBackupOperation) Metadata ¶
func (op *ExportBackupOperation) Metadata() (*anypb.Any, error)
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 (*ExportBackupOperation) Name ¶
func (op *ExportBackupOperation) Name() string
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 (*ExportBackupOperation) Poll ¶
func (op *ExportBackupOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Backup, error)
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 and the 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 (*ExportBackupOperation) Wait ¶
func (op *ExportBackupOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Backup, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
type LocationIterator ¶
type LocationIterator 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 []*locationpb.Location, nextPageToken string, err error) // 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, the iterator will stop after that iteration.
func (*LocationIterator) Next ¶
func (it *LocationIterator) Next() (*locationpb.Location, 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 (*LocationIterator) PageInfo ¶
func (it *LocationIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type OperationIterator ¶
type OperationIterator 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 []*longrunningpb.Operation, nextPageToken string, err error) // 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, the iterator will stop after that iteration.
func (*OperationIterator) Next ¶
func (it *OperationIterator) Next() (*longrunningpb.Operation, 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 (*OperationIterator) PageInfo ¶
func (it *OperationIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type RescheduleClusterMaintenanceOperation ¶
type RescheduleClusterMaintenanceOperation struct {
// contains filtered or unexported fields
}
RescheduleClusterMaintenanceOperation manages a long-running operation from RescheduleClusterMaintenance.
func (*RescheduleClusterMaintenanceOperation) Done ¶
func (op *RescheduleClusterMaintenanceOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*RescheduleClusterMaintenanceOperation) Metadata ¶
func (op *RescheduleClusterMaintenanceOperation) Metadata() (*anypb.Any, error)
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 (*RescheduleClusterMaintenanceOperation) Name ¶
func (op *RescheduleClusterMaintenanceOperation) Name() string
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 (*RescheduleClusterMaintenanceOperation) Poll ¶
func (op *RescheduleClusterMaintenanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
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 and the 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 (*RescheduleClusterMaintenanceOperation) Wait ¶
func (op *RescheduleClusterMaintenanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
type UpdateClusterOperation ¶
type UpdateClusterOperation struct {
// contains filtered or unexported fields
}
UpdateClusterOperation manages a long-running operation from UpdateCluster.
func (*UpdateClusterOperation) Done ¶
func (op *UpdateClusterOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*UpdateClusterOperation) Metadata ¶
func (op *UpdateClusterOperation) Metadata() (*anypb.Any, error)
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 (*UpdateClusterOperation) Name ¶
func (op *UpdateClusterOperation) Name() string
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 (*UpdateClusterOperation) Poll ¶
func (op *UpdateClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
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 and the 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 (*UpdateClusterOperation) Wait ¶
func (op *UpdateClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clusterpb.Cluster, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
Source Files ¶
auxiliary.go auxiliary_go123.go cloud_redis_cluster_client.go doc.go helpers.go version.go
Directories ¶
Path | Synopsis |
---|---|
cluster/apiv1/clusterpb |
- Version
- v1.18.0 (latest)
- Published
- Jan 30, 2025
- Platform
- linux/amd64
- Imports
- 30 packages
- Last checked
- 6 days ago –
Tools for package owners.