Documentation

Overview

Copyright 2020 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package database is an auto-generated package for the Cloud Spanner Database Admin API.

Use of Context

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

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

For information about setting deadlines, reusing contexts, and more please visit pkg.go.dev/cloud.google.com/go.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DatabaseAdminDatabasePath

func DatabaseAdminDatabasePath(project, instance, database string) string

    DatabaseAdminDatabasePath returns the path for the database resource.

    Deprecated: Use

    fmt.Sprintf("projects/%s/instances/%s/databases/%s", project, instance, database)
    

    instead.

    func DatabaseAdminInstancePath

    func DatabaseAdminInstancePath(project, instance string) string

      DatabaseAdminInstancePath returns the path for the instance resource.

      Deprecated: Use

      fmt.Sprintf("projects/%s/instances/%s", project, instance)
      

      instead.

      func DefaultAuthScopes

      func DefaultAuthScopes() []string

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

        Types

        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 []*databasepb.Backup, nextPageToken string, err error)
        	// contains filtered or unexported fields
        }

          BackupIterator manages a stream of *databasepb.Backup.

          func (*BackupIterator) Next

          func (it *BackupIterator) Next() (*databasepb.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 CreateBackupOperation

              type CreateBackupOperation struct {
              	// contains filtered or unexported fields
              }

                CreateBackupOperation manages a long-running operation from CreateBackup.

                func (*CreateBackupOperation) Done

                func (op *CreateBackupOperation) Done() bool

                  Done reports whether the long-running operation has completed.

                  func (*CreateBackupOperation) Metadata

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

                    func (*CreateBackupOperation) Name

                    func (op *CreateBackupOperation) 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 (*CreateBackupOperation) Poll

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

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

                        If Poll fails, the error is returned and op is unmodified. If Poll succeeds 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 (*CreateBackupOperation) Wait

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

                          See documentation of Poll for error-handling information.

                          type CreateDatabaseOperation

                          type CreateDatabaseOperation struct {
                          	// contains filtered or unexported fields
                          }

                            CreateDatabaseOperation manages a long-running operation from CreateDatabase.

                            func (*CreateDatabaseOperation) Done

                            func (op *CreateDatabaseOperation) Done() bool

                              Done reports whether the long-running operation has completed.

                              func (*CreateDatabaseOperation) Metadata

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

                                func (*CreateDatabaseOperation) Name

                                func (op *CreateDatabaseOperation) 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 (*CreateDatabaseOperation) Poll

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

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

                                    If Poll fails, the error is returned and op is unmodified. If Poll succeeds 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 (*CreateDatabaseOperation) Wait

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

                                      See documentation of Poll for error-handling information.

                                      type DatabaseAdminCallOptions

                                      type DatabaseAdminCallOptions struct {
                                      	ListDatabases          []gax.CallOption
                                      	CreateDatabase         []gax.CallOption
                                      	GetDatabase            []gax.CallOption
                                      	UpdateDatabaseDdl      []gax.CallOption
                                      	DropDatabase           []gax.CallOption
                                      	GetDatabaseDdl         []gax.CallOption
                                      	SetIamPolicy           []gax.CallOption
                                      	GetIamPolicy           []gax.CallOption
                                      	TestIamPermissions     []gax.CallOption
                                      	CreateBackup           []gax.CallOption
                                      	GetBackup              []gax.CallOption
                                      	UpdateBackup           []gax.CallOption
                                      	DeleteBackup           []gax.CallOption
                                      	ListBackups            []gax.CallOption
                                      	RestoreDatabase        []gax.CallOption
                                      	ListDatabaseOperations []gax.CallOption
                                      	ListBackupOperations   []gax.CallOption
                                      }

                                        DatabaseAdminCallOptions contains the retry settings for each method of DatabaseAdminClient.

                                        type DatabaseAdminClient

                                        type DatabaseAdminClient 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 *DatabaseAdminCallOptions
                                        	// contains filtered or unexported fields
                                        }

                                          DatabaseAdminClient is a client for interacting with Cloud Spanner Database Admin API.

                                          Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

                                          func NewDatabaseAdminClient

                                          func NewDatabaseAdminClient(ctx context.Context, opts ...option.ClientOption) (*DatabaseAdminClient, error)

                                          NewDatabaseAdminClient creates a new database admin client.

                                          Cloud Spanner Database Admin API

                                          The Cloud Spanner Database Admin API can be used to create, drop, and list databases. It also enables updating the schema of pre-existing databases. It can be also used to create, delete and list backups for a database and to restore from an existing backup.

                                          Example
                                          Output:
                                          
                                          

                                          func (*DatabaseAdminClient) Close

                                          func (c *DatabaseAdminClient) Close() error

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

                                            func (*DatabaseAdminClient) Connection

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

                                              Connection returns a connection to the API service.

                                              Deprecated.

                                              func (*DatabaseAdminClient) CreateBackup

                                                CreateBackup starts creating a new Cloud Spanner Backup. The returned backup [long-running operation][google.longrunning.Operation] will have a name of the format projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id> and can be used to track creation of the backup. The metadata field type is CreateBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the creation and delete the backup. There can be only one pending backup creation per database. Backup creation of different databases can run concurrently.

                                                Example
                                                Output:
                                                
                                                

                                                func (*DatabaseAdminClient) CreateBackupOperation

                                                func (c *DatabaseAdminClient) CreateBackupOperation(name string) *CreateBackupOperation

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

                                                  func (*DatabaseAdminClient) CreateDatabase

                                                    CreateDatabase creates a new Cloud Spanner database and starts to prepare it for serving. The returned [long-running operation][google.longrunning.Operation] will have a name of the format <database_name>/operations/<operation_id> and can be used to track preparation of the database. The metadata field type is CreateDatabaseMetadata. The response field type is Database, if successful.

                                                    Example
                                                    Output:
                                                    
                                                    

                                                    func (*DatabaseAdminClient) CreateDatabaseOperation

                                                    func (c *DatabaseAdminClient) CreateDatabaseOperation(name string) *CreateDatabaseOperation

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

                                                      func (*DatabaseAdminClient) CreateDatabaseWithRetry

                                                      func (c *DatabaseAdminClient) CreateDatabaseWithRetry(ctx context.Context, req *databasepb.CreateDatabaseRequest, opts ...gax.CallOption) (*CreateDatabaseOperation, error)

                                                        CreateDatabaseWithRetry creates a new database and retries the call if the backend returns a retryable error. The actual CreateDatabase RPC is only retried if the initial call did not reach the server. In other cases, the client will query the backend for the long-running operation that was created by the initial RPC and return that operation.

                                                        func (*DatabaseAdminClient) DeleteBackup

                                                          DeleteBackup deletes a pending or completed Backup.

                                                          Example
                                                          Output:
                                                          
                                                          

                                                          func (*DatabaseAdminClient) DropDatabase

                                                            DropDatabase drops (aka deletes) a Cloud Spanner database. Completed backups for the database will be retained according to their expire_time.

                                                            Example
                                                            Output:
                                                            
                                                            

                                                            func (*DatabaseAdminClient) GetBackup

                                                              GetBackup gets metadata on a pending or completed Backup.

                                                              Example
                                                              Output:
                                                              
                                                              

                                                              func (*DatabaseAdminClient) GetDatabase

                                                                GetDatabase gets the state of a Cloud Spanner database.

                                                                Example
                                                                Output:
                                                                
                                                                

                                                                func (*DatabaseAdminClient) GetDatabaseDdl

                                                                  GetDatabaseDdl returns the schema of a Cloud Spanner database as a list of formatted DDL statements. This method does not show pending schema updates, those may be queried using the Operations API.

                                                                  Example
                                                                  Output:
                                                                  
                                                                  

                                                                  func (*DatabaseAdminClient) GetIamPolicy

                                                                  func (c *DatabaseAdminClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)

                                                                    GetIamPolicy gets the access control policy for a database or backup resource. Returns an empty policy if a database or backup exists but does not have a policy set.

                                                                    Authorization requires spanner.databases.getIamPolicy permission on resource. For backups, authorization requires spanner.backups.getIamPolicy permission on resource.

                                                                    Example
                                                                    Output:
                                                                    
                                                                    

                                                                    func (*DatabaseAdminClient) ListBackupOperations

                                                                      ListBackupOperations lists the backup [long-running operations][google.longrunning.Operation] in the given instance. A backup operation has a name of the form projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>. The long-running operation metadata field type metadata.type_url describes the type of the metadata. Operations returned include those that have completed/failed/canceled within the last 7 days, and pending operations. Operations returned are ordered by operation.metadata.value.progress.start_time in descending order starting from the most recently started operation.

                                                                      Example
                                                                      Output:
                                                                      
                                                                      

                                                                      func (*DatabaseAdminClient) ListBackups

                                                                        ListBackups lists completed and pending backups. Backups returned are ordered by create_time in descending order, starting from the most recent create_time.

                                                                        Example
                                                                        Output:
                                                                        
                                                                        

                                                                        func (*DatabaseAdminClient) ListDatabaseOperations

                                                                          ListDatabaseOperations lists database [longrunning-operations][google.longrunning.Operation]. A database operation has a name of the form projects/<project>/instances/<instance>/databases/<database>/operations/<operation>. The long-running operation metadata field type metadata.type_url describes the type of the metadata. Operations returned include those that have completed/failed/canceled within the last 7 days, and pending operations.

                                                                          Example
                                                                          Output:
                                                                          
                                                                          

                                                                          func (*DatabaseAdminClient) ListDatabases

                                                                            ListDatabases lists Cloud Spanner databases.

                                                                            Example
                                                                            Output:
                                                                            
                                                                            

                                                                            func (*DatabaseAdminClient) RestoreDatabase

                                                                              RestoreDatabase create a new database by restoring from a completed backup. The new database must be in the same project and in an instance with the same instance configuration as the instance containing the backup. The returned database [long-running operation][google.longrunning.Operation] has a name of the format projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>, and can be used to track the progress of the operation, and to cancel it. The metadata field type is RestoreDatabaseMetadata. The response type is Database, if successful. Cancelling the returned operation will stop the restore and delete the database. There can be only one database being restored into an instance at a time. Once the restore operation completes, a new restore operation can be initiated, without waiting for the optimize operation associated with the first restore to complete.

                                                                              Example
                                                                              Output:
                                                                              
                                                                              

                                                                              func (*DatabaseAdminClient) RestoreDatabaseOperation

                                                                              func (c *DatabaseAdminClient) RestoreDatabaseOperation(name string) *RestoreDatabaseOperation

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

                                                                                func (*DatabaseAdminClient) SetIamPolicy

                                                                                func (c *DatabaseAdminClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)

                                                                                  SetIamPolicy sets the access control policy on a database or backup resource. Replaces any existing policy.

                                                                                  Authorization requires spanner.databases.setIamPolicy permission on resource. For backups, authorization requires spanner.backups.setIamPolicy permission on resource.

                                                                                  Example
                                                                                  Output:
                                                                                  
                                                                                  

                                                                                  func (*DatabaseAdminClient) StartBackupOperation

                                                                                  func (c *DatabaseAdminClient) StartBackupOperation(ctx context.Context, backupID string, databasePath string, expireTime time.Time, opts ...gax.CallOption) (*CreateBackupOperation, error)

                                                                                    StartBackupOperation creates a backup of the given database. It will be stored as projects/<project>/instances/<instance>/backups/<backupID>. The backup will be automatically deleted by Cloud Spanner after its expiration.

                                                                                    backupID must be unique across an instance.

                                                                                    expireTime is the time the backup will expire. It is respected to microsecond granularity.

                                                                                    databasePath must have the form projects/<project>/instances/<instance>/databases/<database>.

                                                                                    func (*DatabaseAdminClient) TestIamPermissions

                                                                                      TestIamPermissions returns permissions that the caller has on the specified database or backup resource.

                                                                                      Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has spanner.databases.list permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has spanner.backups.list permission on the containing instance.

                                                                                      Example
                                                                                      Output:
                                                                                      
                                                                                      

                                                                                      func (*DatabaseAdminClient) UpdateBackup

                                                                                        UpdateBackup updates a pending or completed Backup.

                                                                                        Example
                                                                                        Output:
                                                                                        
                                                                                        

                                                                                        func (*DatabaseAdminClient) UpdateDatabaseDdl

                                                                                          UpdateDatabaseDdl updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns, indexes, etc. The returned [long-running operation][google.longrunning.Operation] will have a name of the format <database_name>/operations/<operation_id> and can be used to track execution of the schema change(s). The metadata field type is UpdateDatabaseDdlMetadata. The operation has no response.

                                                                                          Example
                                                                                          Output:
                                                                                          
                                                                                          

                                                                                          func (*DatabaseAdminClient) UpdateDatabaseDdlOperation

                                                                                          func (c *DatabaseAdminClient) UpdateDatabaseDdlOperation(name string) *UpdateDatabaseDdlOperation

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

                                                                                            type DatabaseIterator

                                                                                            type DatabaseIterator 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 []*databasepb.Database, nextPageToken string, err error)
                                                                                            	// contains filtered or unexported fields
                                                                                            }

                                                                                              DatabaseIterator manages a stream of *databasepb.Database.

                                                                                              func (*DatabaseIterator) Next

                                                                                              func (it *DatabaseIterator) Next() (*databasepb.Database, 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 (*DatabaseIterator) PageInfo

                                                                                                func (it *DatabaseIterator) 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) Next

                                                                                                      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 RestoreDatabaseOperation

                                                                                                        type RestoreDatabaseOperation struct {
                                                                                                        	// contains filtered or unexported fields
                                                                                                        }

                                                                                                          RestoreDatabaseOperation manages a long-running operation from RestoreDatabase.

                                                                                                          func (*RestoreDatabaseOperation) Done

                                                                                                          func (op *RestoreDatabaseOperation) Done() bool

                                                                                                            Done reports whether the long-running operation has completed.

                                                                                                            func (*RestoreDatabaseOperation) Metadata

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

                                                                                                              func (*RestoreDatabaseOperation) Name

                                                                                                              func (op *RestoreDatabaseOperation) 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 (*RestoreDatabaseOperation) Poll

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

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

                                                                                                                  If Poll fails, the error is returned and op is unmodified. If Poll succeeds 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 (*RestoreDatabaseOperation) Wait

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

                                                                                                                    See documentation of Poll for error-handling information.

                                                                                                                    type UpdateDatabaseDdlOperation

                                                                                                                    type UpdateDatabaseDdlOperation struct {
                                                                                                                    	// contains filtered or unexported fields
                                                                                                                    }

                                                                                                                      UpdateDatabaseDdlOperation manages a long-running operation from UpdateDatabaseDdl.

                                                                                                                      func (*UpdateDatabaseDdlOperation) Done

                                                                                                                      func (op *UpdateDatabaseDdlOperation) Done() bool

                                                                                                                        Done reports whether the long-running operation has completed.

                                                                                                                        func (*UpdateDatabaseDdlOperation) Metadata

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

                                                                                                                          func (*UpdateDatabaseDdlOperation) Name

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

                                                                                                                            func (*UpdateDatabaseDdlOperation) Poll

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

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

                                                                                                                              If Poll fails, the error is returned and op is unmodified. If Poll succeeds 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 (*UpdateDatabaseDdlOperation) Wait

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

                                                                                                                                See documentation of Poll for error-handling information.