Package com.google.cloud.spanner.spi.v1
Interface SpannerRpc
-
- All Superinterfaces:
com.google.cloud.ServiceRpc
- All Known Implementing Classes:
GapicSpannerRpc
@InternalApi public interface SpannerRpc extends com.google.cloud.ServiceRpc
Abstracts remote calls to the Cloud Spanner service. Typically end-consumer code will never use this interface; it's main purpose is to abstract the implementation of the public Cloud Spanner API from the underlying transport mechanism.Each
SpannerRPC
instance is bound to a particular project and set of authorization credentials.The interface is currently defined in terms of the generated HTTP client model classes. This is purely for expedience; a future version of this interface is likely to be independent of transport to allow switching between gRPC and HTTP.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
SpannerRpc.Option
Options passed inSpannerRpc
methods to control how an RPC is issued.static class
SpannerRpc.Paginated<T>
Represents results from paginated RPCs, i.e., those where up to a maximum number of items is returned from each call and a followup call must be made to fetch more.static interface
SpannerRpc.ResultStreamConsumer
Consumer for the results produced by a streaming read or query call.static interface
SpannerRpc.StreamingCall
Handle for cancellation of a streaming read or query call.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description com.google.api.core.ApiFuture<com.google.protobuf.Empty>
asyncDeleteSession(String sessionName, Map<SpannerRpc.Option,?> options)
List<Session>
batchCreateSessions(String databaseName, int sessionCount, String databaseRole, Map<String,String> labels, Map<SpannerRpc.Option,?> options)
Transaction
beginTransaction(BeginTransactionRequest request, Map<SpannerRpc.Option,?> options, boolean routeToLeader)
Begins a transaction.com.google.api.core.ApiFuture<Transaction>
beginTransactionAsync(BeginTransactionRequest request, Map<SpannerRpc.Option,?> options, boolean routeToLeader)
Begins a transaction asynchronously.void
cancelOperation(String name)
Cancels the specified long-running operation.CommitResponse
commit(CommitRequest commitRequest, Map<SpannerRpc.Option,?> options)
com.google.api.core.ApiFuture<CommitResponse>
commitAsync(CommitRequest commitRequest, Map<SpannerRpc.Option,?> options)
default com.google.api.gax.longrunning.OperationFuture<Backup,CopyBackupMetadata>
copyBackup(BackupId sourceBackupId, Backup destinationBackup)
Creates a copy backup from the source backup specified.com.google.api.gax.longrunning.OperationFuture<Backup,CreateBackupMetadata>
createBackup(Backup backupInfo)
Creates a new backup from the source database specified in theBackup
instance.com.google.api.gax.longrunning.OperationFuture<Database,CreateDatabaseMetadata>
createDatabase(String instanceName, String createDatabaseStatement, Iterable<String> additionalStatements, Database database)
com.google.api.gax.longrunning.OperationFuture<Instance,CreateInstanceMetadata>
createInstance(String parent, String instanceId, Instance instance)
default com.google.api.gax.longrunning.OperationFuture<InstanceConfig,CreateInstanceConfigMetadata>
createInstanceConfig(String parent, String instanceConfigId, InstanceConfig instanceConfig, Boolean validateOnly)
Session
createSession(String databaseName, String databaseRole, Map<String,String> labels, Map<SpannerRpc.Option,?> options)
void
deleteBackup(String backupName)
Deletes a pending or completed backup.void
deleteInstance(String instanceName)
default void
deleteInstanceConfig(String instanceConfigName, String etag, Boolean validateOnly)
void
deleteSession(String sessionName, Map<SpannerRpc.Option,?> options)
void
dropDatabase(String databaseName)
ExecuteBatchDmlResponse
executeBatchDml(ExecuteBatchDmlRequest build, Map<SpannerRpc.Option,?> options)
com.google.api.core.ApiFuture<ExecuteBatchDmlResponse>
executeBatchDmlAsync(ExecuteBatchDmlRequest build, Map<SpannerRpc.Option,?> options)
ResultSet
executePartitionedDml(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options)
SpannerRpc.StreamingCall
executeQuery(ExecuteSqlRequest request, SpannerRpc.ResultStreamConsumer consumer, Map<SpannerRpc.Option,?> options, boolean routeToLeader)
Executes a query with streaming result.ResultSet
executeQuery(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options, boolean routeToLeader)
Executes a query.com.google.api.core.ApiFuture<ResultSet>
executeQueryAsync(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options, boolean routeToLeader)
Executes a query asynchronously.com.google.api.gax.rpc.ServerStream<PartialResultSet>
executeStreamingPartitionedDml(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options, org.threeten.bp.Duration timeout)
Backup
getBackup(String backupName)
Gets the backup with the specified name.Database
getDatabase(String databaseName)
com.google.iam.v1.Policy
getDatabaseAdminIAMPolicy(String resource, com.google.iam.v1.GetPolicyOptions options)
Gets the IAM policy for the given resource using theDatabaseAdminStub
.List<String>
getDatabaseDdl(String databaseName)
Instance
getInstance(String instanceName)
com.google.iam.v1.Policy
getInstanceAdminIAMPolicy(String resource)
Gets the IAM policy for the given resource using theInstanceAdminStub
.InstanceConfig
getInstanceConfig(String instanceConfigName)
com.google.longrunning.Operation
getOperation(String name)
Retrieves a long running operation.com.google.api.gax.retrying.RetrySettings
getPartitionedDmlRetrySettings()
boolean
isClosed()
SpannerRpc.Paginated<com.google.longrunning.Operation>
listBackupOperations(String instanceName, int pageSize, String filter, String pageToken)
List all long-running backup operations on the given instance.SpannerRpc.Paginated<Backup>
listBackups(String instanceName, int pageSize, String filter, String pageToken)
Lists the backups in the specified instance.SpannerRpc.Paginated<com.google.longrunning.Operation>
listDatabaseOperations(String instanceName, int pageSize, String filter, String pageToken)
SpannerRpc.Paginated<DatabaseRole>
listDatabaseRoles(String databaseName, int pageSize, String pageToken)
SpannerRpc.Paginated<Database>
listDatabases(String instanceName, int pageSize, String pageToken)
default SpannerRpc.Paginated<com.google.longrunning.Operation>
listInstanceConfigOperations(int pageSize, String filter, String pageToken)
List all long-running instance config operations on the given project.SpannerRpc.Paginated<InstanceConfig>
listInstanceConfigs(int pageSize, String pageToken)
SpannerRpc.Paginated<Instance>
listInstances(int pageSize, String pageToken, String filter)
PartitionResponse
partitionQuery(PartitionQueryRequest request, Map<SpannerRpc.Option,?> options)
PartitionResponse
partitionRead(PartitionReadRequest request, Map<SpannerRpc.Option,?> options)
SpannerRpc.StreamingCall
read(ReadRequest request, SpannerRpc.ResultStreamConsumer consumer, Map<SpannerRpc.Option,?> options, boolean routeToLeader)
Performs a streaming read.com.google.api.gax.longrunning.OperationFuture<Database,RestoreDatabaseMetadata>
restoreDatabase(Restore restore)
Restore a backup into the given database.void
rollback(RollbackRequest request, Map<SpannerRpc.Option,?> options)
com.google.api.core.ApiFuture<com.google.protobuf.Empty>
rollbackAsync(RollbackRequest request, Map<SpannerRpc.Option,?> options)
com.google.iam.v1.Policy
setDatabaseAdminIAMPolicy(String resource, com.google.iam.v1.Policy policy)
Updates the IAM policy for the given resource using theDatabaseAdminStub
.com.google.iam.v1.Policy
setInstanceAdminIAMPolicy(String resource, com.google.iam.v1.Policy policy)
Updates the IAM policy for the given resource using theInstanceAdminStub
.void
shutdown()
com.google.iam.v1.TestIamPermissionsResponse
testDatabaseAdminIAMPermissions(String resource, Iterable<String> permissions)
Tests the IAM permissions for the given resource using theDatabaseAdminStub
.com.google.iam.v1.TestIamPermissionsResponse
testInstanceAdminIAMPermissions(String resource, Iterable<String> permissions)
Tests the IAM permissions for the given resource using theInstanceAdminStub
.Backup
updateBackup(Backup backup, com.google.protobuf.FieldMask updateMask)
Updates the specified backup.com.google.api.gax.longrunning.OperationFuture<Database,UpdateDatabaseMetadata>
updateDatabase(Database database, com.google.protobuf.FieldMask fieldMask)
Updates the specified fields of a Cloud Spanner database.com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,UpdateDatabaseDdlMetadata>
updateDatabaseDdl(String databaseName, Iterable<String> updateDatabaseStatements, String updateId)
com.google.api.gax.longrunning.OperationFuture<Instance,UpdateInstanceMetadata>
updateInstance(Instance instance, com.google.protobuf.FieldMask fieldMask)
default com.google.api.gax.longrunning.OperationFuture<InstanceConfig,UpdateInstanceConfigMetadata>
updateInstanceConfig(InstanceConfig instanceConfig, Boolean validateOnly, com.google.protobuf.FieldMask fieldMask)
-
-
-
Method Detail
-
listInstanceConfigs
SpannerRpc.Paginated<InstanceConfig> listInstanceConfigs(int pageSize, @Nullable String pageToken) throws SpannerException
- Throws:
SpannerException
-
createInstanceConfig
default com.google.api.gax.longrunning.OperationFuture<InstanceConfig,CreateInstanceConfigMetadata> createInstanceConfig(String parent, String instanceConfigId, InstanceConfig instanceConfig, @Nullable Boolean validateOnly) throws SpannerException
- Throws:
SpannerException
-
updateInstanceConfig
default com.google.api.gax.longrunning.OperationFuture<InstanceConfig,UpdateInstanceConfigMetadata> updateInstanceConfig(InstanceConfig instanceConfig, @Nullable Boolean validateOnly, com.google.protobuf.FieldMask fieldMask) throws SpannerException
- Throws:
SpannerException
-
getInstanceConfig
InstanceConfig getInstanceConfig(String instanceConfigName) throws SpannerException
- Throws:
SpannerException
-
deleteInstanceConfig
default void deleteInstanceConfig(String instanceConfigName, @Nullable String etag, @Nullable Boolean validateOnly) throws SpannerException
- Throws:
SpannerException
-
listInstanceConfigOperations
default SpannerRpc.Paginated<com.google.longrunning.Operation> listInstanceConfigOperations(int pageSize, @Nullable String filter, @Nullable String pageToken)
List all long-running instance config operations on the given project.
-
listInstances
SpannerRpc.Paginated<Instance> listInstances(int pageSize, @Nullable String pageToken, @Nullable String filter) throws SpannerException
- Throws:
SpannerException
-
createInstance
com.google.api.gax.longrunning.OperationFuture<Instance,CreateInstanceMetadata> createInstance(String parent, String instanceId, Instance instance) throws SpannerException
- Throws:
SpannerException
-
updateInstance
com.google.api.gax.longrunning.OperationFuture<Instance,UpdateInstanceMetadata> updateInstance(Instance instance, com.google.protobuf.FieldMask fieldMask) throws SpannerException
- Throws:
SpannerException
-
getInstance
Instance getInstance(String instanceName) throws SpannerException
- Throws:
SpannerException
-
deleteInstance
void deleteInstance(String instanceName) throws SpannerException
- Throws:
SpannerException
-
listDatabases
SpannerRpc.Paginated<Database> listDatabases(String instanceName, int pageSize, @Nullable String pageToken) throws SpannerException
- Throws:
SpannerException
-
createDatabase
com.google.api.gax.longrunning.OperationFuture<Database,CreateDatabaseMetadata> createDatabase(String instanceName, String createDatabaseStatement, Iterable<String> additionalStatements, Database database) throws SpannerException
- Throws:
SpannerException
-
updateDatabaseDdl
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,UpdateDatabaseDdlMetadata> updateDatabaseDdl(String databaseName, Iterable<String> updateDatabaseStatements, @Nullable String updateId) throws SpannerException
- Throws:
SpannerException
-
dropDatabase
void dropDatabase(String databaseName) throws SpannerException
- Throws:
SpannerException
-
getDatabase
Database getDatabase(String databaseName) throws SpannerException
- Throws:
SpannerException
-
updateDatabase
com.google.api.gax.longrunning.OperationFuture<Database,UpdateDatabaseMetadata> updateDatabase(Database database, com.google.protobuf.FieldMask fieldMask) throws SpannerException
Updates the specified fields of a Cloud Spanner database.- Parameters:
database
- The database proto whose field values will be used as the new values in the stored database.fieldMask
- The fields to update. Currently, only the "enable_drop_protection" field of the database supports updates.- Returns:
- an `OperationFuture` that can be used to track the status of the update.
- Throws:
SpannerException
-
getDatabaseDdl
List<String> getDatabaseDdl(String databaseName) throws SpannerException
- Throws:
SpannerException
-
listBackups
SpannerRpc.Paginated<Backup> listBackups(String instanceName, int pageSize, @Nullable String filter, @Nullable String pageToken) throws SpannerException
Lists the backups in the specified instance.- Throws:
SpannerException
-
createBackup
com.google.api.gax.longrunning.OperationFuture<Backup,CreateBackupMetadata> createBackup(Backup backupInfo) throws SpannerException
Creates a new backup from the source database specified in theBackup
instance.- Parameters:
backupInfo
- the backup to create. The instance, database and expireTime fields of the backup must be filled.- Returns:
- the operation that monitors the backup creation.
- Throws:
SpannerException
-
copyBackup
default com.google.api.gax.longrunning.OperationFuture<Backup,CopyBackupMetadata> copyBackup(BackupId sourceBackupId, Backup destinationBackup)
Creates a copy backup from the source backup specified.- Parameters:
destinationBackup
- the backup to create. The instance, database, and expireTime fields of the backup must be filled. It may also optionally have an encryption config set. If no encryption config has been set, the new backup will use the same encryption config as the source backup.- Returns:
- the operation that monitors the backup creation.
-
restoreDatabase
com.google.api.gax.longrunning.OperationFuture<Database,RestoreDatabaseMetadata> restoreDatabase(Restore restore)
Restore a backup into the given database.- Parameters:
restore
- aRestore
instance with the backup source and destination database
-
getBackup
Backup getBackup(String backupName) throws SpannerException
Gets the backup with the specified name.- Throws:
SpannerException
-
updateBackup
Backup updateBackup(Backup backup, com.google.protobuf.FieldMask updateMask)
Updates the specified backup. The only supported field for updates is expireTime.
-
listBackupOperations
SpannerRpc.Paginated<com.google.longrunning.Operation> listBackupOperations(String instanceName, int pageSize, @Nullable String filter, @Nullable String pageToken)
List all long-running backup operations on the given instance.
-
deleteBackup
void deleteBackup(String backupName)
Deletes a pending or completed backup.- Parameters:
backupName
- Required. The fully qualified name of the backup to delete.
-
listDatabaseOperations
SpannerRpc.Paginated<com.google.longrunning.Operation> listDatabaseOperations(String instanceName, int pageSize, @Nullable String filter, @Nullable String pageToken)
-
listDatabaseRoles
SpannerRpc.Paginated<DatabaseRole> listDatabaseRoles(String databaseName, int pageSize, @Nullable String pageToken)
-
getOperation
com.google.longrunning.Operation getOperation(String name) throws SpannerException
Retrieves a long running operation.- Throws:
SpannerException
-
cancelOperation
void cancelOperation(String name) throws SpannerException
Cancels the specified long-running operation.- Throws:
SpannerException
-
batchCreateSessions
List<Session> batchCreateSessions(String databaseName, int sessionCount, @Nullable String databaseRole, @Nullable Map<String,String> labels, @Nullable Map<SpannerRpc.Option,?> options) throws SpannerException
- Throws:
SpannerException
-
createSession
Session createSession(String databaseName, @Nullable String databaseRole, @Nullable Map<String,String> labels, @Nullable Map<SpannerRpc.Option,?> options) throws SpannerException
- Throws:
SpannerException
-
deleteSession
void deleteSession(String sessionName, @Nullable Map<SpannerRpc.Option,?> options) throws SpannerException
- Throws:
SpannerException
-
asyncDeleteSession
com.google.api.core.ApiFuture<com.google.protobuf.Empty> asyncDeleteSession(String sessionName, @Nullable Map<SpannerRpc.Option,?> options) throws SpannerException
- Throws:
SpannerException
-
read
SpannerRpc.StreamingCall read(ReadRequest request, SpannerRpc.ResultStreamConsumer consumer, @Nullable Map<SpannerRpc.Option,?> options, boolean routeToLeader)
Performs a streaming read.- Parameters:
routeToLeader
- Set to true to route the request to the leader region, and false to route the request to any region. When leader aware routing is enabled, RW/PDML requests are preferred to be routed to the leader region, and RO requests (except for PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.
-
executeQuery
ResultSet executeQuery(ExecuteSqlRequest request, @Nullable Map<SpannerRpc.Option,?> options, boolean routeToLeader)
Executes a query.- Parameters:
routeToLeader
- Set to true to route the request to the leader region, and false to route the request to any region. When leader aware routing is enabled, RW/PDML requests are preferred to be routed to the leader region, and RO requests (except for PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.
-
executeQueryAsync
com.google.api.core.ApiFuture<ResultSet> executeQueryAsync(ExecuteSqlRequest request, @Nullable Map<SpannerRpc.Option,?> options, boolean routeToLeader)
Executes a query asynchronously.- Parameters:
routeToLeader
- Set to true to route the request to the leader region, and false to route the request to any region. When leader aware routing is enabled, RW/PDML requests are preferred to be routed to the leader region, and RO requests (except for PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.
-
executePartitionedDml
ResultSet executePartitionedDml(ExecuteSqlRequest request, @Nullable Map<SpannerRpc.Option,?> options)
-
getPartitionedDmlRetrySettings
com.google.api.gax.retrying.RetrySettings getPartitionedDmlRetrySettings()
-
executeStreamingPartitionedDml
com.google.api.gax.rpc.ServerStream<PartialResultSet> executeStreamingPartitionedDml(ExecuteSqlRequest request, @Nullable Map<SpannerRpc.Option,?> options, org.threeten.bp.Duration timeout)
-
executeQuery
SpannerRpc.StreamingCall executeQuery(ExecuteSqlRequest request, SpannerRpc.ResultStreamConsumer consumer, @Nullable Map<SpannerRpc.Option,?> options, boolean routeToLeader)
Executes a query with streaming result.- Parameters:
routeToLeader
- Set to true to route the request to the leader region, and false to route the request to any region. When leader aware routing is enabled, RW/PDML requests are preferred to be routed to the leader region, and RO requests (except for PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.
-
executeBatchDml
ExecuteBatchDmlResponse executeBatchDml(ExecuteBatchDmlRequest build, Map<SpannerRpc.Option,?> options)
-
executeBatchDmlAsync
com.google.api.core.ApiFuture<ExecuteBatchDmlResponse> executeBatchDmlAsync(ExecuteBatchDmlRequest build, Map<SpannerRpc.Option,?> options)
-
beginTransaction
Transaction beginTransaction(BeginTransactionRequest request, @Nullable Map<SpannerRpc.Option,?> options, boolean routeToLeader) throws SpannerException
Begins a transaction.- Parameters:
routeToLeader
- Set to true to route the request to the leader region, and false to route the request to any region. When leader aware routing is enabled, RW/PDML requests are preferred to be routed to the leader region, and RO requests (except for PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.- Throws:
SpannerException
-
beginTransactionAsync
com.google.api.core.ApiFuture<Transaction> beginTransactionAsync(BeginTransactionRequest request, @Nullable Map<SpannerRpc.Option,?> options, boolean routeToLeader)
Begins a transaction asynchronously.- Parameters:
routeToLeader
- Set to true to route the request to the leader region, and false to route the request to any region. When leader aware routing is enabled, RW/PDML requests are preferred to be routed to the leader region, and RO requests (except for PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.
-
commit
CommitResponse commit(CommitRequest commitRequest, @Nullable Map<SpannerRpc.Option,?> options) throws SpannerException
- Throws:
SpannerException
-
commitAsync
com.google.api.core.ApiFuture<CommitResponse> commitAsync(CommitRequest commitRequest, @Nullable Map<SpannerRpc.Option,?> options)
-
rollback
void rollback(RollbackRequest request, @Nullable Map<SpannerRpc.Option,?> options) throws SpannerException
- Throws:
SpannerException
-
rollbackAsync
com.google.api.core.ApiFuture<com.google.protobuf.Empty> rollbackAsync(RollbackRequest request, @Nullable Map<SpannerRpc.Option,?> options)
-
partitionQuery
PartitionResponse partitionQuery(PartitionQueryRequest request, @Nullable Map<SpannerRpc.Option,?> options) throws SpannerException
- Throws:
SpannerException
-
partitionRead
PartitionResponse partitionRead(PartitionReadRequest request, @Nullable Map<SpannerRpc.Option,?> options) throws SpannerException
- Throws:
SpannerException
-
getDatabaseAdminIAMPolicy
com.google.iam.v1.Policy getDatabaseAdminIAMPolicy(String resource, @Nullable com.google.iam.v1.GetPolicyOptions options)
Gets the IAM policy for the given resource using theDatabaseAdminStub
.
-
setDatabaseAdminIAMPolicy
com.google.iam.v1.Policy setDatabaseAdminIAMPolicy(String resource, com.google.iam.v1.Policy policy)
Updates the IAM policy for the given resource using theDatabaseAdminStub
. It is highly recommended to first get the current policy and base the updated policy on the returned policy. SeePolicy.Builder.setEtag(com.google.protobuf.ByteString)
for information on the recommended read-modify-write cycle.
-
testDatabaseAdminIAMPermissions
com.google.iam.v1.TestIamPermissionsResponse testDatabaseAdminIAMPermissions(String resource, Iterable<String> permissions)
Tests the IAM permissions for the given resource using theDatabaseAdminStub
.
-
getInstanceAdminIAMPolicy
com.google.iam.v1.Policy getInstanceAdminIAMPolicy(String resource)
Gets the IAM policy for the given resource using theInstanceAdminStub
.
-
setInstanceAdminIAMPolicy
com.google.iam.v1.Policy setInstanceAdminIAMPolicy(String resource, com.google.iam.v1.Policy policy)
Updates the IAM policy for the given resource using theInstanceAdminStub
. It is highly recommended to first get the current policy and base the updated policy on the returned policy. SeePolicy.Builder.setEtag(com.google.protobuf.ByteString)
for information on the recommended read-modify-write cycle.
-
testInstanceAdminIAMPermissions
com.google.iam.v1.TestIamPermissionsResponse testInstanceAdminIAMPermissions(String resource, Iterable<String> permissions)
Tests the IAM permissions for the given resource using theInstanceAdminStub
.
-
shutdown
void shutdown()
-
isClosed
boolean isClosed()
-
-