Documentation ¶
Overview ¶
Package redis is an auto-generated package for the Google Cloud Memorystore for Redis API.
NOTE: This package is in alpha. It is not stable, and is likely to change.
The Google Cloud Memorystore for Redis API is used for creating and managing Redis instances on the Google Cloud Platform.
Index ¶
- func DefaultAuthScopes() []string
- type CloudRedisCallOptions
- type CloudRedisClient
- func (c *CloudRedisClient) Close() error
- func (c *CloudRedisClient) Connection() *grpc.ClientConn
- func (c *CloudRedisClient) CreateInstance(ctx context.Context, req *redispb.CreateInstanceRequest, ...) (*CreateInstanceOperation, error)
- func (c *CloudRedisClient) CreateInstanceOperation(name string) *CreateInstanceOperation
- func (c *CloudRedisClient) DeleteInstance(ctx context.Context, req *redispb.DeleteInstanceRequest, ...) (*DeleteInstanceOperation, error)
- func (c *CloudRedisClient) DeleteInstanceOperation(name string) *DeleteInstanceOperation
- func (c *CloudRedisClient) GetInstance(ctx context.Context, req *redispb.GetInstanceRequest, opts ...gax.CallOption) (*redispb.Instance, error)
- func (c *CloudRedisClient) ListInstances(ctx context.Context, req *redispb.ListInstancesRequest, opts ...gax.CallOption) *InstanceIterator
- func (c *CloudRedisClient) UpdateInstance(ctx context.Context, req *redispb.UpdateInstanceRequest, ...) (*UpdateInstanceOperation, error)
- func (c *CloudRedisClient) UpdateInstanceOperation(name string) *UpdateInstanceOperation
- type CreateInstanceOperation
- func (op *CreateInstanceOperation) Done() bool
- func (op *CreateInstanceOperation) Metadata() (*anypb.Any, error)
- func (op *CreateInstanceOperation) Name() string
- func (op *CreateInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*redispb.Instance, error)
- func (op *CreateInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*redispb.Instance, error)
- type DeleteInstanceOperation
- func (op *DeleteInstanceOperation) Done() bool
- func (op *DeleteInstanceOperation) Metadata() (*anypb.Any, error)
- func (op *DeleteInstanceOperation) Name() string
- func (op *DeleteInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) error
- func (op *DeleteInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
- type InstanceIterator
- type UpdateInstanceOperation
- func (op *UpdateInstanceOperation) Done() bool
- func (op *UpdateInstanceOperation) Metadata() (*anypb.Any, error)
- func (op *UpdateInstanceOperation) Name() string
- func (op *UpdateInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*redispb.Instance, error)
- func (op *UpdateInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*redispb.Instance, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type CloudRedisCallOptions ¶
type CloudRedisCallOptions struct { ListInstances []gax.CallOption GetInstance []gax.CallOption CreateInstance []gax.CallOption UpdateInstance []gax.CallOption DeleteInstance []gax.CallOption }
CloudRedisCallOptions contains the retry settings for each method of CloudRedisClient.
type CloudRedisClient ¶
type CloudRedisClient struct { // LROClient is used internally to handle longrunning operations. // It is exposed so that its CallOptions can be modified if required. // Users should not Close this client. LROClient *lroauto.OperationsClient // The call options for this service. CallOptions *CloudRedisCallOptions // contains filtered or unexported fields }
CloudRedisClient is a client for interacting with Google Cloud Memorystore for Redis API.
func NewCloudRedisClient ¶
func NewCloudRedisClient(ctx context.Context, opts ...option.ClientOption) (*CloudRedisClient, error)
NewCloudRedisClient creates a new cloud redis client.
Configures and manages Cloud Memorystore for Redis instances ¶
Google Cloud Memorystore for Redis v1beta1 ¶
The redis.googleapis.com service implements the Google Cloud Memorystore for Redis API and defines the following resource model for managing Redis instances:
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 instances, named: /instances/* As such, Redis instances are resources of the form: /projects/{project_id}/locations/{location_id}/instances/{instance_id}
Note that location_id must be refering to a GCP region; for example:
projects/redpepper-1290/locations/us-central1/instances/my-redis
Example ¶
ctx := context.Background() c, err := redis.NewCloudRedisClient(ctx) if err != nil { // TODO: Handle error. } // TODO: Use client. _ = c
Output:
func (*CloudRedisClient) Close ¶
func (c *CloudRedisClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*CloudRedisClient) Connection ¶
func (c *CloudRedisClient) Connection() *grpc.ClientConn
Connection returns the client's connection to the API service.
func (*CloudRedisClient) CreateInstance ¶
func (c *CloudRedisClient) CreateInstance(ctx context.Context, req *redispb.CreateInstanceRequest, opts ...gax.CallOption) (*CreateInstanceOperation, error)
CreateInstance creates a Redis instance based on the specified tier and memory size.
By default, the instance is peered to the project's default network (at /compute/docs/networks-and-firewalls#networks).
The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis instance will be fully functional. Completed longrunning.Operation will contain the new instance object in the response field.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Example ¶
ctx := context.Background() c, err := redis.NewCloudRedisClient(ctx) if err != nil { // TODO: Handle error. } req := &redispb.CreateInstanceRequest{ // TODO: Fill request struct fields. } op, err := c.CreateInstance(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Output:
func (*CloudRedisClient) CreateInstanceOperation ¶
func (c *CloudRedisClient) CreateInstanceOperation(name string) *CreateInstanceOperation
CreateInstanceOperation returns a new CreateInstanceOperation from a given name. The name must be that of a previously created CreateInstanceOperation, possibly from a different process.
func (*CloudRedisClient) DeleteInstance ¶
func (c *CloudRedisClient) DeleteInstance(ctx context.Context, req *redispb.DeleteInstanceRequest, opts ...gax.CallOption) (*DeleteInstanceOperation, error)
DeleteInstance deletes a specific Redis instance. Instance stops serving and data is deleted.
Example ¶
ctx := context.Background() c, err := redis.NewCloudRedisClient(ctx) if err != nil { // TODO: Handle error. } req := &redispb.DeleteInstanceRequest{ // TODO: Fill request struct fields. } op, err := c.DeleteInstance(ctx, req) if err != nil { // TODO: Handle error. } err = op.Wait(ctx) // TODO: Handle error.
Output:
func (*CloudRedisClient) DeleteInstanceOperation ¶
func (c *CloudRedisClient) DeleteInstanceOperation(name string) *DeleteInstanceOperation
DeleteInstanceOperation returns a new DeleteInstanceOperation from a given name. The name must be that of a previously created DeleteInstanceOperation, possibly from a different process.
func (*CloudRedisClient) GetInstance ¶
func (c *CloudRedisClient) GetInstance(ctx context.Context, req *redispb.GetInstanceRequest, opts ...gax.CallOption) (*redispb.Instance, error)
GetInstance gets the details of a specific Redis instance.
Example ¶
ctx := context.Background() c, err := redis.NewCloudRedisClient(ctx) if err != nil { // TODO: Handle error. } req := &redispb.GetInstanceRequest{ // TODO: Fill request struct fields. } resp, err := c.GetInstance(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Output:
func (*CloudRedisClient) ListInstances ¶
func (c *CloudRedisClient) ListInstances(ctx context.Context, req *redispb.ListInstancesRequest, opts ...gax.CallOption) *InstanceIterator
ListInstances lists all Redis instances 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.
Example ¶
ctx := context.Background() c, err := redis.NewCloudRedisClient(ctx) if err != nil { // TODO: Handle error. } req := &redispb.ListInstancesRequest{ // TODO: Fill request struct fields. } it := c.ListInstances(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*CloudRedisClient) UpdateInstance ¶
func (c *CloudRedisClient) UpdateInstance(ctx context.Context, req *redispb.UpdateInstanceRequest, opts ...gax.CallOption) (*UpdateInstanceOperation, error)
UpdateInstance updates the metadata and configuration of a specific Redis instance.
Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Example ¶
ctx := context.Background() c, err := redis.NewCloudRedisClient(ctx) if err != nil { // TODO: Handle error. } req := &redispb.UpdateInstanceRequest{ // TODO: Fill request struct fields. } op, err := c.UpdateInstance(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Output:
func (*CloudRedisClient) UpdateInstanceOperation ¶
func (c *CloudRedisClient) UpdateInstanceOperation(name string) *UpdateInstanceOperation
UpdateInstanceOperation returns a new UpdateInstanceOperation from a given name. The name must be that of a previously created UpdateInstanceOperation, possibly from a different process.
type CreateInstanceOperation ¶
type CreateInstanceOperation struct {
// contains filtered or unexported fields
}
CreateInstanceOperation manages a long-running operation from CreateInstance.
func (*CreateInstanceOperation) Done ¶
func (op *CreateInstanceOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*CreateInstanceOperation) Metadata ¶
func (op *CreateInstanceOperation) 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 (*CreateInstanceOperation) Name ¶
func (op *CreateInstanceOperation) 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 (*CreateInstanceOperation) Poll ¶
func (op *CreateInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*redispb.Instance, 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 (*CreateInstanceOperation) Wait ¶
func (op *CreateInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*redispb.Instance, 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 DeleteInstanceOperation ¶
type DeleteInstanceOperation struct {
// contains filtered or unexported fields
}
DeleteInstanceOperation manages a long-running operation from DeleteInstance.
func (*DeleteInstanceOperation) Done ¶
func (op *DeleteInstanceOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*DeleteInstanceOperation) Metadata ¶
func (op *DeleteInstanceOperation) 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 (*DeleteInstanceOperation) Name ¶
func (op *DeleteInstanceOperation) 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 (*DeleteInstanceOperation) Poll ¶
func (op *DeleteInstanceOperation) 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.
func (*DeleteInstanceOperation) Wait ¶
func (op *DeleteInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
Wait blocks until the long-running operation is completed, returning any error encountered.
See documentation of Poll for error-handling information.
type InstanceIterator ¶
type InstanceIterator struct { // 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 []*redispb.Instance, nextPageToken string, err error) // contains filtered or unexported fields }
InstanceIterator manages a stream of *redispb.Instance.
func (*InstanceIterator) Next ¶
func (it *InstanceIterator) Next() (*redispb.Instance, 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 (*InstanceIterator) PageInfo ¶
func (it *InstanceIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type UpdateInstanceOperation ¶
type UpdateInstanceOperation struct {
// contains filtered or unexported fields
}
UpdateInstanceOperation manages a long-running operation from UpdateInstance.
func (*UpdateInstanceOperation) Done ¶
func (op *UpdateInstanceOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*UpdateInstanceOperation) Metadata ¶
func (op *UpdateInstanceOperation) 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 (*UpdateInstanceOperation) Name ¶
func (op *UpdateInstanceOperation) 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 (*UpdateInstanceOperation) Poll ¶
func (op *UpdateInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*redispb.Instance, 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 (*UpdateInstanceOperation) Wait ¶
func (op *UpdateInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*redispb.Instance, 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.