diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClient.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClient.java index 112b43e2ef..27dd9c515a 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClient.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClient.java @@ -210,138 +210,6 @@ public final OperationsClient getOperationsClient() { return operationsClient; } - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists Cloud Spanner databases. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   for (Database element : databaseAdminClient.listDatabases(parent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param parent Required. The instance whose databases should be listed. Values are of the form - * `projects/<project>/instances/<instance>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDatabasesPagedResponse listDatabases(InstanceName parent) { - ListDatabasesRequest request = - ListDatabasesRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .build(); - return listDatabases(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists Cloud Spanner databases. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   for (Database element : databaseAdminClient.listDatabases(parent.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param parent Required. The instance whose databases should be listed. Values are of the form - * `projects/<project>/instances/<instance>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDatabasesPagedResponse listDatabases(String parent) { - ListDatabasesRequest request = ListDatabasesRequest.newBuilder().setParent(parent).build(); - return listDatabases(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists Cloud Spanner databases. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   ListDatabasesRequest request = ListDatabasesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   for (Database element : databaseAdminClient.listDatabases(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDatabasesPagedResponse listDatabases(ListDatabasesRequest request) { - return listDatabasesPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists Cloud Spanner databases. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   ListDatabasesRequest request = ListDatabasesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   ApiFuture<ListDatabasesPagedResponse> future = databaseAdminClient.listDatabasesPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (Database element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listDatabasesPagedCallable() { - return stub.listDatabasesPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists Cloud Spanner databases. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   ListDatabasesRequest request = ListDatabasesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   while (true) {
-   *     ListDatabasesResponse response = databaseAdminClient.listDatabasesCallable().call(request);
-   *     for (Database element : response.getDatabasesList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable listDatabasesCallable() { - return stub.listDatabasesCallable(); - } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Creates a new Cloud Spanner database and starts to prepare it for serving. The returned @@ -520,96 +388,6 @@ public final UnaryCallable createDatabaseCalla return stub.createDatabaseCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets the state of a Cloud Spanner database. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
-   *   Database response = databaseAdminClient.getDatabase(name);
-   * }
-   * 
- * - * @param name Required. The name of the requested database. Values are of the form - * `projects/<project>/instances/<instance>/databases/<database>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Database getDatabase(DatabaseName name) { - GetDatabaseRequest request = - GetDatabaseRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - return getDatabase(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets the state of a Cloud Spanner database. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
-   *   Database response = databaseAdminClient.getDatabase(name.toString());
-   * }
-   * 
- * - * @param name Required. The name of the requested database. Values are of the form - * `projects/<project>/instances/<instance>/databases/<database>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Database getDatabase(String name) { - GetDatabaseRequest request = GetDatabaseRequest.newBuilder().setName(name).build(); - return getDatabase(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets the state of a Cloud Spanner database. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
-   *   GetDatabaseRequest request = GetDatabaseRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   Database response = databaseAdminClient.getDatabase(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Database getDatabase(GetDatabaseRequest request) { - return getDatabaseCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets the state of a Cloud Spanner database. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
-   *   GetDatabaseRequest request = GetDatabaseRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Database> future = databaseAdminClient.getDatabaseCallable().futureCall(request);
-   *   // Do something
-   *   Database response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable getDatabaseCallable() { - return stub.getDatabaseCallable(); - } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns, @@ -736,46 +514,696 @@ public final OperationFuture updateDatabaseDdl * .setDatabase(database.toString()) * .addAllStatements(statements) * .build(); - * OperationFuture<Empty, UpdateDatabaseDdlMetadata> future = databaseAdminClient.updateDatabaseDdlOperationCallable().futureCall(request); - * // Do something - * future.get(); + * OperationFuture<Empty, UpdateDatabaseDdlMetadata> future = databaseAdminClient.updateDatabaseDdlOperationCallable().futureCall(request); + * // Do something + * future.get(); + * } + * + */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public final OperationCallable + updateDatabaseDdlOperationCallable() { + return stub.updateDatabaseDdlOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * 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][google.longrunning.Operation.metadata] + * field type is + * [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The + * operation has no response. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
+   *   List<String> statements = new ArrayList<>();
+   *   UpdateDatabaseDdlRequest request = UpdateDatabaseDdlRequest.newBuilder()
+   *     .setDatabase(database.toString())
+   *     .addAllStatements(statements)
+   *     .build();
+   *   ApiFuture<Operation> future = databaseAdminClient.updateDatabaseDdlCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable updateDatabaseDdlCallable() { + return stub.updateDatabaseDdlCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * 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][google.longrunning.Operation.metadata] field type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Backup][google.spanner.admin.database.v1.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. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   Backup backup = Backup.newBuilder().build();
+   *   String backupId = "";
+   *   Backup response = databaseAdminClient.createBackupAsync(parent, backup, backupId).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the instance in which the backup will be created. This must + * be the same instance that contains the database the backup will be created from. The backup + * will be stored in the location(s) specified in the instance configuration of this instance. + * Values are of the form `projects/<project>/instances/<instance>`. + * @param backup Required. The backup to create. + * @param backupId Required. The id of the backup to be created. The `backup_id` appended to + * `parent` forms the full backup name of the form + * `projects/<project>/instances/<instance>/backups/<backup_id>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture createBackupAsync( + InstanceName parent, Backup backup, String backupId) { + CreateBackupRequest request = + CreateBackupRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setBackup(backup) + .setBackupId(backupId) + .build(); + return createBackupAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * 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][google.longrunning.Operation.metadata] field type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Backup][google.spanner.admin.database.v1.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. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   Backup backup = Backup.newBuilder().build();
+   *   String backupId = "";
+   *   Backup response = databaseAdminClient.createBackupAsync(parent.toString(), backup, backupId).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the instance in which the backup will be created. This must + * be the same instance that contains the database the backup will be created from. The backup + * will be stored in the location(s) specified in the instance configuration of this instance. + * Values are of the form `projects/<project>/instances/<instance>`. + * @param backup Required. The backup to create. + * @param backupId Required. The id of the backup to be created. The `backup_id` appended to + * `parent` forms the full backup name of the form + * `projects/<project>/instances/<instance>/backups/<backup_id>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture createBackupAsync( + String parent, Backup backup, String backupId) { + CreateBackupRequest request = + CreateBackupRequest.newBuilder() + .setParent(parent) + .setBackup(backup) + .setBackupId(backupId) + .build(); + return createBackupAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * 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][google.longrunning.Operation.metadata] field type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Backup][google.spanner.admin.database.v1.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. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String backupId = "";
+   *   Backup backup = Backup.newBuilder().build();
+   *   CreateBackupRequest request = CreateBackupRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setBackupId(backupId)
+   *     .setBackup(backup)
+   *     .build();
+   *   Backup response = databaseAdminClient.createBackupAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture createBackupAsync( + CreateBackupRequest request) { + return createBackupOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * 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][google.longrunning.Operation.metadata] field type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Backup][google.spanner.admin.database.v1.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. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String backupId = "";
+   *   Backup backup = Backup.newBuilder().build();
+   *   CreateBackupRequest request = CreateBackupRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setBackupId(backupId)
+   *     .setBackup(backup)
+   *     .build();
+   *   OperationFuture<Backup, CreateBackupMetadata> future = databaseAdminClient.createBackupOperationCallable().futureCall(request);
+   *   // Do something
+   *   Backup response = future.get();
+   * }
+   * 
+ */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public final OperationCallable + createBackupOperationCallable() { + return stub.createBackupOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * 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][google.longrunning.Operation.metadata] field type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Backup][google.spanner.admin.database.v1.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. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String backupId = "";
+   *   Backup backup = Backup.newBuilder().build();
+   *   CreateBackupRequest request = CreateBackupRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setBackupId(backupId)
+   *     .setBackup(backup)
+   *     .build();
+   *   ApiFuture<Operation> future = databaseAdminClient.createBackupCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable createBackupCallable() { + return stub.createBackupCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * 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][google.longrunning.Operation.metadata] field type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. The + * [response][google.longrunning.Operation.response] type is + * [Database][google.spanner.admin.database.v1.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. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String databaseId = "";
+   *   BackupName backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
+   *   Database response = databaseAdminClient.restoreDatabaseAsync(parent, databaseId, backup).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the instance in which to create the restored database. This + * instance must be in the same project and have the same instance configuration as the + * instance containing the source backup. Values are of the form + * `projects/<project>/instances/<instance>`. + * @param databaseId Required. The id of the database to create and restore to. This database must + * not already exist. The `database_id` appended to `parent` forms the full database name of + * the form + * `projects/<project>/instances/<instance>/databases/<database_id>`. + * @param backup Name of the backup from which to restore. Values are of the form + * `projects/<project>/instances/<instance>/backups/<backup>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture restoreDatabaseAsync( + InstanceName parent, String databaseId, BackupName backup) { + RestoreDatabaseRequest request = + RestoreDatabaseRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setDatabaseId(databaseId) + .setBackup(backup == null ? null : backup.toString()) + .build(); + return restoreDatabaseAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * 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][google.longrunning.Operation.metadata] field type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. The + * [response][google.longrunning.Operation.response] type is + * [Database][google.spanner.admin.database.v1.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. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String databaseId = "";
+   *   BackupName backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
+   *   Database response = databaseAdminClient.restoreDatabaseAsync(parent.toString(), databaseId, backup.toString()).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the instance in which to create the restored database. This + * instance must be in the same project and have the same instance configuration as the + * instance containing the source backup. Values are of the form + * `projects/<project>/instances/<instance>`. + * @param databaseId Required. The id of the database to create and restore to. This database must + * not already exist. The `database_id` appended to `parent` forms the full database name of + * the form + * `projects/<project>/instances/<instance>/databases/<database_id>`. + * @param backup Name of the backup from which to restore. Values are of the form + * `projects/<project>/instances/<instance>/backups/<backup>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture restoreDatabaseAsync( + String parent, String databaseId, String backup) { + RestoreDatabaseRequest request = + RestoreDatabaseRequest.newBuilder() + .setParent(parent) + .setDatabaseId(databaseId) + .setBackup(backup) + .build(); + return restoreDatabaseAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * 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][google.longrunning.Operation.metadata] field type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. The + * [response][google.longrunning.Operation.response] type is + * [Database][google.spanner.admin.database.v1.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. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String databaseId = "";
+   *   RestoreDatabaseRequest request = RestoreDatabaseRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setDatabaseId(databaseId)
+   *     .build();
+   *   Database response = databaseAdminClient.restoreDatabaseAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture restoreDatabaseAsync( + RestoreDatabaseRequest request) { + return restoreDatabaseOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * 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][google.longrunning.Operation.metadata] field type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. The + * [response][google.longrunning.Operation.response] type is + * [Database][google.spanner.admin.database.v1.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. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String databaseId = "";
+   *   RestoreDatabaseRequest request = RestoreDatabaseRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setDatabaseId(databaseId)
+   *     .build();
+   *   OperationFuture<Database, RestoreDatabaseMetadata> future = databaseAdminClient.restoreDatabaseOperationCallable().futureCall(request);
+   *   // Do something
+   *   Database response = future.get();
+   * }
+   * 
+ */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public final OperationCallable + restoreDatabaseOperationCallable() { + return stub.restoreDatabaseOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * 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][google.longrunning.Operation.metadata] field type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. The + * [response][google.longrunning.Operation.response] type is + * [Database][google.spanner.admin.database.v1.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. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String databaseId = "";
+   *   RestoreDatabaseRequest request = RestoreDatabaseRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setDatabaseId(databaseId)
+   *     .build();
+   *   ApiFuture<Operation> future = databaseAdminClient.restoreDatabaseCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable restoreDatabaseCallable() { + return stub.restoreDatabaseCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists Cloud Spanner databases. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   for (Database element : databaseAdminClient.listDatabases(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The instance whose databases should be listed. Values are of the form + * `projects/<project>/instances/<instance>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListDatabasesPagedResponse listDatabases(InstanceName parent) { + ListDatabasesRequest request = + ListDatabasesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listDatabases(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists Cloud Spanner databases. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   for (Database element : databaseAdminClient.listDatabases(parent.toString()).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The instance whose databases should be listed. Values are of the form + * `projects/<project>/instances/<instance>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListDatabasesPagedResponse listDatabases(String parent) { + ListDatabasesRequest request = ListDatabasesRequest.newBuilder().setParent(parent).build(); + return listDatabases(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists Cloud Spanner databases. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   ListDatabasesRequest request = ListDatabasesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   for (Database element : databaseAdminClient.listDatabases(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListDatabasesPagedResponse listDatabases(ListDatabasesRequest request) { + return listDatabasesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists Cloud Spanner databases. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   ListDatabasesRequest request = ListDatabasesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<ListDatabasesPagedResponse> future = databaseAdminClient.listDatabasesPagedCallable().futureCall(request);
+   *   // Do something
+   *   for (Database element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable + listDatabasesPagedCallable() { + return stub.listDatabasesPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists Cloud Spanner databases. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   ListDatabasesRequest request = ListDatabasesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   while (true) {
+   *     ListDatabasesResponse response = databaseAdminClient.listDatabasesCallable().call(request);
+   *     for (Database element : response.getDatabasesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable listDatabasesCallable() { + return stub.listDatabasesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets the state of a Cloud Spanner database. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
+   *   Database response = databaseAdminClient.getDatabase(name);
+   * }
+   * 
+ * + * @param name Required. The name of the requested database. Values are of the form + * `projects/<project>/instances/<instance>/databases/<database>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Database getDatabase(DatabaseName name) { + GetDatabaseRequest request = + GetDatabaseRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getDatabase(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets the state of a Cloud Spanner database. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
+   *   Database response = databaseAdminClient.getDatabase(name.toString());
+   * }
+   * 
+ * + * @param name Required. The name of the requested database. Values are of the form + * `projects/<project>/instances/<instance>/databases/<database>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Database getDatabase(String name) { + GetDatabaseRequest request = GetDatabaseRequest.newBuilder().setName(name).build(); + return getDatabase(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets the state of a Cloud Spanner database. + * + *

Sample code: + * + *


+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
+   *   GetDatabaseRequest request = GetDatabaseRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   Database response = databaseAdminClient.getDatabase(request);
    * }
    * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public final OperationCallable - updateDatabaseDdlOperationCallable() { - return stub.updateDatabaseDdlOperationCallable(); + public final Database getDatabase(GetDatabaseRequest request) { + return getDatabaseCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * 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][google.longrunning.Operation.metadata] - * field type is - * [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The - * operation has no response. + * Gets the state of a Cloud Spanner database. * *

Sample code: * *


    * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
-   *   List<String> statements = new ArrayList<>();
-   *   UpdateDatabaseDdlRequest request = UpdateDatabaseDdlRequest.newBuilder()
-   *     .setDatabase(database.toString())
-   *     .addAllStatements(statements)
+   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
+   *   GetDatabaseRequest request = GetDatabaseRequest.newBuilder()
+   *     .setName(name.toString())
    *     .build();
-   *   ApiFuture<Operation> future = databaseAdminClient.updateDatabaseDdlCallable().futureCall(request);
+   *   ApiFuture<Database> future = databaseAdminClient.getDatabaseCallable().futureCall(request);
    *   // Do something
-   *   future.get();
+   *   Database response = future.get();
    * }
    * 
*/ - public final UnaryCallable updateDatabaseDdlCallable() { - return stub.updateDatabaseDdlCallable(); + public final UnaryCallable getDatabaseCallable() { + return stub.getDatabaseCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD @@ -1316,243 +1744,38 @@ public final TestIamPermissionsResponse testIamPermissions( * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) { - return testIamPermissionsCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * 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. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   ResourceName resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .addAllPermissions(permissions)
-   *     .build();
-   *   ApiFuture<TestIamPermissionsResponse> future = databaseAdminClient.testIamPermissionsCallable().futureCall(request);
-   *   // Do something
-   *   TestIamPermissionsResponse response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - testIamPermissionsCallable() { - return stub.testIamPermissionsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * 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][google.longrunning.Operation.metadata] field type is - * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Backup][google.spanner.admin.database.v1.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. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   Backup backup = Backup.newBuilder().build();
-   *   String backupId = "";
-   *   Backup response = databaseAdminClient.createBackupAsync(parent, backup, backupId).get();
-   * }
-   * 
- * - * @param parent Required. The name of the instance in which the backup will be created. This must - * be the same instance that contains the database the backup will be created from. The backup - * will be stored in the location(s) specified in the instance configuration of this instance. - * Values are of the form `projects/<project>/instances/<instance>`. - * @param backup Required. The backup to create. - * @param backupId Required. The id of the backup to be created. The `backup_id` appended to - * `parent` forms the full backup name of the form - * `projects/<project>/instances/<instance>/backups/<backup_id>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture createBackupAsync( - InstanceName parent, Backup backup, String backupId) { - CreateBackupRequest request = - CreateBackupRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .setBackup(backup) - .setBackupId(backupId) - .build(); - return createBackupAsync(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * 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][google.longrunning.Operation.metadata] field type is - * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Backup][google.spanner.admin.database.v1.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. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   Backup backup = Backup.newBuilder().build();
-   *   String backupId = "";
-   *   Backup response = databaseAdminClient.createBackupAsync(parent.toString(), backup, backupId).get();
-   * }
-   * 
- * - * @param parent Required. The name of the instance in which the backup will be created. This must - * be the same instance that contains the database the backup will be created from. The backup - * will be stored in the location(s) specified in the instance configuration of this instance. - * Values are of the form `projects/<project>/instances/<instance>`. - * @param backup Required. The backup to create. - * @param backupId Required. The id of the backup to be created. The `backup_id` appended to - * `parent` forms the full backup name of the form - * `projects/<project>/instances/<instance>/backups/<backup_id>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture createBackupAsync( - String parent, Backup backup, String backupId) { - CreateBackupRequest request = - CreateBackupRequest.newBuilder() - .setParent(parent) - .setBackup(backup) - .setBackupId(backupId) - .build(); - return createBackupAsync(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * 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][google.longrunning.Operation.metadata] field type is - * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Backup][google.spanner.admin.database.v1.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. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   String backupId = "";
-   *   Backup backup = Backup.newBuilder().build();
-   *   CreateBackupRequest request = CreateBackupRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setBackupId(backupId)
-   *     .setBackup(backup)
-   *     .build();
-   *   Backup response = databaseAdminClient.createBackupAsync(request).get();
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture createBackupAsync( - CreateBackupRequest request) { - return createBackupOperationCallable().futureCall(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * 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][google.longrunning.Operation.metadata] field type is - * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Backup][google.spanner.admin.database.v1.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. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   String backupId = "";
-   *   Backup backup = Backup.newBuilder().build();
-   *   CreateBackupRequest request = CreateBackupRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setBackupId(backupId)
-   *     .setBackup(backup)
-   *     .build();
-   *   OperationFuture<Backup, CreateBackupMetadata> future = databaseAdminClient.createBackupOperationCallable().futureCall(request);
-   *   // Do something
-   *   Backup response = future.get();
-   * }
-   * 
- */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public final OperationCallable - createBackupOperationCallable() { - return stub.createBackupOperationCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * 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][google.longrunning.Operation.metadata] field type is - * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Backup][google.spanner.admin.database.v1.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. + return testIamPermissionsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * 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. * *

Sample code: * *


    * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   String backupId = "";
-   *   Backup backup = Backup.newBuilder().build();
-   *   CreateBackupRequest request = CreateBackupRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setBackupId(backupId)
-   *     .setBackup(backup)
+   *   ResourceName resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
+   *   List<String> permissions = new ArrayList<>();
+   *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
+   *     .setResource(resource.toString())
+   *     .addAllPermissions(permissions)
    *     .build();
-   *   ApiFuture<Operation> future = databaseAdminClient.createBackupCallable().futureCall(request);
+   *   ApiFuture<TestIamPermissionsResponse> future = databaseAdminClient.testIamPermissionsCallable().futureCall(request);
    *   // Do something
-   *   Operation response = future.get();
+   *   TestIamPermissionsResponse response = future.get();
    * }
    * 
*/ - public final UnaryCallable createBackupCallable() { - return stub.createBackupCallable(); + public final UnaryCallable + testIamPermissionsCallable() { + return stub.testIamPermissionsCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD @@ -1950,229 +2173,6 @@ public final UnaryCallable listBackupsC return stub.listBackupsCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * 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][google.longrunning.Operation.metadata] field type is - * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. The - * [response][google.longrunning.Operation.response] type is - * [Database][google.spanner.admin.database.v1.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. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   String databaseId = "";
-   *   BackupName backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
-   *   Database response = databaseAdminClient.restoreDatabaseAsync(parent, databaseId, backup).get();
-   * }
-   * 
- * - * @param parent Required. The name of the instance in which to create the restored database. This - * instance must be in the same project and have the same instance configuration as the - * instance containing the source backup. Values are of the form - * `projects/<project>/instances/<instance>`. - * @param databaseId Required. The id of the database to create and restore to. This database must - * not already exist. The `database_id` appended to `parent` forms the full database name of - * the form - * `projects/<project>/instances/<instance>/databases/<database_id>`. - * @param backup Name of the backup from which to restore. Values are of the form - * `projects/<project>/instances/<instance>/backups/<backup>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture restoreDatabaseAsync( - InstanceName parent, String databaseId, BackupName backup) { - RestoreDatabaseRequest request = - RestoreDatabaseRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .setDatabaseId(databaseId) - .setBackup(backup == null ? null : backup.toString()) - .build(); - return restoreDatabaseAsync(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * 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][google.longrunning.Operation.metadata] field type is - * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. The - * [response][google.longrunning.Operation.response] type is - * [Database][google.spanner.admin.database.v1.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. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   String databaseId = "";
-   *   BackupName backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
-   *   Database response = databaseAdminClient.restoreDatabaseAsync(parent.toString(), databaseId, backup.toString()).get();
-   * }
-   * 
- * - * @param parent Required. The name of the instance in which to create the restored database. This - * instance must be in the same project and have the same instance configuration as the - * instance containing the source backup. Values are of the form - * `projects/<project>/instances/<instance>`. - * @param databaseId Required. The id of the database to create and restore to. This database must - * not already exist. The `database_id` appended to `parent` forms the full database name of - * the form - * `projects/<project>/instances/<instance>/databases/<database_id>`. - * @param backup Name of the backup from which to restore. Values are of the form - * `projects/<project>/instances/<instance>/backups/<backup>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture restoreDatabaseAsync( - String parent, String databaseId, String backup) { - RestoreDatabaseRequest request = - RestoreDatabaseRequest.newBuilder() - .setParent(parent) - .setDatabaseId(databaseId) - .setBackup(backup) - .build(); - return restoreDatabaseAsync(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * 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][google.longrunning.Operation.metadata] field type is - * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. The - * [response][google.longrunning.Operation.response] type is - * [Database][google.spanner.admin.database.v1.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. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   String databaseId = "";
-   *   RestoreDatabaseRequest request = RestoreDatabaseRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setDatabaseId(databaseId)
-   *     .build();
-   *   Database response = databaseAdminClient.restoreDatabaseAsync(request).get();
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture restoreDatabaseAsync( - RestoreDatabaseRequest request) { - return restoreDatabaseOperationCallable().futureCall(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * 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][google.longrunning.Operation.metadata] field type is - * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. The - * [response][google.longrunning.Operation.response] type is - * [Database][google.spanner.admin.database.v1.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. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   String databaseId = "";
-   *   RestoreDatabaseRequest request = RestoreDatabaseRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setDatabaseId(databaseId)
-   *     .build();
-   *   OperationFuture<Database, RestoreDatabaseMetadata> future = databaseAdminClient.restoreDatabaseOperationCallable().futureCall(request);
-   *   // Do something
-   *   Database response = future.get();
-   * }
-   * 
- */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public final OperationCallable - restoreDatabaseOperationCallable() { - return stub.restoreDatabaseOperationCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * 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][google.longrunning.Operation.metadata] field type is - * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. The - * [response][google.longrunning.Operation.response] type is - * [Database][google.spanner.admin.database.v1.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. - * - *

Sample code: - * - *


-   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   String databaseId = "";
-   *   RestoreDatabaseRequest request = RestoreDatabaseRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setDatabaseId(databaseId)
-   *     .build();
-   *   ApiFuture<Operation> future = databaseAdminClient.restoreDatabaseCallable().futureCall(request);
-   *   // Do something
-   *   Operation response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable restoreDatabaseCallable() { - return stub.restoreDatabaseCallable(); - } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Lists database [longrunning-operations][google.longrunning.Operation]. A database operation has diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminSettings.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminSettings.java index 53edae1edf..8ae9ec5303 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminSettings.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminSettings.java @@ -103,12 +103,6 @@ @Generated("by gapic-generator") @BetaApi public class DatabaseAdminSettings extends ClientSettings { - /** Returns the object with the settings used for calls to listDatabases. */ - public PagedCallSettings - listDatabasesSettings() { - return ((DatabaseAdminStubSettings) getStubSettings()).listDatabasesSettings(); - } - /** Returns the object with the settings used for calls to createDatabase. */ public UnaryCallSettings createDatabaseSettings() { return ((DatabaseAdminStubSettings) getStubSettings()).createDatabaseSettings(); @@ -122,11 +116,6 @@ public UnaryCallSettings createDatabaseSetting return ((DatabaseAdminStubSettings) getStubSettings()).createDatabaseOperationSettings(); } - /** Returns the object with the settings used for calls to getDatabase. */ - public UnaryCallSettings getDatabaseSettings() { - return ((DatabaseAdminStubSettings) getStubSettings()).getDatabaseSettings(); - } - /** Returns the object with the settings used for calls to updateDatabaseDdl. */ public UnaryCallSettings updateDatabaseDdlSettings() { return ((DatabaseAdminStubSettings) getStubSettings()).updateDatabaseDdlSettings(); @@ -140,6 +129,43 @@ public UnaryCallSettings updateDatabaseDdlS return ((DatabaseAdminStubSettings) getStubSettings()).updateDatabaseDdlOperationSettings(); } + /** Returns the object with the settings used for calls to createBackup. */ + public UnaryCallSettings createBackupSettings() { + return ((DatabaseAdminStubSettings) getStubSettings()).createBackupSettings(); + } + + /** Returns the object with the settings used for calls to createBackup. */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings + createBackupOperationSettings() { + return ((DatabaseAdminStubSettings) getStubSettings()).createBackupOperationSettings(); + } + + /** Returns the object with the settings used for calls to restoreDatabase. */ + public UnaryCallSettings restoreDatabaseSettings() { + return ((DatabaseAdminStubSettings) getStubSettings()).restoreDatabaseSettings(); + } + + /** Returns the object with the settings used for calls to restoreDatabase. */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings + restoreDatabaseOperationSettings() { + return ((DatabaseAdminStubSettings) getStubSettings()).restoreDatabaseOperationSettings(); + } + + /** Returns the object with the settings used for calls to listDatabases. */ + public PagedCallSettings + listDatabasesSettings() { + return ((DatabaseAdminStubSettings) getStubSettings()).listDatabasesSettings(); + } + + /** Returns the object with the settings used for calls to getDatabase. */ + public UnaryCallSettings getDatabaseSettings() { + return ((DatabaseAdminStubSettings) getStubSettings()).getDatabaseSettings(); + } + /** Returns the object with the settings used for calls to dropDatabase. */ public UnaryCallSettings dropDatabaseSettings() { return ((DatabaseAdminStubSettings) getStubSettings()).dropDatabaseSettings(); @@ -166,19 +192,6 @@ public UnaryCallSettings getIamPolicySettings() { return ((DatabaseAdminStubSettings) getStubSettings()).testIamPermissionsSettings(); } - /** Returns the object with the settings used for calls to createBackup. */ - public UnaryCallSettings createBackupSettings() { - return ((DatabaseAdminStubSettings) getStubSettings()).createBackupSettings(); - } - - /** Returns the object with the settings used for calls to createBackup. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public OperationCallSettings - createBackupOperationSettings() { - return ((DatabaseAdminStubSettings) getStubSettings()).createBackupOperationSettings(); - } - /** Returns the object with the settings used for calls to getBackup. */ public UnaryCallSettings getBackupSettings() { return ((DatabaseAdminStubSettings) getStubSettings()).getBackupSettings(); @@ -200,19 +213,6 @@ public UnaryCallSettings deleteBackupSettings() { return ((DatabaseAdminStubSettings) getStubSettings()).listBackupsSettings(); } - /** Returns the object with the settings used for calls to restoreDatabase. */ - public UnaryCallSettings restoreDatabaseSettings() { - return ((DatabaseAdminStubSettings) getStubSettings()).restoreDatabaseSettings(); - } - - /** Returns the object with the settings used for calls to restoreDatabase. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public OperationCallSettings - restoreDatabaseOperationSettings() { - return ((DatabaseAdminStubSettings) getStubSettings()).restoreDatabaseOperationSettings(); - } - /** Returns the object with the settings used for calls to listDatabaseOperations. */ public PagedCallSettings< ListDatabaseOperationsRequest, @@ -328,13 +328,6 @@ public Builder applyToAllUnaryMethods( return this; } - /** Returns the builder for the settings used for calls to listDatabases. */ - public PagedCallSettings.Builder< - ListDatabasesRequest, ListDatabasesResponse, ListDatabasesPagedResponse> - listDatabasesSettings() { - return getStubSettingsBuilder().listDatabasesSettings(); - } - /** Returns the builder for the settings used for calls to createDatabase. */ public UnaryCallSettings.Builder createDatabaseSettings() { return getStubSettingsBuilder().createDatabaseSettings(); @@ -348,11 +341,6 @@ public UnaryCallSettings.Builder createDatabas return getStubSettingsBuilder().createDatabaseOperationSettings(); } - /** Returns the builder for the settings used for calls to getDatabase. */ - public UnaryCallSettings.Builder getDatabaseSettings() { - return getStubSettingsBuilder().getDatabaseSettings(); - } - /** Returns the builder for the settings used for calls to updateDatabaseDdl. */ public UnaryCallSettings.Builder updateDatabaseDdlSettings() { @@ -367,6 +355,44 @@ public UnaryCallSettings.Builder getDatabaseSettin return getStubSettingsBuilder().updateDatabaseDdlOperationSettings(); } + /** Returns the builder for the settings used for calls to createBackup. */ + public UnaryCallSettings.Builder createBackupSettings() { + return getStubSettingsBuilder().createBackupSettings(); + } + + /** Returns the builder for the settings used for calls to createBackup. */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings.Builder + createBackupOperationSettings() { + return getStubSettingsBuilder().createBackupOperationSettings(); + } + + /** Returns the builder for the settings used for calls to restoreDatabase. */ + public UnaryCallSettings.Builder restoreDatabaseSettings() { + return getStubSettingsBuilder().restoreDatabaseSettings(); + } + + /** Returns the builder for the settings used for calls to restoreDatabase. */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings.Builder + restoreDatabaseOperationSettings() { + return getStubSettingsBuilder().restoreDatabaseOperationSettings(); + } + + /** Returns the builder for the settings used for calls to listDatabases. */ + public PagedCallSettings.Builder< + ListDatabasesRequest, ListDatabasesResponse, ListDatabasesPagedResponse> + listDatabasesSettings() { + return getStubSettingsBuilder().listDatabasesSettings(); + } + + /** Returns the builder for the settings used for calls to getDatabase. */ + public UnaryCallSettings.Builder getDatabaseSettings() { + return getStubSettingsBuilder().getDatabaseSettings(); + } + /** Returns the builder for the settings used for calls to dropDatabase. */ public UnaryCallSettings.Builder dropDatabaseSettings() { return getStubSettingsBuilder().dropDatabaseSettings(); @@ -394,19 +420,6 @@ public UnaryCallSettings.Builder getIamPolicySettin return getStubSettingsBuilder().testIamPermissionsSettings(); } - /** Returns the builder for the settings used for calls to createBackup. */ - public UnaryCallSettings.Builder createBackupSettings() { - return getStubSettingsBuilder().createBackupSettings(); - } - - /** Returns the builder for the settings used for calls to createBackup. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public OperationCallSettings.Builder - createBackupOperationSettings() { - return getStubSettingsBuilder().createBackupOperationSettings(); - } - /** Returns the builder for the settings used for calls to getBackup. */ public UnaryCallSettings.Builder getBackupSettings() { return getStubSettingsBuilder().getBackupSettings(); @@ -429,19 +442,6 @@ public UnaryCallSettings.Builder deleteBackupSetting return getStubSettingsBuilder().listBackupsSettings(); } - /** Returns the builder for the settings used for calls to restoreDatabase. */ - public UnaryCallSettings.Builder restoreDatabaseSettings() { - return getStubSettingsBuilder().restoreDatabaseSettings(); - } - - /** Returns the builder for the settings used for calls to restoreDatabase. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public OperationCallSettings.Builder - restoreDatabaseOperationSettings() { - return getStubSettingsBuilder().restoreDatabaseOperationSettings(); - } - /** Returns the builder for the settings used for calls to listDatabaseOperations. */ public PagedCallSettings.Builder< ListDatabaseOperationsRequest, diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStub.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStub.java index fd92157c55..9f060f971a 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStub.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStub.java @@ -74,15 +74,6 @@ public OperationsStub getOperationsStub() { throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); } - public UnaryCallable - listDatabasesPagedCallable() { - throw new UnsupportedOperationException("Not implemented: listDatabasesPagedCallable()"); - } - - public UnaryCallable listDatabasesCallable() { - throw new UnsupportedOperationException("Not implemented: listDatabasesCallable()"); - } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable createDatabaseOperationCallable() { @@ -93,10 +84,6 @@ public UnaryCallable createDatabaseCallable() throw new UnsupportedOperationException("Not implemented: createDatabaseCallable()"); } - public UnaryCallable getDatabaseCallable() { - throw new UnsupportedOperationException("Not implemented: getDatabaseCallable()"); - } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable updateDatabaseDdlOperationCallable() { @@ -108,6 +95,39 @@ public UnaryCallable updateDatabaseDdlCalla throw new UnsupportedOperationException("Not implemented: updateDatabaseDdlCallable()"); } + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable + createBackupOperationCallable() { + throw new UnsupportedOperationException("Not implemented: createBackupOperationCallable()"); + } + + public UnaryCallable createBackupCallable() { + throw new UnsupportedOperationException("Not implemented: createBackupCallable()"); + } + + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable + restoreDatabaseOperationCallable() { + throw new UnsupportedOperationException("Not implemented: restoreDatabaseOperationCallable()"); + } + + public UnaryCallable restoreDatabaseCallable() { + throw new UnsupportedOperationException("Not implemented: restoreDatabaseCallable()"); + } + + public UnaryCallable + listDatabasesPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listDatabasesPagedCallable()"); + } + + public UnaryCallable listDatabasesCallable() { + throw new UnsupportedOperationException("Not implemented: listDatabasesCallable()"); + } + + public UnaryCallable getDatabaseCallable() { + throw new UnsupportedOperationException("Not implemented: getDatabaseCallable()"); + } + public UnaryCallable dropDatabaseCallable() { throw new UnsupportedOperationException("Not implemented: dropDatabaseCallable()"); } @@ -129,16 +149,6 @@ public UnaryCallable getIamPolicyCallable() { throw new UnsupportedOperationException("Not implemented: testIamPermissionsCallable()"); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallable - createBackupOperationCallable() { - throw new UnsupportedOperationException("Not implemented: createBackupOperationCallable()"); - } - - public UnaryCallable createBackupCallable() { - throw new UnsupportedOperationException("Not implemented: createBackupCallable()"); - } - public UnaryCallable getBackupCallable() { throw new UnsupportedOperationException("Not implemented: getBackupCallable()"); } @@ -159,16 +169,6 @@ public UnaryCallable listBackupsCallabl throw new UnsupportedOperationException("Not implemented: listBackupsCallable()"); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallable - restoreDatabaseOperationCallable() { - throw new UnsupportedOperationException("Not implemented: restoreDatabaseOperationCallable()"); - } - - public UnaryCallable restoreDatabaseCallable() { - throw new UnsupportedOperationException("Not implemented: restoreDatabaseCallable()"); - } - public UnaryCallable listDatabaseOperationsPagedCallable() { throw new UnsupportedOperationException( diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStubSettings.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStubSettings.java index 53d5767a89..7799b21fc3 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStubSettings.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStubSettings.java @@ -128,16 +128,22 @@ public class DatabaseAdminStubSettings extends StubSettings - listDatabasesSettings; private final UnaryCallSettings createDatabaseSettings; private final OperationCallSettings createDatabaseOperationSettings; - private final UnaryCallSettings getDatabaseSettings; private final UnaryCallSettings updateDatabaseDdlSettings; private final OperationCallSettings updateDatabaseDdlOperationSettings; + private final UnaryCallSettings createBackupSettings; + private final OperationCallSettings + createBackupOperationSettings; + private final UnaryCallSettings restoreDatabaseSettings; + private final OperationCallSettings + restoreDatabaseOperationSettings; + private final PagedCallSettings< + ListDatabasesRequest, ListDatabasesResponse, ListDatabasesPagedResponse> + listDatabasesSettings; + private final UnaryCallSettings getDatabaseSettings; private final UnaryCallSettings dropDatabaseSettings; private final UnaryCallSettings getDatabaseDdlSettings; @@ -145,17 +151,11 @@ public class DatabaseAdminStubSettings extends StubSettings getIamPolicySettings; private final UnaryCallSettings testIamPermissionsSettings; - private final UnaryCallSettings createBackupSettings; - private final OperationCallSettings - createBackupOperationSettings; private final UnaryCallSettings getBackupSettings; private final UnaryCallSettings updateBackupSettings; private final UnaryCallSettings deleteBackupSettings; private final PagedCallSettings listBackupsSettings; - private final UnaryCallSettings restoreDatabaseSettings; - private final OperationCallSettings - restoreDatabaseOperationSettings; private final PagedCallSettings< ListDatabaseOperationsRequest, ListDatabaseOperationsResponse, @@ -167,12 +167,6 @@ public class DatabaseAdminStubSettings extends StubSettings listBackupOperationsSettings; - /** Returns the object with the settings used for calls to listDatabases. */ - public PagedCallSettings - listDatabasesSettings() { - return listDatabasesSettings; - } - /** Returns the object with the settings used for calls to createDatabase. */ public UnaryCallSettings createDatabaseSettings() { return createDatabaseSettings; @@ -185,11 +179,6 @@ public UnaryCallSettings createDatabaseSetting return createDatabaseOperationSettings; } - /** Returns the object with the settings used for calls to getDatabase. */ - public UnaryCallSettings getDatabaseSettings() { - return getDatabaseSettings; - } - /** Returns the object with the settings used for calls to updateDatabaseDdl. */ public UnaryCallSettings updateDatabaseDdlSettings() { return updateDatabaseDdlSettings; @@ -202,6 +191,41 @@ public UnaryCallSettings updateDatabaseDdlS return updateDatabaseDdlOperationSettings; } + /** Returns the object with the settings used for calls to createBackup. */ + public UnaryCallSettings createBackupSettings() { + return createBackupSettings; + } + + /** Returns the object with the settings used for calls to createBackup. */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings + createBackupOperationSettings() { + return createBackupOperationSettings; + } + + /** Returns the object with the settings used for calls to restoreDatabase. */ + public UnaryCallSettings restoreDatabaseSettings() { + return restoreDatabaseSettings; + } + + /** Returns the object with the settings used for calls to restoreDatabase. */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings + restoreDatabaseOperationSettings() { + return restoreDatabaseOperationSettings; + } + + /** Returns the object with the settings used for calls to listDatabases. */ + public PagedCallSettings + listDatabasesSettings() { + return listDatabasesSettings; + } + + /** Returns the object with the settings used for calls to getDatabase. */ + public UnaryCallSettings getDatabaseSettings() { + return getDatabaseSettings; + } + /** Returns the object with the settings used for calls to dropDatabase. */ public UnaryCallSettings dropDatabaseSettings() { return dropDatabaseSettings; @@ -228,18 +252,6 @@ public UnaryCallSettings getIamPolicySettings() { return testIamPermissionsSettings; } - /** Returns the object with the settings used for calls to createBackup. */ - public UnaryCallSettings createBackupSettings() { - return createBackupSettings; - } - - /** Returns the object with the settings used for calls to createBackup. */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings - createBackupOperationSettings() { - return createBackupOperationSettings; - } - /** Returns the object with the settings used for calls to getBackup. */ public UnaryCallSettings getBackupSettings() { return getBackupSettings; @@ -261,18 +273,6 @@ public UnaryCallSettings deleteBackupSettings() { return listBackupsSettings; } - /** Returns the object with the settings used for calls to restoreDatabase. */ - public UnaryCallSettings restoreDatabaseSettings() { - return restoreDatabaseSettings; - } - - /** Returns the object with the settings used for calls to restoreDatabase. */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings - restoreDatabaseOperationSettings() { - return restoreDatabaseOperationSettings; - } - /** Returns the object with the settings used for calls to listDatabaseOperations. */ public PagedCallSettings< ListDatabaseOperationsRequest, @@ -360,26 +360,26 @@ public Builder toBuilder() { protected DatabaseAdminStubSettings(Builder settingsBuilder) throws IOException { super(settingsBuilder); - listDatabasesSettings = settingsBuilder.listDatabasesSettings().build(); createDatabaseSettings = settingsBuilder.createDatabaseSettings().build(); createDatabaseOperationSettings = settingsBuilder.createDatabaseOperationSettings().build(); - getDatabaseSettings = settingsBuilder.getDatabaseSettings().build(); updateDatabaseDdlSettings = settingsBuilder.updateDatabaseDdlSettings().build(); updateDatabaseDdlOperationSettings = settingsBuilder.updateDatabaseDdlOperationSettings().build(); + createBackupSettings = settingsBuilder.createBackupSettings().build(); + createBackupOperationSettings = settingsBuilder.createBackupOperationSettings().build(); + restoreDatabaseSettings = settingsBuilder.restoreDatabaseSettings().build(); + restoreDatabaseOperationSettings = settingsBuilder.restoreDatabaseOperationSettings().build(); + listDatabasesSettings = settingsBuilder.listDatabasesSettings().build(); + getDatabaseSettings = settingsBuilder.getDatabaseSettings().build(); dropDatabaseSettings = settingsBuilder.dropDatabaseSettings().build(); getDatabaseDdlSettings = settingsBuilder.getDatabaseDdlSettings().build(); setIamPolicySettings = settingsBuilder.setIamPolicySettings().build(); getIamPolicySettings = settingsBuilder.getIamPolicySettings().build(); testIamPermissionsSettings = settingsBuilder.testIamPermissionsSettings().build(); - createBackupSettings = settingsBuilder.createBackupSettings().build(); - createBackupOperationSettings = settingsBuilder.createBackupOperationSettings().build(); getBackupSettings = settingsBuilder.getBackupSettings().build(); updateBackupSettings = settingsBuilder.updateBackupSettings().build(); deleteBackupSettings = settingsBuilder.deleteBackupSettings().build(); listBackupsSettings = settingsBuilder.listBackupsSettings().build(); - restoreDatabaseSettings = settingsBuilder.restoreDatabaseSettings().build(); - restoreDatabaseOperationSettings = settingsBuilder.restoreDatabaseOperationSettings().build(); listDatabaseOperationsSettings = settingsBuilder.listDatabaseOperationsSettings().build(); listBackupOperationsSettings = settingsBuilder.listBackupOperationsSettings().build(); } @@ -623,20 +623,28 @@ public ApiFuture getFuturePagedResponse( public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; - private final PagedCallSettings.Builder< - ListDatabasesRequest, ListDatabasesResponse, ListDatabasesPagedResponse> - listDatabasesSettings; private final UnaryCallSettings.Builder createDatabaseSettings; private final OperationCallSettings.Builder< CreateDatabaseRequest, Database, CreateDatabaseMetadata> createDatabaseOperationSettings; - private final UnaryCallSettings.Builder getDatabaseSettings; private final UnaryCallSettings.Builder updateDatabaseDdlSettings; private final OperationCallSettings.Builder< UpdateDatabaseDdlRequest, Empty, UpdateDatabaseDdlMetadata> updateDatabaseDdlOperationSettings; + private final UnaryCallSettings.Builder createBackupSettings; + private final OperationCallSettings.Builder + createBackupOperationSettings; + private final UnaryCallSettings.Builder + restoreDatabaseSettings; + private final OperationCallSettings.Builder< + RestoreDatabaseRequest, Database, RestoreDatabaseMetadata> + restoreDatabaseOperationSettings; + private final PagedCallSettings.Builder< + ListDatabasesRequest, ListDatabasesResponse, ListDatabasesPagedResponse> + listDatabasesSettings; + private final UnaryCallSettings.Builder getDatabaseSettings; private final UnaryCallSettings.Builder dropDatabaseSettings; private final UnaryCallSettings.Builder getDatabaseDdlSettings; @@ -644,20 +652,12 @@ public static class Builder extends StubSettings.Builder getIamPolicySettings; private final UnaryCallSettings.Builder testIamPermissionsSettings; - private final UnaryCallSettings.Builder createBackupSettings; - private final OperationCallSettings.Builder - createBackupOperationSettings; private final UnaryCallSettings.Builder getBackupSettings; private final UnaryCallSettings.Builder updateBackupSettings; private final UnaryCallSettings.Builder deleteBackupSettings; private final PagedCallSettings.Builder< ListBackupsRequest, ListBackupsResponse, ListBackupsPagedResponse> listBackupsSettings; - private final UnaryCallSettings.Builder - restoreDatabaseSettings; - private final OperationCallSettings.Builder< - RestoreDatabaseRequest, Database, RestoreDatabaseMetadata> - restoreDatabaseOperationSettings; private final PagedCallSettings.Builder< ListDatabaseOperationsRequest, ListDatabaseOperationsResponse, @@ -676,11 +676,20 @@ public static class Builder extends StubSettings.Builder> definitions = ImmutableMap.builder(); definitions.put( - "idempotent", + "retry_policy_1_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED))); + definitions.put( + "no_retry_2_codes", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put( + "retry_policy_2_codes", ImmutableSet.copyOf( Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED))); + definitions.put( + "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -694,12 +703,41 @@ public static class Builder extends StubSettings.Builder>of( - listDatabasesSettings, createDatabaseSettings, - getDatabaseSettings, updateDatabaseDdlSettings, + createBackupSettings, + restoreDatabaseSettings, + listDatabasesSettings, + getDatabaseSettings, dropDatabaseSettings, getDatabaseDdlSettings, setIamPolicySettings, getIamPolicySettings, testIamPermissionsSettings, - createBackupSettings, getBackupSettings, updateBackupSettings, deleteBackupSettings, listBackupsSettings, - restoreDatabaseSettings, listDatabaseOperationsSettings, listBackupOperationsSettings); @@ -789,96 +827,96 @@ private static Builder createDefault() { private static Builder initDefaults(Builder builder) { builder - .listDatabasesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .createDatabaseSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); builder - .createDatabaseSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .updateDatabaseDdlSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder - .getDatabaseSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .createBackupSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); builder - .updateDatabaseDdlSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .restoreDatabaseSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + + builder + .listDatabasesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + builder + .getDatabaseSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder .dropDatabaseSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder .getDatabaseDdlSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder .setIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params")); builder .getIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); builder .testIamPermissionsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .createBackupSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params")); builder .getBackupSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder .updateBackupSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); builder .deleteBackupSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder .listBackupsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .restoreDatabaseSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder .listDatabaseOperationsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder .listBackupOperationsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder .createDatabaseOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Database.class)) @@ -900,8 +938,8 @@ private static Builder initDefaults(Builder builder) { .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) @@ -924,8 +962,8 @@ private static Builder initDefaults(Builder builder) { .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Backup.class)) @@ -947,8 +985,8 @@ private static Builder initDefaults(Builder builder) { .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Database.class)) @@ -972,45 +1010,45 @@ private static Builder initDefaults(Builder builder) { protected Builder(DatabaseAdminStubSettings settings) { super(settings); - listDatabasesSettings = settings.listDatabasesSettings.toBuilder(); createDatabaseSettings = settings.createDatabaseSettings.toBuilder(); createDatabaseOperationSettings = settings.createDatabaseOperationSettings.toBuilder(); - getDatabaseSettings = settings.getDatabaseSettings.toBuilder(); updateDatabaseDdlSettings = settings.updateDatabaseDdlSettings.toBuilder(); updateDatabaseDdlOperationSettings = settings.updateDatabaseDdlOperationSettings.toBuilder(); + createBackupSettings = settings.createBackupSettings.toBuilder(); + createBackupOperationSettings = settings.createBackupOperationSettings.toBuilder(); + restoreDatabaseSettings = settings.restoreDatabaseSettings.toBuilder(); + restoreDatabaseOperationSettings = settings.restoreDatabaseOperationSettings.toBuilder(); + listDatabasesSettings = settings.listDatabasesSettings.toBuilder(); + getDatabaseSettings = settings.getDatabaseSettings.toBuilder(); dropDatabaseSettings = settings.dropDatabaseSettings.toBuilder(); getDatabaseDdlSettings = settings.getDatabaseDdlSettings.toBuilder(); setIamPolicySettings = settings.setIamPolicySettings.toBuilder(); getIamPolicySettings = settings.getIamPolicySettings.toBuilder(); testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder(); - createBackupSettings = settings.createBackupSettings.toBuilder(); - createBackupOperationSettings = settings.createBackupOperationSettings.toBuilder(); getBackupSettings = settings.getBackupSettings.toBuilder(); updateBackupSettings = settings.updateBackupSettings.toBuilder(); deleteBackupSettings = settings.deleteBackupSettings.toBuilder(); listBackupsSettings = settings.listBackupsSettings.toBuilder(); - restoreDatabaseSettings = settings.restoreDatabaseSettings.toBuilder(); - restoreDatabaseOperationSettings = settings.restoreDatabaseOperationSettings.toBuilder(); listDatabaseOperationsSettings = settings.listDatabaseOperationsSettings.toBuilder(); listBackupOperationsSettings = settings.listBackupOperationsSettings.toBuilder(); unaryMethodSettingsBuilders = ImmutableList.>of( - listDatabasesSettings, createDatabaseSettings, - getDatabaseSettings, updateDatabaseDdlSettings, + createBackupSettings, + restoreDatabaseSettings, + listDatabasesSettings, + getDatabaseSettings, dropDatabaseSettings, getDatabaseDdlSettings, setIamPolicySettings, getIamPolicySettings, testIamPermissionsSettings, - createBackupSettings, getBackupSettings, updateBackupSettings, deleteBackupSettings, listBackupsSettings, - restoreDatabaseSettings, listDatabaseOperationsSettings, listBackupOperationsSettings); } @@ -1031,13 +1069,6 @@ public Builder applyToAllUnaryMethods( return unaryMethodSettingsBuilders; } - /** Returns the builder for the settings used for calls to listDatabases. */ - public PagedCallSettings.Builder< - ListDatabasesRequest, ListDatabasesResponse, ListDatabasesPagedResponse> - listDatabasesSettings() { - return listDatabasesSettings; - } - /** Returns the builder for the settings used for calls to createDatabase. */ public UnaryCallSettings.Builder createDatabaseSettings() { return createDatabaseSettings; @@ -1051,11 +1082,6 @@ public UnaryCallSettings.Builder createDatabas return createDatabaseOperationSettings; } - /** Returns the builder for the settings used for calls to getDatabase. */ - public UnaryCallSettings.Builder getDatabaseSettings() { - return getDatabaseSettings; - } - /** Returns the builder for the settings used for calls to updateDatabaseDdl. */ public UnaryCallSettings.Builder updateDatabaseDdlSettings() { @@ -1070,6 +1096,44 @@ public UnaryCallSettings.Builder getDatabaseSettin return updateDatabaseDdlOperationSettings; } + /** Returns the builder for the settings used for calls to createBackup. */ + public UnaryCallSettings.Builder createBackupSettings() { + return createBackupSettings; + } + + /** Returns the builder for the settings used for calls to createBackup. */ + @BetaApi( + "The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder + createBackupOperationSettings() { + return createBackupOperationSettings; + } + + /** Returns the builder for the settings used for calls to restoreDatabase. */ + public UnaryCallSettings.Builder restoreDatabaseSettings() { + return restoreDatabaseSettings; + } + + /** Returns the builder for the settings used for calls to restoreDatabase. */ + @BetaApi( + "The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder + restoreDatabaseOperationSettings() { + return restoreDatabaseOperationSettings; + } + + /** Returns the builder for the settings used for calls to listDatabases. */ + public PagedCallSettings.Builder< + ListDatabasesRequest, ListDatabasesResponse, ListDatabasesPagedResponse> + listDatabasesSettings() { + return listDatabasesSettings; + } + + /** Returns the builder for the settings used for calls to getDatabase. */ + public UnaryCallSettings.Builder getDatabaseSettings() { + return getDatabaseSettings; + } + /** Returns the builder for the settings used for calls to dropDatabase. */ public UnaryCallSettings.Builder dropDatabaseSettings() { return dropDatabaseSettings; @@ -1097,19 +1161,6 @@ public UnaryCallSettings.Builder getIamPolicySettin return testIamPermissionsSettings; } - /** Returns the builder for the settings used for calls to createBackup. */ - public UnaryCallSettings.Builder createBackupSettings() { - return createBackupSettings; - } - - /** Returns the builder for the settings used for calls to createBackup. */ - @BetaApi( - "The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings.Builder - createBackupOperationSettings() { - return createBackupOperationSettings; - } - /** Returns the builder for the settings used for calls to getBackup. */ public UnaryCallSettings.Builder getBackupSettings() { return getBackupSettings; @@ -1132,19 +1183,6 @@ public UnaryCallSettings.Builder deleteBackupSetting return listBackupsSettings; } - /** Returns the builder for the settings used for calls to restoreDatabase. */ - public UnaryCallSettings.Builder restoreDatabaseSettings() { - return restoreDatabaseSettings; - } - - /** Returns the builder for the settings used for calls to restoreDatabase. */ - @BetaApi( - "The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings.Builder - restoreDatabaseOperationSettings() { - return restoreDatabaseOperationSettings; - } - /** Returns the builder for the settings used for calls to listDatabaseOperations. */ public PagedCallSettings.Builder< ListDatabaseOperationsRequest, diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/GrpcDatabaseAdminStub.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/GrpcDatabaseAdminStub.java index aaf318ca90..c3d8b39713 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/GrpcDatabaseAdminStub.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/GrpcDatabaseAdminStub.java @@ -80,16 +80,6 @@ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public class GrpcDatabaseAdminStub extends DatabaseAdminStub { - private static final MethodDescriptor - listDatabasesMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/ListDatabases") - .setRequestMarshaller( - ProtoUtils.marshaller(ListDatabasesRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListDatabasesResponse.getDefaultInstance())) - .build(); private static final MethodDescriptor createDatabaseMethodDescriptor = MethodDescriptor.newBuilder() @@ -99,13 +89,6 @@ public class GrpcDatabaseAdminStub extends DatabaseAdminStub { ProtoUtils.marshaller(CreateDatabaseRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); - private static final MethodDescriptor getDatabaseMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/GetDatabase") - .setRequestMarshaller(ProtoUtils.marshaller(GetDatabaseRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Database.getDefaultInstance())) - .build(); private static final MethodDescriptor updateDatabaseDdlMethodDescriptor = MethodDescriptor.newBuilder() @@ -115,6 +98,40 @@ public class GrpcDatabaseAdminStub extends DatabaseAdminStub { ProtoUtils.marshaller(UpdateDatabaseDdlRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); + private static final MethodDescriptor + createBackupMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/CreateBackup") + .setRequestMarshaller(ProtoUtils.marshaller(CreateBackupRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + private static final MethodDescriptor + restoreDatabaseMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/RestoreDatabase") + .setRequestMarshaller( + ProtoUtils.marshaller(RestoreDatabaseRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + private static final MethodDescriptor + listDatabasesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/ListDatabases") + .setRequestMarshaller( + ProtoUtils.marshaller(ListDatabasesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListDatabasesResponse.getDefaultInstance())) + .build(); + private static final MethodDescriptor getDatabaseMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/GetDatabase") + .setRequestMarshaller(ProtoUtils.marshaller(GetDatabaseRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Database.getDefaultInstance())) + .build(); private static final MethodDescriptor dropDatabaseMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -157,14 +174,6 @@ public class GrpcDatabaseAdminStub extends DatabaseAdminStub { .setResponseMarshaller( ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance())) .build(); - private static final MethodDescriptor - createBackupMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/CreateBackup") - .setRequestMarshaller(ProtoUtils.marshaller(CreateBackupRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) - .build(); private static final MethodDescriptor getBackupMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -195,15 +204,6 @@ public class GrpcDatabaseAdminStub extends DatabaseAdminStub { .setResponseMarshaller( ProtoUtils.marshaller(ListBackupsResponse.getDefaultInstance())) .build(); - private static final MethodDescriptor - restoreDatabaseMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/RestoreDatabase") - .setRequestMarshaller( - ProtoUtils.marshaller(RestoreDatabaseRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) - .build(); private static final MethodDescriptor< ListDatabaseOperationsRequest, ListDatabaseOperationsResponse> listDatabaseOperationsMethodDescriptor = @@ -232,34 +232,34 @@ public class GrpcDatabaseAdminStub extends DatabaseAdminStub { private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; - private final UnaryCallable listDatabasesCallable; - private final UnaryCallable - listDatabasesPagedCallable; private final UnaryCallable createDatabaseCallable; private final OperationCallable createDatabaseOperationCallable; - private final UnaryCallable getDatabaseCallable; private final UnaryCallable updateDatabaseDdlCallable; private final OperationCallable updateDatabaseDdlOperationCallable; + private final UnaryCallable createBackupCallable; + private final OperationCallable + createBackupOperationCallable; + private final UnaryCallable restoreDatabaseCallable; + private final OperationCallable + restoreDatabaseOperationCallable; + private final UnaryCallable listDatabasesCallable; + private final UnaryCallable + listDatabasesPagedCallable; + private final UnaryCallable getDatabaseCallable; private final UnaryCallable dropDatabaseCallable; private final UnaryCallable getDatabaseDdlCallable; private final UnaryCallable setIamPolicyCallable; private final UnaryCallable getIamPolicyCallable; private final UnaryCallable testIamPermissionsCallable; - private final UnaryCallable createBackupCallable; - private final OperationCallable - createBackupOperationCallable; private final UnaryCallable getBackupCallable; private final UnaryCallable updateBackupCallable; private final UnaryCallable deleteBackupCallable; private final UnaryCallable listBackupsCallable; private final UnaryCallable listBackupsPagedCallable; - private final UnaryCallable restoreDatabaseCallable; - private final OperationCallable - restoreDatabaseOperationCallable; private final UnaryCallable listDatabaseOperationsCallable; private final UnaryCallable @@ -309,54 +309,80 @@ protected GrpcDatabaseAdminStub( this.callableFactory = callableFactory; this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); - GrpcCallSettings listDatabasesTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(listDatabasesMethodDescriptor) + GrpcCallSettings createDatabaseTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createDatabaseMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { + new RequestParamsExtractor() { @Override - public Map extract(ListDatabasesRequest request) { + public Map extract(CreateDatabaseRequest request) { ImmutableMap.Builder params = ImmutableMap.builder(); params.put("parent", String.valueOf(request.getParent())); return params.build(); } }) .build(); - GrpcCallSettings createDatabaseTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createDatabaseMethodDescriptor) + GrpcCallSettings updateDatabaseDdlTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateDatabaseDdlMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { + new RequestParamsExtractor() { @Override - public Map extract(CreateDatabaseRequest request) { + public Map extract(UpdateDatabaseDdlRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("database", String.valueOf(request.getDatabase())); + return params.build(); + } + }) + .build(); + GrpcCallSettings createBackupTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createBackupMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(CreateBackupRequest request) { ImmutableMap.Builder params = ImmutableMap.builder(); params.put("parent", String.valueOf(request.getParent())); return params.build(); } }) .build(); - GrpcCallSettings getDatabaseTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getDatabaseMethodDescriptor) + GrpcCallSettings restoreDatabaseTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(restoreDatabaseMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { + new RequestParamsExtractor() { @Override - public Map extract(GetDatabaseRequest request) { + public Map extract(RestoreDatabaseRequest request) { ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); + params.put("parent", String.valueOf(request.getParent())); return params.build(); } }) .build(); - GrpcCallSettings updateDatabaseDdlTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(updateDatabaseDdlMethodDescriptor) + GrpcCallSettings listDatabasesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listDatabasesMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { + new RequestParamsExtractor() { @Override - public Map extract(UpdateDatabaseDdlRequest request) { + public Map extract(ListDatabasesRequest request) { ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("database", String.valueOf(request.getDatabase())); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings getDatabaseTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getDatabaseMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(GetDatabaseRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); return params.build(); } }) @@ -428,19 +454,6 @@ public Map extract(TestIamPermissionsRequest request) { } }) .build(); - GrpcCallSettings createBackupTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createBackupMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateBackupRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } - }) - .build(); GrpcCallSettings getBackupTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getBackupMethodDescriptor) @@ -493,19 +506,6 @@ public Map extract(ListBackupsRequest request) { } }) .build(); - GrpcCallSettings restoreDatabaseTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(restoreDatabaseMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(RestoreDatabaseRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } - }) - .build(); GrpcCallSettings listDatabaseOperationsTransportSettings = GrpcCallSettings @@ -536,12 +536,6 @@ public Map extract(ListBackupOperationsRequest request) { }) .build(); - this.listDatabasesCallable = - callableFactory.createUnaryCallable( - listDatabasesTransportSettings, settings.listDatabasesSettings(), clientContext); - this.listDatabasesPagedCallable = - callableFactory.createPagedCallable( - listDatabasesTransportSettings, settings.listDatabasesSettings(), clientContext); this.createDatabaseCallable = callableFactory.createUnaryCallable( createDatabaseTransportSettings, settings.createDatabaseSettings(), clientContext); @@ -551,9 +545,6 @@ public Map extract(ListBackupOperationsRequest request) { settings.createDatabaseOperationSettings(), clientContext, this.operationsStub); - this.getDatabaseCallable = - callableFactory.createUnaryCallable( - getDatabaseTransportSettings, settings.getDatabaseSettings(), clientContext); this.updateDatabaseDdlCallable = callableFactory.createUnaryCallable( updateDatabaseDdlTransportSettings, @@ -565,6 +556,33 @@ public Map extract(ListBackupOperationsRequest request) { settings.updateDatabaseDdlOperationSettings(), clientContext, this.operationsStub); + this.createBackupCallable = + callableFactory.createUnaryCallable( + createBackupTransportSettings, settings.createBackupSettings(), clientContext); + this.createBackupOperationCallable = + callableFactory.createOperationCallable( + createBackupTransportSettings, + settings.createBackupOperationSettings(), + clientContext, + this.operationsStub); + this.restoreDatabaseCallable = + callableFactory.createUnaryCallable( + restoreDatabaseTransportSettings, settings.restoreDatabaseSettings(), clientContext); + this.restoreDatabaseOperationCallable = + callableFactory.createOperationCallable( + restoreDatabaseTransportSettings, + settings.restoreDatabaseOperationSettings(), + clientContext, + this.operationsStub); + this.listDatabasesCallable = + callableFactory.createUnaryCallable( + listDatabasesTransportSettings, settings.listDatabasesSettings(), clientContext); + this.listDatabasesPagedCallable = + callableFactory.createPagedCallable( + listDatabasesTransportSettings, settings.listDatabasesSettings(), clientContext); + this.getDatabaseCallable = + callableFactory.createUnaryCallable( + getDatabaseTransportSettings, settings.getDatabaseSettings(), clientContext); this.dropDatabaseCallable = callableFactory.createUnaryCallable( dropDatabaseTransportSettings, settings.dropDatabaseSettings(), clientContext); @@ -582,15 +600,6 @@ public Map extract(ListBackupOperationsRequest request) { testIamPermissionsTransportSettings, settings.testIamPermissionsSettings(), clientContext); - this.createBackupCallable = - callableFactory.createUnaryCallable( - createBackupTransportSettings, settings.createBackupSettings(), clientContext); - this.createBackupOperationCallable = - callableFactory.createOperationCallable( - createBackupTransportSettings, - settings.createBackupOperationSettings(), - clientContext, - this.operationsStub); this.getBackupCallable = callableFactory.createUnaryCallable( getBackupTransportSettings, settings.getBackupSettings(), clientContext); @@ -606,15 +615,6 @@ public Map extract(ListBackupOperationsRequest request) { this.listBackupsPagedCallable = callableFactory.createPagedCallable( listBackupsTransportSettings, settings.listBackupsSettings(), clientContext); - this.restoreDatabaseCallable = - callableFactory.createUnaryCallable( - restoreDatabaseTransportSettings, settings.restoreDatabaseSettings(), clientContext); - this.restoreDatabaseOperationCallable = - callableFactory.createOperationCallable( - restoreDatabaseTransportSettings, - settings.restoreDatabaseOperationSettings(), - clientContext, - this.operationsStub); this.listDatabaseOperationsCallable = callableFactory.createUnaryCallable( listDatabaseOperationsTransportSettings, @@ -644,15 +644,6 @@ public GrpcOperationsStub getOperationsStub() { return operationsStub; } - public UnaryCallable - listDatabasesPagedCallable() { - return listDatabasesPagedCallable; - } - - public UnaryCallable listDatabasesCallable() { - return listDatabasesCallable; - } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable createDatabaseOperationCallable() { @@ -663,10 +654,6 @@ public UnaryCallable createDatabaseCallable() return createDatabaseCallable; } - public UnaryCallable getDatabaseCallable() { - return getDatabaseCallable; - } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable updateDatabaseDdlOperationCallable() { @@ -677,6 +664,39 @@ public UnaryCallable updateDatabaseDdlCalla return updateDatabaseDdlCallable; } + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable + createBackupOperationCallable() { + return createBackupOperationCallable; + } + + public UnaryCallable createBackupCallable() { + return createBackupCallable; + } + + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable + restoreDatabaseOperationCallable() { + return restoreDatabaseOperationCallable; + } + + public UnaryCallable restoreDatabaseCallable() { + return restoreDatabaseCallable; + } + + public UnaryCallable + listDatabasesPagedCallable() { + return listDatabasesPagedCallable; + } + + public UnaryCallable listDatabasesCallable() { + return listDatabasesCallable; + } + + public UnaryCallable getDatabaseCallable() { + return getDatabaseCallable; + } + public UnaryCallable dropDatabaseCallable() { return dropDatabaseCallable; } @@ -698,16 +718,6 @@ public UnaryCallable getIamPolicyCallable() { return testIamPermissionsCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallable - createBackupOperationCallable() { - return createBackupOperationCallable; - } - - public UnaryCallable createBackupCallable() { - return createBackupCallable; - } - public UnaryCallable getBackupCallable() { return getBackupCallable; } @@ -728,16 +738,6 @@ public UnaryCallable listBackupsCallabl return listBackupsCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallable - restoreDatabaseOperationCallable() { - return restoreDatabaseOperationCallable; - } - - public UnaryCallable restoreDatabaseCallable() { - return restoreDatabaseCallable; - } - public UnaryCallable listDatabaseOperationsPagedCallable() { return listDatabaseOperationsPagedCallable; diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminClient.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminClient.java index 4242e4e42e..fb9c411c00 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminClient.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminClient.java @@ -212,274 +212,810 @@ public final OperationsClient getOperationsClient() { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists the supported instance configurations for a given project. + * Creates an instance and begins preparing it to begin serving. The returned [long-running + * operation][google.longrunning.Operation] can be used to track the progress of preparing the new + * instance. The instance name is assigned by the caller. If the named instance already exists, + * `CreateInstance` returns `ALREADY_EXISTS`. + * + *

Immediately upon completion of this request: + * + *

* The instance is readable via the API, with all requested attributes but no allocated + * resources. Its state is `CREATING`. + * + *

Until completion of the returned operation: + * + *

* Cancelling the operation renders the instance immediately unreadable via the API. + * * The instance can be deleted. * All other attempts to modify the instance are + * rejected. + * + *

Upon completion of the returned operation: + * + *

* Billing for all successfully-allocated resources begins (some types may have lower + * than the requested levels). * Databases can be created in the instance. * The + * instance's allocated resource levels are readable via the API. * The instance's state + * becomes `READY`. + * + *

The returned [long-running operation][google.longrunning.Operation] will have a name of the + * format `<instance_name>/operations/<operation_id>` and can be used to track + * creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is + * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. * *

Sample code: * *


    * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   for (InstanceConfig element : instanceAdminClient.listInstanceConfigs(parent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
+   *   String instanceId = "";
+   *   Instance instance = Instance.newBuilder().build();
+   *   Instance response = instanceAdminClient.createInstanceAsync(parent, instanceId, instance).get();
    * }
    * 
* - * @param parent Required. The name of the project for which a list of supported instance - * configurations is requested. Values are of the form `projects/<project>`. + * @param parent Required. The name of the project in which to create the instance. Values are of + * the form `projects/<project>`. + * @param instanceId Required. The ID of the instance to create. Valid identifiers are of the form + * `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in length. + * @param instance Required. The instance to create. The name may be omitted, but if specified + * must be `<parent>/instances/<instance_id>`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final ListInstanceConfigsPagedResponse listInstanceConfigs(ProjectName parent) { - ListInstanceConfigsRequest request = - ListInstanceConfigsRequest.newBuilder() + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture createInstanceAsync( + ProjectName parent, String instanceId, Instance instance) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) + .setInstanceId(instanceId) + .setInstance(instance) .build(); - return listInstanceConfigs(request); + return createInstanceAsync(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists the supported instance configurations for a given project. + * Creates an instance and begins preparing it to begin serving. The returned [long-running + * operation][google.longrunning.Operation] can be used to track the progress of preparing the new + * instance. The instance name is assigned by the caller. If the named instance already exists, + * `CreateInstance` returns `ALREADY_EXISTS`. + * + *

Immediately upon completion of this request: + * + *

* The instance is readable via the API, with all requested attributes but no allocated + * resources. Its state is `CREATING`. + * + *

Until completion of the returned operation: + * + *

* Cancelling the operation renders the instance immediately unreadable via the API. + * * The instance can be deleted. * All other attempts to modify the instance are + * rejected. + * + *

Upon completion of the returned operation: + * + *

* Billing for all successfully-allocated resources begins (some types may have lower + * than the requested levels). * Databases can be created in the instance. * The + * instance's allocated resource levels are readable via the API. * The instance's state + * becomes `READY`. + * + *

The returned [long-running operation][google.longrunning.Operation] will have a name of the + * format `<instance_name>/operations/<operation_id>` and can be used to track + * creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is + * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. * *

Sample code: * *


    * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   for (InstanceConfig element : instanceAdminClient.listInstanceConfigs(parent.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
+   *   String instanceId = "";
+   *   Instance instance = Instance.newBuilder().build();
+   *   Instance response = instanceAdminClient.createInstanceAsync(parent.toString(), instanceId, instance).get();
    * }
    * 
* - * @param parent Required. The name of the project for which a list of supported instance - * configurations is requested. Values are of the form `projects/<project>`. + * @param parent Required. The name of the project in which to create the instance. Values are of + * the form `projects/<project>`. + * @param instanceId Required. The ID of the instance to create. Valid identifiers are of the form + * `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in length. + * @param instance Required. The instance to create. The name may be omitted, but if specified + * must be `<parent>/instances/<instance_id>`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final ListInstanceConfigsPagedResponse listInstanceConfigs(String parent) { - ListInstanceConfigsRequest request = - ListInstanceConfigsRequest.newBuilder().setParent(parent).build(); - return listInstanceConfigs(request); + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture createInstanceAsync( + String parent, String instanceId, Instance instance) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() + .setParent(parent) + .setInstanceId(instanceId) + .setInstance(instance) + .build(); + return createInstanceAsync(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists the supported instance configurations for a given project. + * Creates an instance and begins preparing it to begin serving. The returned [long-running + * operation][google.longrunning.Operation] can be used to track the progress of preparing the new + * instance. The instance name is assigned by the caller. If the named instance already exists, + * `CreateInstance` returns `ALREADY_EXISTS`. + * + *

Immediately upon completion of this request: + * + *

* The instance is readable via the API, with all requested attributes but no allocated + * resources. Its state is `CREATING`. + * + *

Until completion of the returned operation: + * + *

* Cancelling the operation renders the instance immediately unreadable via the API. + * * The instance can be deleted. * All other attempts to modify the instance are + * rejected. + * + *

Upon completion of the returned operation: + * + *

* Billing for all successfully-allocated resources begins (some types may have lower + * than the requested levels). * Databases can be created in the instance. * The + * instance's allocated resource levels are readable via the API. * The instance's state + * becomes `READY`. + * + *

The returned [long-running operation][google.longrunning.Operation] will have a name of the + * format `<instance_name>/operations/<operation_id>` and can be used to track + * creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is + * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. * *

Sample code: * *


    * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   ListInstanceConfigsRequest request = ListInstanceConfigsRequest.newBuilder()
+   *   String instanceId = "";
+   *   Instance instance = Instance.newBuilder().build();
+   *   CreateInstanceRequest request = CreateInstanceRequest.newBuilder()
    *     .setParent(parent.toString())
+   *     .setInstanceId(instanceId)
+   *     .setInstance(instance)
    *     .build();
-   *   for (InstanceConfig element : instanceAdminClient.listInstanceConfigs(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
+   *   Instance response = instanceAdminClient.createInstanceAsync(request).get();
    * }
    * 
* * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final ListInstanceConfigsPagedResponse listInstanceConfigs( - ListInstanceConfigsRequest request) { - return listInstanceConfigsPagedCallable().call(request); + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture createInstanceAsync( + CreateInstanceRequest request) { + return createInstanceOperationCallable().futureCall(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists the supported instance configurations for a given project. + * Creates an instance and begins preparing it to begin serving. The returned [long-running + * operation][google.longrunning.Operation] can be used to track the progress of preparing the new + * instance. The instance name is assigned by the caller. If the named instance already exists, + * `CreateInstance` returns `ALREADY_EXISTS`. + * + *

Immediately upon completion of this request: + * + *

* The instance is readable via the API, with all requested attributes but no allocated + * resources. Its state is `CREATING`. + * + *

Until completion of the returned operation: + * + *

* Cancelling the operation renders the instance immediately unreadable via the API. + * * The instance can be deleted. * All other attempts to modify the instance are + * rejected. + * + *

Upon completion of the returned operation: + * + *

* Billing for all successfully-allocated resources begins (some types may have lower + * than the requested levels). * Databases can be created in the instance. * The + * instance's allocated resource levels are readable via the API. * The instance's state + * becomes `READY`. + * + *

The returned [long-running operation][google.longrunning.Operation] will have a name of the + * format `<instance_name>/operations/<operation_id>` and can be used to track + * creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is + * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. * *

Sample code: * *


    * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   ListInstanceConfigsRequest request = ListInstanceConfigsRequest.newBuilder()
+   *   String instanceId = "";
+   *   Instance instance = Instance.newBuilder().build();
+   *   CreateInstanceRequest request = CreateInstanceRequest.newBuilder()
    *     .setParent(parent.toString())
+   *     .setInstanceId(instanceId)
+   *     .setInstance(instance)
    *     .build();
-   *   ApiFuture<ListInstanceConfigsPagedResponse> future = instanceAdminClient.listInstanceConfigsPagedCallable().futureCall(request);
+   *   OperationFuture<Instance, CreateInstanceMetadata> future = instanceAdminClient.createInstanceOperationCallable().futureCall(request);
    *   // Do something
-   *   for (InstanceConfig element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
+   *   Instance response = future.get();
    * }
    * 
*/ - public final UnaryCallable - listInstanceConfigsPagedCallable() { - return stub.listInstanceConfigsPagedCallable(); + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public final OperationCallable + createInstanceOperationCallable() { + return stub.createInstanceOperationCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists the supported instance configurations for a given project. + * Creates an instance and begins preparing it to begin serving. The returned [long-running + * operation][google.longrunning.Operation] can be used to track the progress of preparing the new + * instance. The instance name is assigned by the caller. If the named instance already exists, + * `CreateInstance` returns `ALREADY_EXISTS`. + * + *

Immediately upon completion of this request: + * + *

* The instance is readable via the API, with all requested attributes but no allocated + * resources. Its state is `CREATING`. + * + *

Until completion of the returned operation: + * + *

* Cancelling the operation renders the instance immediately unreadable via the API. + * * The instance can be deleted. * All other attempts to modify the instance are + * rejected. + * + *

Upon completion of the returned operation: + * + *

* Billing for all successfully-allocated resources begins (some types may have lower + * than the requested levels). * Databases can be created in the instance. * The + * instance's allocated resource levels are readable via the API. * The instance's state + * becomes `READY`. + * + *

The returned [long-running operation][google.longrunning.Operation] will have a name of the + * format `<instance_name>/operations/<operation_id>` and can be used to track + * creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is + * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. * *

Sample code: * *


    * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   ListInstanceConfigsRequest request = ListInstanceConfigsRequest.newBuilder()
+   *   String instanceId = "";
+   *   Instance instance = Instance.newBuilder().build();
+   *   CreateInstanceRequest request = CreateInstanceRequest.newBuilder()
    *     .setParent(parent.toString())
+   *     .setInstanceId(instanceId)
+   *     .setInstance(instance)
    *     .build();
-   *   while (true) {
-   *     ListInstanceConfigsResponse response = instanceAdminClient.listInstanceConfigsCallable().call(request);
-   *     for (InstanceConfig element : response.getInstanceConfigsList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
+   *   ApiFuture<Operation> future = instanceAdminClient.createInstanceCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
    * }
    * 
*/ - public final UnaryCallable - listInstanceConfigsCallable() { - return stub.listInstanceConfigsCallable(); + public final UnaryCallable createInstanceCallable() { + return stub.createInstanceCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets information about a particular instance configuration. + * Updates an instance, and begins allocating or releasing resources as requested. The returned + * [long-running operation][google.longrunning.Operation] can be used to track the progress of + * updating the instance. If the named instance does not exist, returns `NOT_FOUND`. + * + *

Immediately upon completion of this request: + * + *

* For resource types for which a decrease in the instance's allocation has been + * requested, billing is based on the newly-requested level. + * + *

Until completion of the returned operation: + * + *

* Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins + * restoring resources to their pre-request values. The operation is guaranteed to succeed at + * undoing all resource changes, after which point it terminates with a `CANCELLED` status. * + * All other attempts to modify the instance are rejected. * Reading the instance via the API + * continues to give the pre-request resource levels. + * + *

Upon completion of the returned operation: + * + *

* Billing begins for all successfully-allocated resources (some types may have lower + * than the requested levels). * All newly-reserved resources are available for serving the + * instance's tables. * The instance's new resource levels are readable via the API. + * + *

The returned [long-running operation][google.longrunning.Operation] will have a name of the + * format `<instance_name>/operations/<operation_id>` and can be used to track the + * instance modification. The [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. + * + *

Authorization requires `spanner.instances.update` permission on resource + * [name][google.spanner.admin.instance.v1.Instance.name]. * *

Sample code: * *


    * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
-   *   InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
-   *   InstanceConfig response = instanceAdminClient.getInstanceConfig(name);
+   *   Instance instance = Instance.newBuilder().build();
+   *   FieldMask fieldMask = FieldMask.newBuilder().build();
+   *   Instance response = instanceAdminClient.updateInstanceAsync(instance, fieldMask).get();
    * }
    * 
* - * @param name Required. The name of the requested instance configuration. Values are of the form - * `projects/<project>/instanceConfigs/<config>`. + * @param instance Required. The instance to update, which must always include the instance name. + * Otherwise, only fields mentioned in + * [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] need be + * included. + * @param fieldMask Required. A mask specifying which fields in + * [Instance][google.spanner.admin.instance.v1.Instance] should be updated. The field mask + * must always be specified; this prevents any future fields in + * [Instance][google.spanner.admin.instance.v1.Instance] from being erased accidentally by + * clients that do not know about them. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final InstanceConfig getInstanceConfig(InstanceConfigName name) { - GetInstanceConfigRequest request = - GetInstanceConfigRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return getInstanceConfig(request); + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture updateInstanceAsync( + Instance instance, FieldMask fieldMask) { + UpdateInstanceRequest request = + UpdateInstanceRequest.newBuilder().setInstance(instance).setFieldMask(fieldMask).build(); + return updateInstanceAsync(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets information about a particular instance configuration. + * Updates an instance, and begins allocating or releasing resources as requested. The returned + * [long-running operation][google.longrunning.Operation] can be used to track the progress of + * updating the instance. If the named instance does not exist, returns `NOT_FOUND`. + * + *

Immediately upon completion of this request: + * + *

* For resource types for which a decrease in the instance's allocation has been + * requested, billing is based on the newly-requested level. + * + *

Until completion of the returned operation: + * + *

* Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins + * restoring resources to their pre-request values. The operation is guaranteed to succeed at + * undoing all resource changes, after which point it terminates with a `CANCELLED` status. * + * All other attempts to modify the instance are rejected. * Reading the instance via the API + * continues to give the pre-request resource levels. + * + *

Upon completion of the returned operation: + * + *

* Billing begins for all successfully-allocated resources (some types may have lower + * than the requested levels). * All newly-reserved resources are available for serving the + * instance's tables. * The instance's new resource levels are readable via the API. + * + *

The returned [long-running operation][google.longrunning.Operation] will have a name of the + * format `<instance_name>/operations/<operation_id>` and can be used to track the + * instance modification. The [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. + * + *

Authorization requires `spanner.instances.update` permission on resource + * [name][google.spanner.admin.instance.v1.Instance.name]. * *

Sample code: * *


    * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
-   *   InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
-   *   InstanceConfig response = instanceAdminClient.getInstanceConfig(name.toString());
+   *   Instance instance = Instance.newBuilder().build();
+   *   FieldMask fieldMask = FieldMask.newBuilder().build();
+   *   UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder()
+   *     .setInstance(instance)
+   *     .setFieldMask(fieldMask)
+   *     .build();
+   *   Instance response = instanceAdminClient.updateInstanceAsync(request).get();
    * }
    * 
* - * @param name Required. The name of the requested instance configuration. Values are of the form - * `projects/<project>/instanceConfigs/<config>`. + * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final InstanceConfig getInstanceConfig(String name) { - GetInstanceConfigRequest request = GetInstanceConfigRequest.newBuilder().setName(name).build(); - return getInstanceConfig(request); + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture updateInstanceAsync( + UpdateInstanceRequest request) { + return updateInstanceOperationCallable().futureCall(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets information about a particular instance configuration. + * Updates an instance, and begins allocating or releasing resources as requested. The returned + * [long-running operation][google.longrunning.Operation] can be used to track the progress of + * updating the instance. If the named instance does not exist, returns `NOT_FOUND`. + * + *

Immediately upon completion of this request: + * + *

* For resource types for which a decrease in the instance's allocation has been + * requested, billing is based on the newly-requested level. + * + *

Until completion of the returned operation: + * + *

* Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins + * restoring resources to their pre-request values. The operation is guaranteed to succeed at + * undoing all resource changes, after which point it terminates with a `CANCELLED` status. * + * All other attempts to modify the instance are rejected. * Reading the instance via the API + * continues to give the pre-request resource levels. + * + *

Upon completion of the returned operation: + * + *

* Billing begins for all successfully-allocated resources (some types may have lower + * than the requested levels). * All newly-reserved resources are available for serving the + * instance's tables. * The instance's new resource levels are readable via the API. + * + *

The returned [long-running operation][google.longrunning.Operation] will have a name of the + * format `<instance_name>/operations/<operation_id>` and can be used to track the + * instance modification. The [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. + * + *

Authorization requires `spanner.instances.update` permission on resource + * [name][google.spanner.admin.instance.v1.Instance.name]. * *

Sample code: * *


    * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
-   *   InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
-   *   GetInstanceConfigRequest request = GetInstanceConfigRequest.newBuilder()
-   *     .setName(name.toString())
+   *   Instance instance = Instance.newBuilder().build();
+   *   FieldMask fieldMask = FieldMask.newBuilder().build();
+   *   UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder()
+   *     .setInstance(instance)
+   *     .setFieldMask(fieldMask)
    *     .build();
-   *   InstanceConfig response = instanceAdminClient.getInstanceConfig(request);
+   *   OperationFuture<Instance, UpdateInstanceMetadata> future = instanceAdminClient.updateInstanceOperationCallable().futureCall(request);
+   *   // Do something
+   *   Instance response = future.get();
    * }
    * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final InstanceConfig getInstanceConfig(GetInstanceConfigRequest request) { - return getInstanceConfigCallable().call(request); + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public final OperationCallable + updateInstanceOperationCallable() { + return stub.updateInstanceOperationCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets information about a particular instance configuration. + * Updates an instance, and begins allocating or releasing resources as requested. The returned + * [long-running operation][google.longrunning.Operation] can be used to track the progress of + * updating the instance. If the named instance does not exist, returns `NOT_FOUND`. + * + *

Immediately upon completion of this request: + * + *

* For resource types for which a decrease in the instance's allocation has been + * requested, billing is based on the newly-requested level. + * + *

Until completion of the returned operation: + * + *

* Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins + * restoring resources to their pre-request values. The operation is guaranteed to succeed at + * undoing all resource changes, after which point it terminates with a `CANCELLED` status. * + * All other attempts to modify the instance are rejected. * Reading the instance via the API + * continues to give the pre-request resource levels. + * + *

Upon completion of the returned operation: + * + *

* Billing begins for all successfully-allocated resources (some types may have lower + * than the requested levels). * All newly-reserved resources are available for serving the + * instance's tables. * The instance's new resource levels are readable via the API. + * + *

The returned [long-running operation][google.longrunning.Operation] will have a name of the + * format `<instance_name>/operations/<operation_id>` and can be used to track the + * instance modification. The [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. + * + *

Authorization requires `spanner.instances.update` permission on resource + * [name][google.spanner.admin.instance.v1.Instance.name]. * *

Sample code: * *


    * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
-   *   InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
-   *   GetInstanceConfigRequest request = GetInstanceConfigRequest.newBuilder()
-   *     .setName(name.toString())
+   *   Instance instance = Instance.newBuilder().build();
+   *   FieldMask fieldMask = FieldMask.newBuilder().build();
+   *   UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder()
+   *     .setInstance(instance)
+   *     .setFieldMask(fieldMask)
    *     .build();
-   *   ApiFuture<InstanceConfig> future = instanceAdminClient.getInstanceConfigCallable().futureCall(request);
+   *   ApiFuture<Operation> future = instanceAdminClient.updateInstanceCallable().futureCall(request);
    *   // Do something
-   *   InstanceConfig response = future.get();
+   *   Operation response = future.get();
    * }
    * 
*/ - public final UnaryCallable getInstanceConfigCallable() { - return stub.getInstanceConfigCallable(); + public final UnaryCallable updateInstanceCallable() { + return stub.updateInstanceCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists all instances in the given project. + * Lists the supported instance configurations for a given project. * *

Sample code: * *


    * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   for (Instance element : instanceAdminClient.listInstances(parent).iterateAll()) {
+   *   for (InstanceConfig element : instanceAdminClient.listInstanceConfigs(parent).iterateAll()) {
    *     // doThingsWith(element);
    *   }
    * }
    * 
* - * @param parent Required. The name of the project for which a list of instances is requested. - * Values are of the form `projects/<project>`. + * @param parent Required. The name of the project for which a list of supported instance + * configurations is requested. Values are of the form `projects/<project>`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final ListInstancesPagedResponse listInstances(ProjectName parent) { - ListInstancesRequest request = - ListInstancesRequest.newBuilder() + public final ListInstanceConfigsPagedResponse listInstanceConfigs(ProjectName parent) { + ListInstanceConfigsRequest request = + ListInstanceConfigsRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) .build(); - return listInstances(request); + return listInstanceConfigs(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists all instances in the given project. + * Lists the supported instance configurations for a given project. * *

Sample code: * *


    * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   for (Instance element : instanceAdminClient.listInstances(parent.toString()).iterateAll()) {
+   *   for (InstanceConfig element : instanceAdminClient.listInstanceConfigs(parent.toString()).iterateAll()) {
    *     // doThingsWith(element);
    *   }
    * }
    * 
* - * @param parent Required. The name of the project for which a list of instances is requested. + * @param parent Required. The name of the project for which a list of supported instance + * configurations is requested. Values are of the form `projects/<project>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListInstanceConfigsPagedResponse listInstanceConfigs(String parent) { + ListInstanceConfigsRequest request = + ListInstanceConfigsRequest.newBuilder().setParent(parent).build(); + return listInstanceConfigs(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists the supported instance configurations for a given project. + * + *

Sample code: + * + *


+   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ListInstanceConfigsRequest request = ListInstanceConfigsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   for (InstanceConfig element : instanceAdminClient.listInstanceConfigs(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListInstanceConfigsPagedResponse listInstanceConfigs( + ListInstanceConfigsRequest request) { + return listInstanceConfigsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists the supported instance configurations for a given project. + * + *

Sample code: + * + *


+   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ListInstanceConfigsRequest request = ListInstanceConfigsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<ListInstanceConfigsPagedResponse> future = instanceAdminClient.listInstanceConfigsPagedCallable().futureCall(request);
+   *   // Do something
+   *   for (InstanceConfig element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable + listInstanceConfigsPagedCallable() { + return stub.listInstanceConfigsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists the supported instance configurations for a given project. + * + *

Sample code: + * + *


+   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ListInstanceConfigsRequest request = ListInstanceConfigsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   while (true) {
+   *     ListInstanceConfigsResponse response = instanceAdminClient.listInstanceConfigsCallable().call(request);
+   *     for (InstanceConfig element : response.getInstanceConfigsList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable + listInstanceConfigsCallable() { + return stub.listInstanceConfigsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets information about a particular instance configuration. + * + *

Sample code: + * + *


+   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
+   *   InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
+   *   InstanceConfig response = instanceAdminClient.getInstanceConfig(name);
+   * }
+   * 
+ * + * @param name Required. The name of the requested instance configuration. Values are of the form + * `projects/<project>/instanceConfigs/<config>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final InstanceConfig getInstanceConfig(InstanceConfigName name) { + GetInstanceConfigRequest request = + GetInstanceConfigRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getInstanceConfig(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets information about a particular instance configuration. + * + *

Sample code: + * + *


+   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
+   *   InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
+   *   InstanceConfig response = instanceAdminClient.getInstanceConfig(name.toString());
+   * }
+   * 
+ * + * @param name Required. The name of the requested instance configuration. Values are of the form + * `projects/<project>/instanceConfigs/<config>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final InstanceConfig getInstanceConfig(String name) { + GetInstanceConfigRequest request = GetInstanceConfigRequest.newBuilder().setName(name).build(); + return getInstanceConfig(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets information about a particular instance configuration. + * + *

Sample code: + * + *


+   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
+   *   InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
+   *   GetInstanceConfigRequest request = GetInstanceConfigRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   InstanceConfig response = instanceAdminClient.getInstanceConfig(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final InstanceConfig getInstanceConfig(GetInstanceConfigRequest request) { + return getInstanceConfigCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets information about a particular instance configuration. + * + *

Sample code: + * + *


+   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
+   *   InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
+   *   GetInstanceConfigRequest request = GetInstanceConfigRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<InstanceConfig> future = instanceAdminClient.getInstanceConfigCallable().futureCall(request);
+   *   // Do something
+   *   InstanceConfig response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getInstanceConfigCallable() { + return stub.getInstanceConfigCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists all instances in the given project. + * + *

Sample code: + * + *


+   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (Instance element : instanceAdminClient.listInstances(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The name of the project for which a list of instances is requested. + * Values are of the form `projects/<project>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListInstancesPagedResponse listInstances(ProjectName parent) { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listInstances(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists all instances in the given project. + * + *

Sample code: + * + *


+   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (Instance element : instanceAdminClient.listInstances(parent.toString()).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The name of the project for which a list of instances is requested. * Values are of the form `projects/<project>`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -659,542 +1195,6 @@ public final UnaryCallable getInstanceCallable() { return stub.getInstanceCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates an instance and begins preparing it to begin serving. The returned [long-running - * operation][google.longrunning.Operation] can be used to track the progress of preparing the new - * instance. The instance name is assigned by the caller. If the named instance already exists, - * `CreateInstance` returns `ALREADY_EXISTS`. - * - *

Immediately upon completion of this request: - * - *

* The instance is readable via the API, with all requested attributes but no allocated - * resources. Its state is `CREATING`. - * - *

Until completion of the returned operation: - * - *

* Cancelling the operation renders the instance immediately unreadable via the API. - * * The instance can be deleted. * All other attempts to modify the instance are - * rejected. - * - *

Upon completion of the returned operation: - * - *

* Billing for all successfully-allocated resources begins (some types may have lower - * than the requested levels). * Databases can be created in the instance. * The - * instance's allocated resource levels are readable via the API. * The instance's state - * becomes `READY`. - * - *

The returned [long-running operation][google.longrunning.Operation] will have a name of the - * format `<instance_name>/operations/<operation_id>` and can be used to track - * creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is - * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Instance][google.spanner.admin.instance.v1.Instance], if successful. - * - *

Sample code: - * - *


-   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   String instanceId = "";
-   *   Instance instance = Instance.newBuilder().build();
-   *   Instance response = instanceAdminClient.createInstanceAsync(parent, instanceId, instance).get();
-   * }
-   * 
- * - * @param parent Required. The name of the project in which to create the instance. Values are of - * the form `projects/<project>`. - * @param instanceId Required. The ID of the instance to create. Valid identifiers are of the form - * `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in length. - * @param instance Required. The instance to create. The name may be omitted, but if specified - * must be `<parent>/instances/<instance_id>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture createInstanceAsync( - ProjectName parent, String instanceId, Instance instance) { - CreateInstanceRequest request = - CreateInstanceRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .setInstanceId(instanceId) - .setInstance(instance) - .build(); - return createInstanceAsync(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates an instance and begins preparing it to begin serving. The returned [long-running - * operation][google.longrunning.Operation] can be used to track the progress of preparing the new - * instance. The instance name is assigned by the caller. If the named instance already exists, - * `CreateInstance` returns `ALREADY_EXISTS`. - * - *

Immediately upon completion of this request: - * - *

* The instance is readable via the API, with all requested attributes but no allocated - * resources. Its state is `CREATING`. - * - *

Until completion of the returned operation: - * - *

* Cancelling the operation renders the instance immediately unreadable via the API. - * * The instance can be deleted. * All other attempts to modify the instance are - * rejected. - * - *

Upon completion of the returned operation: - * - *

* Billing for all successfully-allocated resources begins (some types may have lower - * than the requested levels). * Databases can be created in the instance. * The - * instance's allocated resource levels are readable via the API. * The instance's state - * becomes `READY`. - * - *

The returned [long-running operation][google.longrunning.Operation] will have a name of the - * format `<instance_name>/operations/<operation_id>` and can be used to track - * creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is - * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Instance][google.spanner.admin.instance.v1.Instance], if successful. - * - *

Sample code: - * - *


-   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   String instanceId = "";
-   *   Instance instance = Instance.newBuilder().build();
-   *   Instance response = instanceAdminClient.createInstanceAsync(parent.toString(), instanceId, instance).get();
-   * }
-   * 
- * - * @param parent Required. The name of the project in which to create the instance. Values are of - * the form `projects/<project>`. - * @param instanceId Required. The ID of the instance to create. Valid identifiers are of the form - * `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in length. - * @param instance Required. The instance to create. The name may be omitted, but if specified - * must be `<parent>/instances/<instance_id>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture createInstanceAsync( - String parent, String instanceId, Instance instance) { - CreateInstanceRequest request = - CreateInstanceRequest.newBuilder() - .setParent(parent) - .setInstanceId(instanceId) - .setInstance(instance) - .build(); - return createInstanceAsync(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates an instance and begins preparing it to begin serving. The returned [long-running - * operation][google.longrunning.Operation] can be used to track the progress of preparing the new - * instance. The instance name is assigned by the caller. If the named instance already exists, - * `CreateInstance` returns `ALREADY_EXISTS`. - * - *

Immediately upon completion of this request: - * - *

* The instance is readable via the API, with all requested attributes but no allocated - * resources. Its state is `CREATING`. - * - *

Until completion of the returned operation: - * - *

* Cancelling the operation renders the instance immediately unreadable via the API. - * * The instance can be deleted. * All other attempts to modify the instance are - * rejected. - * - *

Upon completion of the returned operation: - * - *

* Billing for all successfully-allocated resources begins (some types may have lower - * than the requested levels). * Databases can be created in the instance. * The - * instance's allocated resource levels are readable via the API. * The instance's state - * becomes `READY`. - * - *

The returned [long-running operation][google.longrunning.Operation] will have a name of the - * format `<instance_name>/operations/<operation_id>` and can be used to track - * creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is - * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Instance][google.spanner.admin.instance.v1.Instance], if successful. - * - *

Sample code: - * - *


-   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   String instanceId = "";
-   *   Instance instance = Instance.newBuilder().build();
-   *   CreateInstanceRequest request = CreateInstanceRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setInstanceId(instanceId)
-   *     .setInstance(instance)
-   *     .build();
-   *   Instance response = instanceAdminClient.createInstanceAsync(request).get();
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture createInstanceAsync( - CreateInstanceRequest request) { - return createInstanceOperationCallable().futureCall(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates an instance and begins preparing it to begin serving. The returned [long-running - * operation][google.longrunning.Operation] can be used to track the progress of preparing the new - * instance. The instance name is assigned by the caller. If the named instance already exists, - * `CreateInstance` returns `ALREADY_EXISTS`. - * - *

Immediately upon completion of this request: - * - *

* The instance is readable via the API, with all requested attributes but no allocated - * resources. Its state is `CREATING`. - * - *

Until completion of the returned operation: - * - *

* Cancelling the operation renders the instance immediately unreadable via the API. - * * The instance can be deleted. * All other attempts to modify the instance are - * rejected. - * - *

Upon completion of the returned operation: - * - *

* Billing for all successfully-allocated resources begins (some types may have lower - * than the requested levels). * Databases can be created in the instance. * The - * instance's allocated resource levels are readable via the API. * The instance's state - * becomes `READY`. - * - *

The returned [long-running operation][google.longrunning.Operation] will have a name of the - * format `<instance_name>/operations/<operation_id>` and can be used to track - * creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is - * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Instance][google.spanner.admin.instance.v1.Instance], if successful. - * - *

Sample code: - * - *


-   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   String instanceId = "";
-   *   Instance instance = Instance.newBuilder().build();
-   *   CreateInstanceRequest request = CreateInstanceRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setInstanceId(instanceId)
-   *     .setInstance(instance)
-   *     .build();
-   *   OperationFuture<Instance, CreateInstanceMetadata> future = instanceAdminClient.createInstanceOperationCallable().futureCall(request);
-   *   // Do something
-   *   Instance response = future.get();
-   * }
-   * 
- */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public final OperationCallable - createInstanceOperationCallable() { - return stub.createInstanceOperationCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates an instance and begins preparing it to begin serving. The returned [long-running - * operation][google.longrunning.Operation] can be used to track the progress of preparing the new - * instance. The instance name is assigned by the caller. If the named instance already exists, - * `CreateInstance` returns `ALREADY_EXISTS`. - * - *

Immediately upon completion of this request: - * - *

* The instance is readable via the API, with all requested attributes but no allocated - * resources. Its state is `CREATING`. - * - *

Until completion of the returned operation: - * - *

* Cancelling the operation renders the instance immediately unreadable via the API. - * * The instance can be deleted. * All other attempts to modify the instance are - * rejected. - * - *

Upon completion of the returned operation: - * - *

* Billing for all successfully-allocated resources begins (some types may have lower - * than the requested levels). * Databases can be created in the instance. * The - * instance's allocated resource levels are readable via the API. * The instance's state - * becomes `READY`. - * - *

The returned [long-running operation][google.longrunning.Operation] will have a name of the - * format `<instance_name>/operations/<operation_id>` and can be used to track - * creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is - * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Instance][google.spanner.admin.instance.v1.Instance], if successful. - * - *

Sample code: - * - *


-   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   String instanceId = "";
-   *   Instance instance = Instance.newBuilder().build();
-   *   CreateInstanceRequest request = CreateInstanceRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setInstanceId(instanceId)
-   *     .setInstance(instance)
-   *     .build();
-   *   ApiFuture<Operation> future = instanceAdminClient.createInstanceCallable().futureCall(request);
-   *   // Do something
-   *   Operation response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable createInstanceCallable() { - return stub.createInstanceCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates an instance, and begins allocating or releasing resources as requested. The returned - * [long-running operation][google.longrunning.Operation] can be used to track the progress of - * updating the instance. If the named instance does not exist, returns `NOT_FOUND`. - * - *

Immediately upon completion of this request: - * - *

* For resource types for which a decrease in the instance's allocation has been - * requested, billing is based on the newly-requested level. - * - *

Until completion of the returned operation: - * - *

* Cancelling the operation sets its metadata's - * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins - * restoring resources to their pre-request values. The operation is guaranteed to succeed at - * undoing all resource changes, after which point it terminates with a `CANCELLED` status. * - * All other attempts to modify the instance are rejected. * Reading the instance via the API - * continues to give the pre-request resource levels. - * - *

Upon completion of the returned operation: - * - *

* Billing begins for all successfully-allocated resources (some types may have lower - * than the requested levels). * All newly-reserved resources are available for serving the - * instance's tables. * The instance's new resource levels are readable via the API. - * - *

The returned [long-running operation][google.longrunning.Operation] will have a name of the - * format `<instance_name>/operations/<operation_id>` and can be used to track the - * instance modification. The [metadata][google.longrunning.Operation.metadata] field type is - * [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Instance][google.spanner.admin.instance.v1.Instance], if successful. - * - *

Authorization requires `spanner.instances.update` permission on resource - * [name][google.spanner.admin.instance.v1.Instance.name]. - * - *

Sample code: - * - *


-   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
-   *   Instance instance = Instance.newBuilder().build();
-   *   FieldMask fieldMask = FieldMask.newBuilder().build();
-   *   Instance response = instanceAdminClient.updateInstanceAsync(instance, fieldMask).get();
-   * }
-   * 
- * - * @param instance Required. The instance to update, which must always include the instance name. - * Otherwise, only fields mentioned in - * [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] need be - * included. - * @param fieldMask Required. A mask specifying which fields in - * [Instance][google.spanner.admin.instance.v1.Instance] should be updated. The field mask - * must always be specified; this prevents any future fields in - * [Instance][google.spanner.admin.instance.v1.Instance] from being erased accidentally by - * clients that do not know about them. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture updateInstanceAsync( - Instance instance, FieldMask fieldMask) { - UpdateInstanceRequest request = - UpdateInstanceRequest.newBuilder().setInstance(instance).setFieldMask(fieldMask).build(); - return updateInstanceAsync(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates an instance, and begins allocating or releasing resources as requested. The returned - * [long-running operation][google.longrunning.Operation] can be used to track the progress of - * updating the instance. If the named instance does not exist, returns `NOT_FOUND`. - * - *

Immediately upon completion of this request: - * - *

* For resource types for which a decrease in the instance's allocation has been - * requested, billing is based on the newly-requested level. - * - *

Until completion of the returned operation: - * - *

* Cancelling the operation sets its metadata's - * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins - * restoring resources to their pre-request values. The operation is guaranteed to succeed at - * undoing all resource changes, after which point it terminates with a `CANCELLED` status. * - * All other attempts to modify the instance are rejected. * Reading the instance via the API - * continues to give the pre-request resource levels. - * - *

Upon completion of the returned operation: - * - *

* Billing begins for all successfully-allocated resources (some types may have lower - * than the requested levels). * All newly-reserved resources are available for serving the - * instance's tables. * The instance's new resource levels are readable via the API. - * - *

The returned [long-running operation][google.longrunning.Operation] will have a name of the - * format `<instance_name>/operations/<operation_id>` and can be used to track the - * instance modification. The [metadata][google.longrunning.Operation.metadata] field type is - * [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Instance][google.spanner.admin.instance.v1.Instance], if successful. - * - *

Authorization requires `spanner.instances.update` permission on resource - * [name][google.spanner.admin.instance.v1.Instance.name]. - * - *

Sample code: - * - *


-   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
-   *   Instance instance = Instance.newBuilder().build();
-   *   FieldMask fieldMask = FieldMask.newBuilder().build();
-   *   UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder()
-   *     .setInstance(instance)
-   *     .setFieldMask(fieldMask)
-   *     .build();
-   *   Instance response = instanceAdminClient.updateInstanceAsync(request).get();
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture updateInstanceAsync( - UpdateInstanceRequest request) { - return updateInstanceOperationCallable().futureCall(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates an instance, and begins allocating or releasing resources as requested. The returned - * [long-running operation][google.longrunning.Operation] can be used to track the progress of - * updating the instance. If the named instance does not exist, returns `NOT_FOUND`. - * - *

Immediately upon completion of this request: - * - *

* For resource types for which a decrease in the instance's allocation has been - * requested, billing is based on the newly-requested level. - * - *

Until completion of the returned operation: - * - *

* Cancelling the operation sets its metadata's - * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins - * restoring resources to their pre-request values. The operation is guaranteed to succeed at - * undoing all resource changes, after which point it terminates with a `CANCELLED` status. * - * All other attempts to modify the instance are rejected. * Reading the instance via the API - * continues to give the pre-request resource levels. - * - *

Upon completion of the returned operation: - * - *

* Billing begins for all successfully-allocated resources (some types may have lower - * than the requested levels). * All newly-reserved resources are available for serving the - * instance's tables. * The instance's new resource levels are readable via the API. - * - *

The returned [long-running operation][google.longrunning.Operation] will have a name of the - * format `<instance_name>/operations/<operation_id>` and can be used to track the - * instance modification. The [metadata][google.longrunning.Operation.metadata] field type is - * [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Instance][google.spanner.admin.instance.v1.Instance], if successful. - * - *

Authorization requires `spanner.instances.update` permission on resource - * [name][google.spanner.admin.instance.v1.Instance.name]. - * - *

Sample code: - * - *


-   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
-   *   Instance instance = Instance.newBuilder().build();
-   *   FieldMask fieldMask = FieldMask.newBuilder().build();
-   *   UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder()
-   *     .setInstance(instance)
-   *     .setFieldMask(fieldMask)
-   *     .build();
-   *   OperationFuture<Instance, UpdateInstanceMetadata> future = instanceAdminClient.updateInstanceOperationCallable().futureCall(request);
-   *   // Do something
-   *   Instance response = future.get();
-   * }
-   * 
- */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public final OperationCallable - updateInstanceOperationCallable() { - return stub.updateInstanceOperationCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates an instance, and begins allocating or releasing resources as requested. The returned - * [long-running operation][google.longrunning.Operation] can be used to track the progress of - * updating the instance. If the named instance does not exist, returns `NOT_FOUND`. - * - *

Immediately upon completion of this request: - * - *

* For resource types for which a decrease in the instance's allocation has been - * requested, billing is based on the newly-requested level. - * - *

Until completion of the returned operation: - * - *

* Cancelling the operation sets its metadata's - * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins - * restoring resources to their pre-request values. The operation is guaranteed to succeed at - * undoing all resource changes, after which point it terminates with a `CANCELLED` status. * - * All other attempts to modify the instance are rejected. * Reading the instance via the API - * continues to give the pre-request resource levels. - * - *

Upon completion of the returned operation: - * - *

* Billing begins for all successfully-allocated resources (some types may have lower - * than the requested levels). * All newly-reserved resources are available for serving the - * instance's tables. * The instance's new resource levels are readable via the API. - * - *

The returned [long-running operation][google.longrunning.Operation] will have a name of the - * format `<instance_name>/operations/<operation_id>` and can be used to track the - * instance modification. The [metadata][google.longrunning.Operation.metadata] field type is - * [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Instance][google.spanner.admin.instance.v1.Instance], if successful. - * - *

Authorization requires `spanner.instances.update` permission on resource - * [name][google.spanner.admin.instance.v1.Instance.name]. - * - *

Sample code: - * - *


-   * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
-   *   Instance instance = Instance.newBuilder().build();
-   *   FieldMask fieldMask = FieldMask.newBuilder().build();
-   *   UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder()
-   *     .setInstance(instance)
-   *     .setFieldMask(fieldMask)
-   *     .build();
-   *   ApiFuture<Operation> future = instanceAdminClient.updateInstanceCallable().futureCall(request);
-   *   // Do something
-   *   Operation response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable updateInstanceCallable() { - return stub.updateInstanceCallable(); - } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Deletes an instance. diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminSettings.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminSettings.java index b64951873c..f9cdab9d26 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminSettings.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminSettings.java @@ -89,29 +89,6 @@ @Generated("by gapic-generator") @BetaApi public class InstanceAdminSettings extends ClientSettings { - /** Returns the object with the settings used for calls to listInstanceConfigs. */ - public PagedCallSettings< - ListInstanceConfigsRequest, ListInstanceConfigsResponse, ListInstanceConfigsPagedResponse> - listInstanceConfigsSettings() { - return ((InstanceAdminStubSettings) getStubSettings()).listInstanceConfigsSettings(); - } - - /** Returns the object with the settings used for calls to getInstanceConfig. */ - public UnaryCallSettings getInstanceConfigSettings() { - return ((InstanceAdminStubSettings) getStubSettings()).getInstanceConfigSettings(); - } - - /** Returns the object with the settings used for calls to listInstances. */ - public PagedCallSettings - listInstancesSettings() { - return ((InstanceAdminStubSettings) getStubSettings()).listInstancesSettings(); - } - - /** Returns the object with the settings used for calls to getInstance. */ - public UnaryCallSettings getInstanceSettings() { - return ((InstanceAdminStubSettings) getStubSettings()).getInstanceSettings(); - } - /** Returns the object with the settings used for calls to createInstance. */ public UnaryCallSettings createInstanceSettings() { return ((InstanceAdminStubSettings) getStubSettings()).createInstanceSettings(); @@ -138,6 +115,29 @@ public UnaryCallSettings updateInstanceSetting return ((InstanceAdminStubSettings) getStubSettings()).updateInstanceOperationSettings(); } + /** Returns the object with the settings used for calls to listInstanceConfigs. */ + public PagedCallSettings< + ListInstanceConfigsRequest, ListInstanceConfigsResponse, ListInstanceConfigsPagedResponse> + listInstanceConfigsSettings() { + return ((InstanceAdminStubSettings) getStubSettings()).listInstanceConfigsSettings(); + } + + /** Returns the object with the settings used for calls to getInstanceConfig. */ + public UnaryCallSettings getInstanceConfigSettings() { + return ((InstanceAdminStubSettings) getStubSettings()).getInstanceConfigSettings(); + } + + /** Returns the object with the settings used for calls to listInstances. */ + public PagedCallSettings + listInstancesSettings() { + return ((InstanceAdminStubSettings) getStubSettings()).listInstancesSettings(); + } + + /** Returns the object with the settings used for calls to getInstance. */ + public UnaryCallSettings getInstanceSettings() { + return ((InstanceAdminStubSettings) getStubSettings()).getInstanceSettings(); + } + /** Returns the object with the settings used for calls to deleteInstance. */ public UnaryCallSettings deleteInstanceSettings() { return ((InstanceAdminStubSettings) getStubSettings()).deleteInstanceSettings(); @@ -256,6 +256,32 @@ public Builder applyToAllUnaryMethods( return this; } + /** Returns the builder for the settings used for calls to createInstance. */ + public UnaryCallSettings.Builder createInstanceSettings() { + return getStubSettingsBuilder().createInstanceSettings(); + } + + /** Returns the builder for the settings used for calls to createInstance. */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings.Builder + createInstanceOperationSettings() { + return getStubSettingsBuilder().createInstanceOperationSettings(); + } + + /** Returns the builder for the settings used for calls to updateInstance. */ + public UnaryCallSettings.Builder updateInstanceSettings() { + return getStubSettingsBuilder().updateInstanceSettings(); + } + + /** Returns the builder for the settings used for calls to updateInstance. */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings.Builder + updateInstanceOperationSettings() { + return getStubSettingsBuilder().updateInstanceOperationSettings(); + } + /** Returns the builder for the settings used for calls to listInstanceConfigs. */ public PagedCallSettings.Builder< ListInstanceConfigsRequest, @@ -283,32 +309,6 @@ public UnaryCallSettings.Builder getInstanceSettin return getStubSettingsBuilder().getInstanceSettings(); } - /** Returns the builder for the settings used for calls to createInstance. */ - public UnaryCallSettings.Builder createInstanceSettings() { - return getStubSettingsBuilder().createInstanceSettings(); - } - - /** Returns the builder for the settings used for calls to createInstance. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public OperationCallSettings.Builder - createInstanceOperationSettings() { - return getStubSettingsBuilder().createInstanceOperationSettings(); - } - - /** Returns the builder for the settings used for calls to updateInstance. */ - public UnaryCallSettings.Builder updateInstanceSettings() { - return getStubSettingsBuilder().updateInstanceSettings(); - } - - /** Returns the builder for the settings used for calls to updateInstance. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public OperationCallSettings.Builder - updateInstanceOperationSettings() { - return getStubSettingsBuilder().updateInstanceOperationSettings(); - } - /** Returns the builder for the settings used for calls to deleteInstance. */ public UnaryCallSettings.Builder deleteInstanceSettings() { return getStubSettingsBuilder().deleteInstanceSettings(); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/GrpcInstanceAdminStub.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/GrpcInstanceAdminStub.java index bbc144e69a..f64f7275cb 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/GrpcInstanceAdminStub.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/GrpcInstanceAdminStub.java @@ -66,6 +66,24 @@ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public class GrpcInstanceAdminStub extends InstanceAdminStub { + private static final MethodDescriptor + createInstanceMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.spanner.admin.instance.v1.InstanceAdmin/CreateInstance") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateInstanceRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + private static final MethodDescriptor + updateInstanceMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.spanner.admin.instance.v1.InstanceAdmin/UpdateInstance") + .setRequestMarshaller( + ProtoUtils.marshaller(UpdateInstanceRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); private static final MethodDescriptor listInstanceConfigsMethodDescriptor = MethodDescriptor.newBuilder() @@ -103,24 +121,6 @@ public class GrpcInstanceAdminStub extends InstanceAdminStub { .setRequestMarshaller(ProtoUtils.marshaller(GetInstanceRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Instance.getDefaultInstance())) .build(); - private static final MethodDescriptor - createInstanceMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.spanner.admin.instance.v1.InstanceAdmin/CreateInstance") - .setRequestMarshaller( - ProtoUtils.marshaller(CreateInstanceRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) - .build(); - private static final MethodDescriptor - updateInstanceMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.spanner.admin.instance.v1.InstanceAdmin/UpdateInstance") - .setRequestMarshaller( - ProtoUtils.marshaller(UpdateInstanceRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) - .build(); private static final MethodDescriptor deleteInstanceMethodDescriptor = MethodDescriptor.newBuilder() @@ -159,6 +159,12 @@ public class GrpcInstanceAdminStub extends InstanceAdminStub { private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; + private final UnaryCallable createInstanceCallable; + private final OperationCallable + createInstanceOperationCallable; + private final UnaryCallable updateInstanceCallable; + private final OperationCallable + updateInstanceOperationCallable; private final UnaryCallable listInstanceConfigsCallable; private final UnaryCallable @@ -168,12 +174,6 @@ public class GrpcInstanceAdminStub extends InstanceAdminStub { private final UnaryCallable listInstancesPagedCallable; private final UnaryCallable getInstanceCallable; - private final UnaryCallable createInstanceCallable; - private final OperationCallable - createInstanceOperationCallable; - private final UnaryCallable updateInstanceCallable; - private final OperationCallable - updateInstanceOperationCallable; private final UnaryCallable deleteInstanceCallable; private final UnaryCallable setIamPolicyCallable; private final UnaryCallable getIamPolicyCallable; @@ -220,6 +220,32 @@ protected GrpcInstanceAdminStub( this.callableFactory = callableFactory; this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + GrpcCallSettings createInstanceTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createInstanceMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(CreateInstanceRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings updateInstanceTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateInstanceMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(UpdateInstanceRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("instance.name", String.valueOf(request.getInstance().getName())); + return params.build(); + } + }) + .build(); GrpcCallSettings listInstanceConfigsTransportSettings = GrpcCallSettings.newBuilder() @@ -273,32 +299,6 @@ public Map extract(GetInstanceRequest request) { } }) .build(); - GrpcCallSettings createInstanceTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createInstanceMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateInstanceRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } - }) - .build(); - GrpcCallSettings updateInstanceTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(updateInstanceMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateInstanceRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("instance.name", String.valueOf(request.getInstance().getName())); - return params.build(); - } - }) - .build(); GrpcCallSettings deleteInstanceTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteInstanceMethodDescriptor) @@ -353,6 +353,24 @@ public Map extract(TestIamPermissionsRequest request) { }) .build(); + this.createInstanceCallable = + callableFactory.createUnaryCallable( + createInstanceTransportSettings, settings.createInstanceSettings(), clientContext); + this.createInstanceOperationCallable = + callableFactory.createOperationCallable( + createInstanceTransportSettings, + settings.createInstanceOperationSettings(), + clientContext, + this.operationsStub); + this.updateInstanceCallable = + callableFactory.createUnaryCallable( + updateInstanceTransportSettings, settings.updateInstanceSettings(), clientContext); + this.updateInstanceOperationCallable = + callableFactory.createOperationCallable( + updateInstanceTransportSettings, + settings.updateInstanceOperationSettings(), + clientContext, + this.operationsStub); this.listInstanceConfigsCallable = callableFactory.createUnaryCallable( listInstanceConfigsTransportSettings, @@ -377,24 +395,6 @@ public Map extract(TestIamPermissionsRequest request) { this.getInstanceCallable = callableFactory.createUnaryCallable( getInstanceTransportSettings, settings.getInstanceSettings(), clientContext); - this.createInstanceCallable = - callableFactory.createUnaryCallable( - createInstanceTransportSettings, settings.createInstanceSettings(), clientContext); - this.createInstanceOperationCallable = - callableFactory.createOperationCallable( - createInstanceTransportSettings, - settings.createInstanceOperationSettings(), - clientContext, - this.operationsStub); - this.updateInstanceCallable = - callableFactory.createUnaryCallable( - updateInstanceTransportSettings, settings.updateInstanceSettings(), clientContext); - this.updateInstanceOperationCallable = - callableFactory.createOperationCallable( - updateInstanceTransportSettings, - settings.updateInstanceOperationSettings(), - clientContext, - this.operationsStub); this.deleteInstanceCallable = callableFactory.createUnaryCallable( deleteInstanceTransportSettings, settings.deleteInstanceSettings(), clientContext); @@ -418,6 +418,26 @@ public GrpcOperationsStub getOperationsStub() { return operationsStub; } + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable + createInstanceOperationCallable() { + return createInstanceOperationCallable; + } + + public UnaryCallable createInstanceCallable() { + return createInstanceCallable; + } + + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable + updateInstanceOperationCallable() { + return updateInstanceOperationCallable; + } + + public UnaryCallable updateInstanceCallable() { + return updateInstanceCallable; + } + public UnaryCallable listInstanceConfigsPagedCallable() { return listInstanceConfigsPagedCallable; @@ -445,26 +465,6 @@ public UnaryCallable getInstanceCallable() { return getInstanceCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallable - createInstanceOperationCallable() { - return createInstanceOperationCallable; - } - - public UnaryCallable createInstanceCallable() { - return createInstanceCallable; - } - - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallable - updateInstanceOperationCallable() { - return updateInstanceOperationCallable; - } - - public UnaryCallable updateInstanceCallable() { - return updateInstanceCallable; - } - public UnaryCallable deleteInstanceCallable() { return deleteInstanceCallable; } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStub.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStub.java index 77334eb1a2..085a696307 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStub.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStub.java @@ -60,6 +60,26 @@ public OperationsStub getOperationsStub() { throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); } + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable + createInstanceOperationCallable() { + throw new UnsupportedOperationException("Not implemented: createInstanceOperationCallable()"); + } + + public UnaryCallable createInstanceCallable() { + throw new UnsupportedOperationException("Not implemented: createInstanceCallable()"); + } + + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable + updateInstanceOperationCallable() { + throw new UnsupportedOperationException("Not implemented: updateInstanceOperationCallable()"); + } + + public UnaryCallable updateInstanceCallable() { + throw new UnsupportedOperationException("Not implemented: updateInstanceCallable()"); + } + public UnaryCallable listInstanceConfigsPagedCallable() { throw new UnsupportedOperationException("Not implemented: listInstanceConfigsPagedCallable()"); @@ -87,26 +107,6 @@ public UnaryCallable getInstanceCallable() { throw new UnsupportedOperationException("Not implemented: getInstanceCallable()"); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallable - createInstanceOperationCallable() { - throw new UnsupportedOperationException("Not implemented: createInstanceOperationCallable()"); - } - - public UnaryCallable createInstanceCallable() { - throw new UnsupportedOperationException("Not implemented: createInstanceCallable()"); - } - - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallable - updateInstanceOperationCallable() { - throw new UnsupportedOperationException("Not implemented: updateInstanceOperationCallable()"); - } - - public UnaryCallable updateInstanceCallable() { - throw new UnsupportedOperationException("Not implemented: updateInstanceCallable()"); - } - public UnaryCallable deleteInstanceCallable() { throw new UnsupportedOperationException("Not implemented: deleteInstanceCallable()"); } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStubSettings.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStubSettings.java index c975119498..4c31214912 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStubSettings.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStubSettings.java @@ -114,6 +114,12 @@ public class InstanceAdminStubSettings extends StubSettings createInstanceSettings; + private final OperationCallSettings + createInstanceOperationSettings; + private final UnaryCallSettings updateInstanceSettings; + private final OperationCallSettings + updateInstanceOperationSettings; private final PagedCallSettings< ListInstanceConfigsRequest, ListInstanceConfigsResponse, ListInstanceConfigsPagedResponse> listInstanceConfigsSettings; @@ -123,41 +129,12 @@ public class InstanceAdminStubSettings extends StubSettings listInstancesSettings; private final UnaryCallSettings getInstanceSettings; - private final UnaryCallSettings createInstanceSettings; - private final OperationCallSettings - createInstanceOperationSettings; - private final UnaryCallSettings updateInstanceSettings; - private final OperationCallSettings - updateInstanceOperationSettings; private final UnaryCallSettings deleteInstanceSettings; private final UnaryCallSettings setIamPolicySettings; private final UnaryCallSettings getIamPolicySettings; private final UnaryCallSettings testIamPermissionsSettings; - /** Returns the object with the settings used for calls to listInstanceConfigs. */ - public PagedCallSettings< - ListInstanceConfigsRequest, ListInstanceConfigsResponse, ListInstanceConfigsPagedResponse> - listInstanceConfigsSettings() { - return listInstanceConfigsSettings; - } - - /** Returns the object with the settings used for calls to getInstanceConfig. */ - public UnaryCallSettings getInstanceConfigSettings() { - return getInstanceConfigSettings; - } - - /** Returns the object with the settings used for calls to listInstances. */ - public PagedCallSettings - listInstancesSettings() { - return listInstancesSettings; - } - - /** Returns the object with the settings used for calls to getInstance. */ - public UnaryCallSettings getInstanceSettings() { - return getInstanceSettings; - } - /** Returns the object with the settings used for calls to createInstance. */ public UnaryCallSettings createInstanceSettings() { return createInstanceSettings; @@ -182,6 +159,29 @@ public UnaryCallSettings updateInstanceSetting return updateInstanceOperationSettings; } + /** Returns the object with the settings used for calls to listInstanceConfigs. */ + public PagedCallSettings< + ListInstanceConfigsRequest, ListInstanceConfigsResponse, ListInstanceConfigsPagedResponse> + listInstanceConfigsSettings() { + return listInstanceConfigsSettings; + } + + /** Returns the object with the settings used for calls to getInstanceConfig. */ + public UnaryCallSettings getInstanceConfigSettings() { + return getInstanceConfigSettings; + } + + /** Returns the object with the settings used for calls to listInstances. */ + public PagedCallSettings + listInstancesSettings() { + return listInstancesSettings; + } + + /** Returns the object with the settings used for calls to getInstance. */ + public UnaryCallSettings getInstanceSettings() { + return getInstanceSettings; + } + /** Returns the object with the settings used for calls to deleteInstance. */ public UnaryCallSettings deleteInstanceSettings() { return deleteInstanceSettings; @@ -272,14 +272,14 @@ public Builder toBuilder() { protected InstanceAdminStubSettings(Builder settingsBuilder) throws IOException { super(settingsBuilder); - listInstanceConfigsSettings = settingsBuilder.listInstanceConfigsSettings().build(); - getInstanceConfigSettings = settingsBuilder.getInstanceConfigSettings().build(); - listInstancesSettings = settingsBuilder.listInstancesSettings().build(); - getInstanceSettings = settingsBuilder.getInstanceSettings().build(); createInstanceSettings = settingsBuilder.createInstanceSettings().build(); createInstanceOperationSettings = settingsBuilder.createInstanceOperationSettings().build(); updateInstanceSettings = settingsBuilder.updateInstanceSettings().build(); updateInstanceOperationSettings = settingsBuilder.updateInstanceOperationSettings().build(); + listInstanceConfigsSettings = settingsBuilder.listInstanceConfigsSettings().build(); + getInstanceConfigSettings = settingsBuilder.getInstanceConfigSettings().build(); + listInstancesSettings = settingsBuilder.listInstancesSettings().build(); + getInstanceSettings = settingsBuilder.getInstanceSettings().build(); deleteInstanceSettings = settingsBuilder.deleteInstanceSettings().build(); setIamPolicySettings = settingsBuilder.setIamPolicySettings().build(); getIamPolicySettings = settingsBuilder.getIamPolicySettings().build(); @@ -404,6 +404,16 @@ public ApiFuture getFuturePagedResponse( public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; + private final UnaryCallSettings.Builder + createInstanceSettings; + private final OperationCallSettings.Builder< + CreateInstanceRequest, Instance, CreateInstanceMetadata> + createInstanceOperationSettings; + private final UnaryCallSettings.Builder + updateInstanceSettings; + private final OperationCallSettings.Builder< + UpdateInstanceRequest, Instance, UpdateInstanceMetadata> + updateInstanceOperationSettings; private final PagedCallSettings.Builder< ListInstanceConfigsRequest, ListInstanceConfigsResponse, @@ -415,16 +425,6 @@ public static class Builder extends StubSettings.Builder listInstancesSettings; private final UnaryCallSettings.Builder getInstanceSettings; - private final UnaryCallSettings.Builder - createInstanceSettings; - private final OperationCallSettings.Builder< - CreateInstanceRequest, Instance, CreateInstanceMetadata> - createInstanceOperationSettings; - private final UnaryCallSettings.Builder - updateInstanceSettings; - private final OperationCallSettings.Builder< - UpdateInstanceRequest, Instance, UpdateInstanceMetadata> - updateInstanceOperationSettings; private final UnaryCallSettings.Builder deleteInstanceSettings; private final UnaryCallSettings.Builder setIamPolicySettings; private final UnaryCallSettings.Builder getIamPolicySettings; @@ -438,11 +438,20 @@ public static class Builder extends StubSettings.Builder> definitions = ImmutableMap.builder(); definitions.put( - "idempotent", + "retry_policy_1_codes", ImmutableSet.copyOf( Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED))); + definitions.put( + "no_retry_2_codes", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put( + "retry_policy_2_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED))); + definitions.put( + "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -456,12 +465,41 @@ public static class Builder extends StubSettings.Builder>of( + createInstanceSettings, + updateInstanceSettings, listInstanceConfigsSettings, getInstanceConfigSettings, listInstancesSettings, getInstanceSettings, - createInstanceSettings, - updateInstanceSettings, deleteInstanceSettings, setIamPolicySettings, getIamPolicySettings, @@ -525,61 +563,61 @@ private static Builder createDefault() { private static Builder initDefaults(Builder builder) { builder - .listInstanceConfigsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .createInstanceSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); builder - .getInstanceConfigSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .updateInstanceSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); builder - .listInstancesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .listInstanceConfigsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder - .getInstanceSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .getInstanceConfigSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder - .createInstanceSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .listInstancesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder - .updateInstanceSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .getInstanceSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder .deleteInstanceSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder .setIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params")); builder .getIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); builder .testIamPermissionsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params")); builder .createInstanceOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Instance.class)) @@ -601,8 +639,8 @@ private static Builder initDefaults(Builder builder) { .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Instance.class)) @@ -626,14 +664,14 @@ private static Builder initDefaults(Builder builder) { protected Builder(InstanceAdminStubSettings settings) { super(settings); - listInstanceConfigsSettings = settings.listInstanceConfigsSettings.toBuilder(); - getInstanceConfigSettings = settings.getInstanceConfigSettings.toBuilder(); - listInstancesSettings = settings.listInstancesSettings.toBuilder(); - getInstanceSettings = settings.getInstanceSettings.toBuilder(); createInstanceSettings = settings.createInstanceSettings.toBuilder(); createInstanceOperationSettings = settings.createInstanceOperationSettings.toBuilder(); updateInstanceSettings = settings.updateInstanceSettings.toBuilder(); updateInstanceOperationSettings = settings.updateInstanceOperationSettings.toBuilder(); + listInstanceConfigsSettings = settings.listInstanceConfigsSettings.toBuilder(); + getInstanceConfigSettings = settings.getInstanceConfigSettings.toBuilder(); + listInstancesSettings = settings.listInstancesSettings.toBuilder(); + getInstanceSettings = settings.getInstanceSettings.toBuilder(); deleteInstanceSettings = settings.deleteInstanceSettings.toBuilder(); setIamPolicySettings = settings.setIamPolicySettings.toBuilder(); getIamPolicySettings = settings.getIamPolicySettings.toBuilder(); @@ -641,12 +679,12 @@ protected Builder(InstanceAdminStubSettings settings) { unaryMethodSettingsBuilders = ImmutableList.>of( + createInstanceSettings, + updateInstanceSettings, listInstanceConfigsSettings, getInstanceConfigSettings, listInstancesSettings, getInstanceSettings, - createInstanceSettings, - updateInstanceSettings, deleteInstanceSettings, setIamPolicySettings, getIamPolicySettings, @@ -669,6 +707,32 @@ public Builder applyToAllUnaryMethods( return unaryMethodSettingsBuilders; } + /** Returns the builder for the settings used for calls to createInstance. */ + public UnaryCallSettings.Builder createInstanceSettings() { + return createInstanceSettings; + } + + /** Returns the builder for the settings used for calls to createInstance. */ + @BetaApi( + "The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder + createInstanceOperationSettings() { + return createInstanceOperationSettings; + } + + /** Returns the builder for the settings used for calls to updateInstance. */ + public UnaryCallSettings.Builder updateInstanceSettings() { + return updateInstanceSettings; + } + + /** Returns the builder for the settings used for calls to updateInstance. */ + @BetaApi( + "The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder + updateInstanceOperationSettings() { + return updateInstanceOperationSettings; + } + /** Returns the builder for the settings used for calls to listInstanceConfigs. */ public PagedCallSettings.Builder< ListInstanceConfigsRequest, @@ -696,32 +760,6 @@ public UnaryCallSettings.Builder getInstanceSettin return getInstanceSettings; } - /** Returns the builder for the settings used for calls to createInstance. */ - public UnaryCallSettings.Builder createInstanceSettings() { - return createInstanceSettings; - } - - /** Returns the builder for the settings used for calls to createInstance. */ - @BetaApi( - "The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings.Builder - createInstanceOperationSettings() { - return createInstanceOperationSettings; - } - - /** Returns the builder for the settings used for calls to updateInstance. */ - public UnaryCallSettings.Builder updateInstanceSettings() { - return updateInstanceSettings; - } - - /** Returns the builder for the settings used for calls to updateInstance. */ - @BetaApi( - "The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings.Builder - updateInstanceOperationSettings() { - return updateInstanceOperationSettings; - } - /** Returns the builder for the settings used for calls to deleteInstance. */ public UnaryCallSettings.Builder deleteInstanceSettings() { return deleteInstanceSettings; diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java index f99372d498..e288143469 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java @@ -386,12 +386,17 @@ public static class Builder extends StubSettings.Builder> definitions = ImmutableMap.builder(); definitions.put( - "idempotent", + "retry_policy_1_codes", ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.UNAVAILABLE))); - definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); definitions.put( - "long_running", + "retry_policy_3_codes", ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.UNAVAILABLE))); + definitions.put( + "retry_policy_2_codes", + ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.UNAVAILABLE))); + definitions.put( + "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -410,29 +415,39 @@ public static class Builder extends StubSettings.Builder> callsWithDefaultSettings = + List> callsWithRetry1 = + Arrays.asList(stubSettings.listSessionsSettings(), stubSettings.commitSettings()); + List> callsWithRetry2 = + Arrays.asList(stubSettings.batchCreateSessionsSettings()); + List> callsWithRetry3 = Arrays.asList( - stubSettings.beginTransactionSettings(), stubSettings.createSessionSettings(), + stubSettings.getSessionSettings(), stubSettings.deleteSessionSettings(), - stubSettings.executeBatchDmlSettings(), stubSettings.executeSqlSettings(), - stubSettings.getSessionSettings(), - stubSettings.listSessionsSettings(), - stubSettings.partitionQuerySettings(), - stubSettings.partitionReadSettings(), + stubSettings.executeBatchDmlSettings(), stubSettings.readSettings(), - stubSettings.rollbackSettings()); - List> callsWithStreamingSettings = + stubSettings.beginTransactionSettings(), + stubSettings.rollbackSettings(), + stubSettings.partitionQuerySettings(), + stubSettings.partitionReadSettings()); + List> callsWithNoRetry1 = Arrays.asList( stubSettings.executeStreamingSqlSettings(), stubSettings.streamingReadSettings()); - List> callsWithLongRunningSettings = - Arrays.asList(stubSettings.commitSettings()); - for (UnaryCallSettings callSettings : callsWithDefaultSettings) { - assertThat(callSettings.getRetrySettings()).isEqualTo(defaultRetrySettings); + for (UnaryCallSettings callSettings : callsWithRetry1) { + assertThat(callSettings.getRetrySettings()).isEqualTo(witRetryPolicy1); } - for (ServerStreamingCallSettings callSettings : callsWithStreamingSettings) { - assertThat(callSettings.getRetrySettings()).isEqualTo(streamingRetrySettings); + for (UnaryCallSettings callSettings : callsWithRetry2) { + assertThat(callSettings.getRetrySettings()).isEqualTo(witRetryPolicy2); } - for (UnaryCallSettings callSettings : callsWithLongRunningSettings) { - assertThat(callSettings.getRetrySettings()).isEqualTo(longRunningRetrySettings); + for (UnaryCallSettings callSettings : callsWithRetry3) { + assertThat(callSettings.getRetrySettings()).isEqualTo(witRetryPolicy3); + } + for (ServerStreamingCallSettings callSettings : callsWithNoRetry1) { + assertThat(callSettings.getRetrySettings()).isEqualTo(noRetry1); } } @@ -213,26 +224,54 @@ public void testSpannerCustomRetrySettings() { @Test public void testDatabaseAdminDefaultRetrySettings() { - RetrySettings defaultRetrySettings = + RetrySettings withRetryPolicy1 = RetrySettings.newBuilder() .setInitialRetryDelay(Duration.ofMillis(1000L)) .setRetryDelayMultiplier(1.3) .setMaxRetryDelay(Duration.ofMillis(32000L)) - .setInitialRpcTimeout(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(3600000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(60000L)) - .setTotalTimeout(Duration.ofMillis(600000L)) + .setMaxRpcTimeout(Duration.ofMillis(3600000L)) + .setTotalTimeout(Duration.ofMillis(3600000L)) + .build(); + RetrySettings withRetryPolicy2 = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(1000L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(32000L)) + .setInitialRpcTimeout(Duration.ofMillis(30000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(30000L)) + .setTotalTimeout(Duration.ofMillis(30000L)) + .build(); + RetrySettings noRetryPolicy2 = + RetrySettings.newBuilder() + .setInitialRpcTimeout(Duration.ofMillis(30000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(30000L)) + .setTotalTimeout(Duration.ofMillis(30000L)) .build(); SpannerOptions options = SpannerOptions.newBuilder().setProjectId("test-project").build(); DatabaseAdminStubSettings stubSettings = options.getDatabaseAdminStubSettings(); - List> callsWithDefaultSettings = + List> callsWithRetryPolicy1 = Arrays.asList( stubSettings.dropDatabaseSettings(), - stubSettings.getDatabaseDdlSettings(), - stubSettings.getDatabaseSettings()); + stubSettings.getDatabaseSettings(), + stubSettings.getDatabaseDdlSettings()); + List> callsWithRetryPolicy2 = + Arrays.asList(stubSettings.getIamPolicySettings()); + List> callsWithNoRetry2 = + Arrays.asList( + stubSettings.setIamPolicySettings(), stubSettings.testIamPermissionsSettings()); - for (UnaryCallSettings callSettings : callsWithDefaultSettings) { - assertThat(callSettings.getRetrySettings()).isEqualTo(defaultRetrySettings); + for (UnaryCallSettings callSettings : callsWithRetryPolicy1) { + assertThat(callSettings.getRetrySettings()).isEqualTo(withRetryPolicy1); + } + for (UnaryCallSettings callSettings : callsWithRetryPolicy2) { + assertThat(callSettings.getRetrySettings()).isEqualTo(withRetryPolicy2); + } + for (UnaryCallSettings callSettings : callsWithNoRetry2) { + assertThat(callSettings.getRetrySettings()).isEqualTo(noRetryPolicy2); } } @@ -275,28 +314,68 @@ public void testDatabaseAdminCustomRetrySettings() { @Test public void testInstanceAdminDefaultRetrySettings() { - RetrySettings defaultRetrySettings = + RetrySettings withRetryPolicy1 = RetrySettings.newBuilder() .setInitialRetryDelay(Duration.ofMillis(1000L)) .setRetryDelayMultiplier(1.3) .setMaxRetryDelay(Duration.ofMillis(32000L)) - .setInitialRpcTimeout(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(3600000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(60000L)) - .setTotalTimeout(Duration.ofMillis(600000L)) + .setMaxRpcTimeout(Duration.ofMillis(3600000L)) + .setTotalTimeout(Duration.ofMillis(3600000L)) + .build(); + RetrySettings withRetryPolicy2 = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(1000L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(32000L)) + .setInitialRpcTimeout(Duration.ofMillis(30000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(30000L)) + .setTotalTimeout(Duration.ofMillis(30000L)) + .build(); + RetrySettings noRetryPolicy1 = + RetrySettings.newBuilder() + .setInitialRpcTimeout(Duration.ofMillis(3600000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(3600000L)) + .setTotalTimeout(Duration.ofMillis(3600000L)) + .build(); + RetrySettings noRetryPolicy2 = + RetrySettings.newBuilder() + .setInitialRpcTimeout(Duration.ofMillis(30000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(30000L)) + .setTotalTimeout(Duration.ofMillis(30000L)) .build(); SpannerOptions options = SpannerOptions.newBuilder().setProjectId("test-project").build(); InstanceAdminStubSettings stubSettings = options.getInstanceAdminStubSettings(); - List> callsWithDefaultSettings = + List> callsWithRetryPolicy1 = Arrays.asList( stubSettings.getInstanceConfigSettings(), stubSettings.listInstanceConfigsSettings(), stubSettings.deleteInstanceSettings(), stubSettings.getInstanceSettings(), stubSettings.listInstancesSettings()); + List> callsWithRetryPolicy2 = + Arrays.asList(stubSettings.getIamPolicySettings()); + List> callsWithNoRetryPolicy1 = + Arrays.asList(stubSettings.createInstanceSettings(), stubSettings.updateInstanceSettings()); + List> callsWithNoRetryPolicy2 = + Arrays.asList( + stubSettings.setIamPolicySettings(), stubSettings.testIamPermissionsSettings()); - for (UnaryCallSettings callSettings : callsWithDefaultSettings) { - assertThat(callSettings.getRetrySettings()).isEqualTo(defaultRetrySettings); + for (UnaryCallSettings callSettings : callsWithRetryPolicy1) { + assertThat(callSettings.getRetrySettings()).isEqualTo(withRetryPolicy1); + } + for (UnaryCallSettings callSettings : callsWithRetryPolicy2) { + assertThat(callSettings.getRetrySettings()).isEqualTo(withRetryPolicy2); + } + for (UnaryCallSettings callSettings : callsWithNoRetryPolicy1) { + assertThat(callSettings.getRetrySettings()).isEqualTo(noRetryPolicy1); + } + for (UnaryCallSettings callSettings : callsWithNoRetryPolicy2) { + assertThat(callSettings.getRetrySettings()).isEqualTo(noRetryPolicy2); } } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClientTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClientTest.java index 78efb14466..e304a4ef50 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClientTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClientTest.java @@ -121,30 +121,29 @@ public void tearDown() throws Exception { @Test @SuppressWarnings("all") - public void listDatabasesTest() { - String nextPageToken = ""; - Database databasesElement = Database.newBuilder().build(); - List databases = Arrays.asList(databasesElement); - ListDatabasesResponse expectedResponse = - ListDatabasesResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllDatabases(databases) + public void createDatabaseTest() throws Exception { + DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + Database expectedResponse = Database.newBuilder().setName(name.toString()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) .build(); - mockDatabaseAdmin.addResponse(expectedResponse); + mockDatabaseAdmin.addResponse(resultOperation); InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + String createStatement = "createStatement552974828"; - ListDatabasesPagedResponse pagedListResponse = client.listDatabases(parent); - - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getDatabasesList().get(0), resources.get(0)); + Database actualResponse = client.createDatabaseAsync(parent, createStatement).get(); + Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockDatabaseAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ListDatabasesRequest actualRequest = (ListDatabasesRequest) actualRequests.get(0); + CreateDatabaseRequest actualRequest = (CreateDatabaseRequest) actualRequests.get(0); Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); + Assert.assertEquals(createStatement, actualRequest.getCreateStatement()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -153,45 +152,47 @@ public void listDatabasesTest() { @Test @SuppressWarnings("all") - public void listDatabasesExceptionTest() throws Exception { + public void createDatabaseExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockDatabaseAdmin.addException(exception); try { InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + String createStatement = "createStatement552974828"; - client.listDatabases(parent); + client.createDatabaseAsync(parent, createStatement).get(); Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test @SuppressWarnings("all") - public void createDatabaseTest() throws Exception { - DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); - Database expectedResponse = Database.newBuilder().setName(name.toString()).build(); + public void updateDatabaseDdlTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); Operation resultOperation = Operation.newBuilder() - .setName("createDatabaseTest") + .setName("updateDatabaseDdlTest") .setDone(true) .setResponse(Any.pack(expectedResponse)) .build(); mockDatabaseAdmin.addResponse(resultOperation); - InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); - String createStatement = "createStatement552974828"; + DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + List statements = new ArrayList<>(); - Database actualResponse = client.createDatabaseAsync(parent, createStatement).get(); + Empty actualResponse = client.updateDatabaseDdlAsync(database, statements).get(); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockDatabaseAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - CreateDatabaseRequest actualRequest = (CreateDatabaseRequest) actualRequests.get(0); + UpdateDatabaseDdlRequest actualRequest = (UpdateDatabaseDdlRequest) actualRequests.get(0); - Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); - Assert.assertEquals(createStatement, actualRequest.getCreateStatement()); + Assert.assertEquals(database, DatabaseName.parse(actualRequest.getDatabase())); + Assert.assertEquals(statements, actualRequest.getStatementsList()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -200,15 +201,15 @@ public void createDatabaseTest() throws Exception { @Test @SuppressWarnings("all") - public void createDatabaseExceptionTest() throws Exception { + public void updateDatabaseDdlExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockDatabaseAdmin.addException(exception); try { - InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); - String createStatement = "createStatement552974828"; + DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + List statements = new ArrayList<>(); - client.createDatabaseAsync(parent, createStatement).get(); + client.updateDatabaseDdlAsync(database, statements).get(); Assert.fail("No exception raised"); } catch (ExecutionException e) { Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); @@ -219,21 +220,38 @@ public void createDatabaseExceptionTest() throws Exception { @Test @SuppressWarnings("all") - public void getDatabaseTest() { - DatabaseName name2 = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); - Database expectedResponse = Database.newBuilder().setName(name2.toString()).build(); - mockDatabaseAdmin.addResponse(expectedResponse); + public void createBackupTest() throws Exception { + DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + BackupName name = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]"); + long sizeBytes = 1796325715L; + Backup expectedResponse = + Backup.newBuilder() + .setDatabase(database.toString()) + .setName(name.toString()) + .setSizeBytes(sizeBytes) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockDatabaseAdmin.addResponse(resultOperation); - DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + Backup backup = Backup.newBuilder().build(); + String backupId = "backupId1355353272"; - Database actualResponse = client.getDatabase(name); + Backup actualResponse = client.createBackupAsync(parent, backup, backupId).get(); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockDatabaseAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetDatabaseRequest actualRequest = (GetDatabaseRequest) actualRequests.get(0); + CreateBackupRequest actualRequest = (CreateBackupRequest) actualRequests.get(0); - Assert.assertEquals(name, DatabaseName.parse(actualRequest.getName())); + Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); + Assert.assertEquals(backup, actualRequest.getBackup()); + Assert.assertEquals(backupId, actualRequest.getBackupId()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -242,44 +260,51 @@ public void getDatabaseTest() { @Test @SuppressWarnings("all") - public void getDatabaseExceptionTest() throws Exception { + public void createBackupExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockDatabaseAdmin.addException(exception); try { - DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + Backup backup = Backup.newBuilder().build(); + String backupId = "backupId1355353272"; - client.getDatabase(name); + client.createBackupAsync(parent, backup, backupId).get(); Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test @SuppressWarnings("all") - public void updateDatabaseDdlTest() throws Exception { - Empty expectedResponse = Empty.newBuilder().build(); + public void restoreDatabaseTest() throws Exception { + DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + Database expectedResponse = Database.newBuilder().setName(name.toString()).build(); Operation resultOperation = Operation.newBuilder() - .setName("updateDatabaseDdlTest") + .setName("restoreDatabaseTest") .setDone(true) .setResponse(Any.pack(expectedResponse)) .build(); mockDatabaseAdmin.addResponse(resultOperation); - DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); - List statements = new ArrayList<>(); + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + String databaseId = "databaseId816491103"; + BackupName backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]"); - Empty actualResponse = client.updateDatabaseDdlAsync(database, statements).get(); + Database actualResponse = client.restoreDatabaseAsync(parent, databaseId, backup).get(); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockDatabaseAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - UpdateDatabaseDdlRequest actualRequest = (UpdateDatabaseDdlRequest) actualRequests.get(0); + RestoreDatabaseRequest actualRequest = (RestoreDatabaseRequest) actualRequests.get(0); - Assert.assertEquals(database, DatabaseName.parse(actualRequest.getDatabase())); - Assert.assertEquals(statements, actualRequest.getStatementsList()); + Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); + Assert.assertEquals(databaseId, actualRequest.getDatabaseId()); + Assert.assertEquals(backup, BackupName.parse(actualRequest.getBackup())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -288,15 +313,16 @@ public void updateDatabaseDdlTest() throws Exception { @Test @SuppressWarnings("all") - public void updateDatabaseDdlExceptionTest() throws Exception { + public void restoreDatabaseExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockDatabaseAdmin.addException(exception); try { - DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); - List statements = new ArrayList<>(); + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + String databaseId = "databaseId816491103"; + BackupName backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]"); - client.updateDatabaseDdlAsync(database, statements).get(); + client.restoreDatabaseAsync(parent, databaseId, backup).get(); Assert.fail("No exception raised"); } catch (ExecutionException e) { Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); @@ -305,6 +331,93 @@ public void updateDatabaseDdlExceptionTest() throws Exception { } } + @Test + @SuppressWarnings("all") + public void listDatabasesTest() { + String nextPageToken = ""; + Database databasesElement = Database.newBuilder().build(); + List databases = Arrays.asList(databasesElement); + ListDatabasesResponse expectedResponse = + ListDatabasesResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllDatabases(databases) + .build(); + mockDatabaseAdmin.addResponse(expectedResponse); + + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + + ListDatabasesPagedResponse pagedListResponse = client.listDatabases(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDatabasesList().get(0), resources.get(0)); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListDatabasesRequest actualRequest = (ListDatabasesRequest) actualRequests.get(0); + + Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void listDatabasesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + + client.listDatabases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getDatabaseTest() { + DatabaseName name2 = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + Database expectedResponse = Database.newBuilder().setName(name2.toString()).build(); + mockDatabaseAdmin.addResponse(expectedResponse); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + + Database actualResponse = client.getDatabase(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetDatabaseRequest actualRequest = (GetDatabaseRequest) actualRequests.get(0); + + Assert.assertEquals(name, DatabaseName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void getDatabaseExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + + client.getDatabase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + @Test @SuppressWarnings("all") public void dropDatabaseTest() { @@ -504,66 +617,6 @@ public void testIamPermissionsExceptionTest() throws Exception { } } - @Test - @SuppressWarnings("all") - public void createBackupTest() throws Exception { - DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); - BackupName name = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]"); - long sizeBytes = 1796325715L; - Backup expectedResponse = - Backup.newBuilder() - .setDatabase(database.toString()) - .setName(name.toString()) - .setSizeBytes(sizeBytes) - .build(); - Operation resultOperation = - Operation.newBuilder() - .setName("createBackupTest") - .setDone(true) - .setResponse(Any.pack(expectedResponse)) - .build(); - mockDatabaseAdmin.addResponse(resultOperation); - - InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); - Backup backup = Backup.newBuilder().build(); - String backupId = "backupId1355353272"; - - Backup actualResponse = client.createBackupAsync(parent, backup, backupId).get(); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDatabaseAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateBackupRequest actualRequest = (CreateBackupRequest) actualRequests.get(0); - - Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); - Assert.assertEquals(backup, actualRequest.getBackup()); - Assert.assertEquals(backupId, actualRequest.getBackupId()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void createBackupExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockDatabaseAdmin.addException(exception); - - try { - InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); - Backup backup = Backup.newBuilder().build(); - String backupId = "backupId1355353272"; - - client.createBackupAsync(parent, backup, backupId).get(); - Assert.fail("No exception raised"); - } catch (ExecutionException e) { - Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); - Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); - } - } - @Test @SuppressWarnings("all") public void getBackupTest() { @@ -744,59 +797,6 @@ public void listBackupsExceptionTest() throws Exception { } } - @Test - @SuppressWarnings("all") - public void restoreDatabaseTest() throws Exception { - DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); - Database expectedResponse = Database.newBuilder().setName(name.toString()).build(); - Operation resultOperation = - Operation.newBuilder() - .setName("restoreDatabaseTest") - .setDone(true) - .setResponse(Any.pack(expectedResponse)) - .build(); - mockDatabaseAdmin.addResponse(resultOperation); - - InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); - String databaseId = "databaseId816491103"; - BackupName backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]"); - - Database actualResponse = client.restoreDatabaseAsync(parent, databaseId, backup).get(); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDatabaseAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - RestoreDatabaseRequest actualRequest = (RestoreDatabaseRequest) actualRequests.get(0); - - Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); - Assert.assertEquals(databaseId, actualRequest.getDatabaseId()); - Assert.assertEquals(backup, BackupName.parse(actualRequest.getBackup())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void restoreDatabaseExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockDatabaseAdmin.addException(exception); - - try { - InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); - String databaseId = "databaseId816491103"; - BackupName backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]"); - - client.restoreDatabaseAsync(parent, databaseId, backup).get(); - Assert.fail("No exception raised"); - } catch (ExecutionException e) { - Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); - Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); - } - } - @Test @SuppressWarnings("all") public void listDatabaseOperationsTest() { diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminClientTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminClientTest.java index 406171d3aa..889de79200 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminClientTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminClientTest.java @@ -109,30 +109,40 @@ public void tearDown() throws Exception { @Test @SuppressWarnings("all") - public void listInstanceConfigsTest() { - String nextPageToken = ""; - InstanceConfig instanceConfigsElement = InstanceConfig.newBuilder().build(); - List instanceConfigs = Arrays.asList(instanceConfigsElement); - ListInstanceConfigsResponse expectedResponse = - ListInstanceConfigsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllInstanceConfigs(instanceConfigs) + public void createInstanceTest() throws Exception { + InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]"); + InstanceConfigName config = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]"); + String displayName = "displayName1615086568"; + int nodeCount = 1539922066; + Instance expectedResponse = + Instance.newBuilder() + .setName(name.toString()) + .setConfig(config.toString()) + .setDisplayName(displayName) + .setNodeCount(nodeCount) .build(); - mockInstanceAdmin.addResponse(expectedResponse); + Operation resultOperation = + Operation.newBuilder() + .setName("createInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockInstanceAdmin.addResponse(resultOperation); ProjectName parent = ProjectName.of("[PROJECT]"); + String instanceId = "instanceId-2101995259"; + Instance instance = Instance.newBuilder().build(); - ListInstanceConfigsPagedResponse pagedListResponse = client.listInstanceConfigs(parent); - - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getInstanceConfigsList().get(0), resources.get(0)); + Instance actualResponse = client.createInstanceAsync(parent, instanceId, instance).get(); + Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockInstanceAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ListInstanceConfigsRequest actualRequest = (ListInstanceConfigsRequest) actualRequests.get(0); + CreateInstanceRequest actualRequest = (CreateInstanceRequest) actualRequests.get(0); Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent())); + Assert.assertEquals(instanceId, actualRequest.getInstanceId()); + Assert.assertEquals(instance, actualRequest.getInstance()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -141,39 +151,58 @@ public void listInstanceConfigsTest() { @Test @SuppressWarnings("all") - public void listInstanceConfigsExceptionTest() throws Exception { + public void createInstanceExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockInstanceAdmin.addException(exception); try { ProjectName parent = ProjectName.of("[PROJECT]"); + String instanceId = "instanceId-2101995259"; + Instance instance = Instance.newBuilder().build(); - client.listInstanceConfigs(parent); + client.createInstanceAsync(parent, instanceId, instance).get(); Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test @SuppressWarnings("all") - public void getInstanceConfigTest() { - InstanceConfigName name2 = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]"); + public void updateInstanceTest() throws Exception { + InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]"); + InstanceConfigName config = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]"); String displayName = "displayName1615086568"; - InstanceConfig expectedResponse = - InstanceConfig.newBuilder().setName(name2.toString()).setDisplayName(displayName).build(); - mockInstanceAdmin.addResponse(expectedResponse); + int nodeCount = 1539922066; + Instance expectedResponse = + Instance.newBuilder() + .setName(name.toString()) + .setConfig(config.toString()) + .setDisplayName(displayName) + .setNodeCount(nodeCount) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockInstanceAdmin.addResponse(resultOperation); - InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]"); + Instance instance = Instance.newBuilder().build(); + FieldMask fieldMask = FieldMask.newBuilder().build(); - InstanceConfig actualResponse = client.getInstanceConfig(name); + Instance actualResponse = client.updateInstanceAsync(instance, fieldMask).get(); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockInstanceAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetInstanceConfigRequest actualRequest = (GetInstanceConfigRequest) actualRequests.get(0); + UpdateInstanceRequest actualRequest = (UpdateInstanceRequest) actualRequests.get(0); - Assert.assertEquals(name, InstanceConfigName.parse(actualRequest.getName())); + Assert.assertEquals(instance, actualRequest.getInstance()); + Assert.assertEquals(fieldMask, actualRequest.getFieldMask()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -182,44 +211,47 @@ public void getInstanceConfigTest() { @Test @SuppressWarnings("all") - public void getInstanceConfigExceptionTest() throws Exception { + public void updateInstanceExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockInstanceAdmin.addException(exception); try { - InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]"); + Instance instance = Instance.newBuilder().build(); + FieldMask fieldMask = FieldMask.newBuilder().build(); - client.getInstanceConfig(name); + client.updateInstanceAsync(instance, fieldMask).get(); Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test @SuppressWarnings("all") - public void listInstancesTest() { + public void listInstanceConfigsTest() { String nextPageToken = ""; - Instance instancesElement = Instance.newBuilder().build(); - List instances = Arrays.asList(instancesElement); - ListInstancesResponse expectedResponse = - ListInstancesResponse.newBuilder() + InstanceConfig instanceConfigsElement = InstanceConfig.newBuilder().build(); + List instanceConfigs = Arrays.asList(instanceConfigsElement); + ListInstanceConfigsResponse expectedResponse = + ListInstanceConfigsResponse.newBuilder() .setNextPageToken(nextPageToken) - .addAllInstances(instances) + .addAllInstanceConfigs(instanceConfigs) .build(); mockInstanceAdmin.addResponse(expectedResponse); ProjectName parent = ProjectName.of("[PROJECT]"); - ListInstancesPagedResponse pagedListResponse = client.listInstances(parent); + ListInstanceConfigsPagedResponse pagedListResponse = client.listInstanceConfigs(parent); - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getInstancesList().get(0), resources.get(0)); + Assert.assertEquals(expectedResponse.getInstanceConfigsList().get(0), resources.get(0)); List actualRequests = mockInstanceAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ListInstancesRequest actualRequest = (ListInstancesRequest) actualRequests.get(0); + ListInstanceConfigsRequest actualRequest = (ListInstanceConfigsRequest) actualRequests.get(0); Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent())); Assert.assertTrue( @@ -230,14 +262,14 @@ public void listInstancesTest() { @Test @SuppressWarnings("all") - public void listInstancesExceptionTest() throws Exception { + public void listInstanceConfigsExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockInstanceAdmin.addException(exception); try { ProjectName parent = ProjectName.of("[PROJECT]"); - client.listInstances(parent); + client.listInstanceConfigs(parent); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception @@ -246,30 +278,23 @@ public void listInstancesExceptionTest() throws Exception { @Test @SuppressWarnings("all") - public void getInstanceTest() { - InstanceName name2 = InstanceName.of("[PROJECT]", "[INSTANCE]"); - InstanceConfigName config = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]"); + public void getInstanceConfigTest() { + InstanceConfigName name2 = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]"); String displayName = "displayName1615086568"; - int nodeCount = 1539922066; - Instance expectedResponse = - Instance.newBuilder() - .setName(name2.toString()) - .setConfig(config.toString()) - .setDisplayName(displayName) - .setNodeCount(nodeCount) - .build(); + InstanceConfig expectedResponse = + InstanceConfig.newBuilder().setName(name2.toString()).setDisplayName(displayName).build(); mockInstanceAdmin.addResponse(expectedResponse); - InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]"); + InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]"); - Instance actualResponse = client.getInstance(name); + InstanceConfig actualResponse = client.getInstanceConfig(name); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockInstanceAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetInstanceRequest actualRequest = (GetInstanceRequest) actualRequests.get(0); + GetInstanceConfigRequest actualRequest = (GetInstanceConfigRequest) actualRequests.get(0); - Assert.assertEquals(name, InstanceName.parse(actualRequest.getName())); + Assert.assertEquals(name, InstanceConfigName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -278,14 +303,14 @@ public void getInstanceTest() { @Test @SuppressWarnings("all") - public void getInstanceExceptionTest() throws Exception { + public void getInstanceConfigExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockInstanceAdmin.addException(exception); try { - InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]"); + InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]"); - client.getInstance(name); + client.getInstanceConfig(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception @@ -294,40 +319,30 @@ public void getInstanceExceptionTest() throws Exception { @Test @SuppressWarnings("all") - public void createInstanceTest() throws Exception { - InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]"); - InstanceConfigName config = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]"); - String displayName = "displayName1615086568"; - int nodeCount = 1539922066; - Instance expectedResponse = - Instance.newBuilder() - .setName(name.toString()) - .setConfig(config.toString()) - .setDisplayName(displayName) - .setNodeCount(nodeCount) - .build(); - Operation resultOperation = - Operation.newBuilder() - .setName("createInstanceTest") - .setDone(true) - .setResponse(Any.pack(expectedResponse)) + public void listInstancesTest() { + String nextPageToken = ""; + Instance instancesElement = Instance.newBuilder().build(); + List instances = Arrays.asList(instancesElement); + ListInstancesResponse expectedResponse = + ListInstancesResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllInstances(instances) .build(); - mockInstanceAdmin.addResponse(resultOperation); + mockInstanceAdmin.addResponse(expectedResponse); ProjectName parent = ProjectName.of("[PROJECT]"); - String instanceId = "instanceId-2101995259"; - Instance instance = Instance.newBuilder().build(); - Instance actualResponse = client.createInstanceAsync(parent, instanceId, instance).get(); - Assert.assertEquals(expectedResponse, actualResponse); + ListInstancesPagedResponse pagedListResponse = client.listInstances(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInstancesList().get(0), resources.get(0)); List actualRequests = mockInstanceAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - CreateInstanceRequest actualRequest = (CreateInstanceRequest) actualRequests.get(0); + ListInstancesRequest actualRequest = (ListInstancesRequest) actualRequests.get(0); Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent())); - Assert.assertEquals(instanceId, actualRequest.getInstanceId()); - Assert.assertEquals(instance, actualRequest.getInstance()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -336,58 +351,46 @@ public void createInstanceTest() throws Exception { @Test @SuppressWarnings("all") - public void createInstanceExceptionTest() throws Exception { + public void listInstancesExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockInstanceAdmin.addException(exception); try { ProjectName parent = ProjectName.of("[PROJECT]"); - String instanceId = "instanceId-2101995259"; - Instance instance = Instance.newBuilder().build(); - client.createInstanceAsync(parent, instanceId, instance).get(); + client.listInstances(parent); Assert.fail("No exception raised"); - } catch (ExecutionException e) { - Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); - Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } catch (InvalidArgumentException e) { + // Expected exception } } @Test @SuppressWarnings("all") - public void updateInstanceTest() throws Exception { - InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]"); + public void getInstanceTest() { + InstanceName name2 = InstanceName.of("[PROJECT]", "[INSTANCE]"); InstanceConfigName config = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]"); String displayName = "displayName1615086568"; int nodeCount = 1539922066; Instance expectedResponse = Instance.newBuilder() - .setName(name.toString()) + .setName(name2.toString()) .setConfig(config.toString()) .setDisplayName(displayName) .setNodeCount(nodeCount) .build(); - Operation resultOperation = - Operation.newBuilder() - .setName("updateInstanceTest") - .setDone(true) - .setResponse(Any.pack(expectedResponse)) - .build(); - mockInstanceAdmin.addResponse(resultOperation); + mockInstanceAdmin.addResponse(expectedResponse); - Instance instance = Instance.newBuilder().build(); - FieldMask fieldMask = FieldMask.newBuilder().build(); + InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]"); - Instance actualResponse = client.updateInstanceAsync(instance, fieldMask).get(); + Instance actualResponse = client.getInstance(name); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockInstanceAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - UpdateInstanceRequest actualRequest = (UpdateInstanceRequest) actualRequests.get(0); + GetInstanceRequest actualRequest = (GetInstanceRequest) actualRequests.get(0); - Assert.assertEquals(instance, actualRequest.getInstance()); - Assert.assertEquals(fieldMask, actualRequest.getFieldMask()); + Assert.assertEquals(name, InstanceName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -396,20 +399,17 @@ public void updateInstanceTest() throws Exception { @Test @SuppressWarnings("all") - public void updateInstanceExceptionTest() throws Exception { + public void getInstanceExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockInstanceAdmin.addException(exception); try { - Instance instance = Instance.newBuilder().build(); - FieldMask fieldMask = FieldMask.newBuilder().build(); + InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]"); - client.updateInstanceAsync(instance, fieldMask).get(); + client.getInstance(name); Assert.fail("No exception raised"); - } catch (ExecutionException e) { - Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); - Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } catch (InvalidArgumentException e) { + // Expected exception } } diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupProto.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupProto.java index 330156f140..2aaecf7bcd 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupProto.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupProto.java @@ -130,12 +130,14 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + ".Operation\022\027\n\017next_page_token\030\002 \001(\t\"f\n\nB" + "ackupInfo\022\016\n\006backup\030\001 \001(\t\022/\n\013create_time" + "\030\002 \001(\0132\032.google.protobuf.Timestamp\022\027\n\017so" - + "urce_database\030\003 \001(\tB\321\001\n$com.google.spann" + + "urce_database\030\003 \001(\tB\377\001\n$com.google.spann" + "er.admin.database.v1B\013BackupProtoP\001ZHgoo" + "gle.golang.org/genproto/googleapis/spann" + "er/admin/database/v1;database\252\002&Google.C" + "loud.Spanner.Admin.Database.V1\312\002&Google\\" - + "Cloud\\Spanner\\Admin\\Database\\V1b\006proto3" + + "Cloud\\Spanner\\Admin\\Database\\V1\352\002+Google" + + "::Cloud::Spanner::Admin::Database::V1b\006p" + + "roto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CommonProto.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CommonProto.java index 0ea75df21d..657d73efc9 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CommonProto.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CommonProto.java @@ -48,12 +48,13 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "\030\n\020progress_percent\030\001 \001(\005\022.\n\nstart_time\030" + "\002 \001(\0132\032.google.protobuf.Timestamp\022,\n\010end" + "_time\030\003 \001(\0132\032.google.protobuf.TimestampB" - + "\321\001\n$com.google.spanner.admin.database.v1" + + "\377\001\n$com.google.spanner.admin.database.v1" + "B\013CommonProtoP\001ZHgoogle.golang.org/genpr" + "oto/googleapis/spanner/admin/database/v1" + ";database\252\002&Google.Cloud.Spanner.Admin.D" + "atabase.V1\312\002&Google\\Cloud\\Spanner\\Admin\\" - + "Database\\V1b\006proto3" + + "Database\\V1\352\002+Google::Cloud::Spanner::Ad" + + "min::Database::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/SpannerDatabaseAdminProto.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/SpannerDatabaseAdminProto.java index 910a1a9c13..9af8119d2c 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/SpannerDatabaseAdminProto.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/SpannerDatabaseAdminProto.java @@ -180,7 +180,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "a\022\014\n\004name\030\001 \001(\t\022E\n\010progress\030\002 \001(\01323.goog" + "le.spanner.admin.database.v1.OperationPr" + "ogress*5\n\021RestoreSourceType\022\024\n\020TYPE_UNSP" - + "ECIFIED\020\000\022\n\n\006BACKUP\020\0012\362\036\n\rDatabaseAdmin\022" + + "ECIFIED\020\000\022\n\n\006BACKUP\020\0012\223\037\n\rDatabaseAdmin\022" + "\300\001\n\rListDatabases\0226.google.spanner.admin" + ".database.v1.ListDatabasesRequest\0327.goog" + "le.spanner.admin.database.v1.ListDatabas" @@ -233,61 +233,63 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "es/*}:testIamPermissions:\001*ZG\"B/v1/{reso" + "urce=projects/*/instances/*/backups/*}:t" + "estIamPermissions:\001*\332A\024resource,permissi" - + "ons\022\376\001\n\014CreateBackup\0225.google.spanner.ad" + + "ons\022\237\002\n\014CreateBackup\0225.google.spanner.ad" + "min.database.v1.CreateBackupRequest\032\035.go" - + "ogle.longrunning.Operation\"\227\001\202\323\344\223\0025\"+/v1" + + "ogle.longrunning.Operation\"\270\001\202\323\344\223\0025\"+/v1" + "/{parent=projects/*/instances/*}/backups" - + ":\006backup\332A\027parent,backup,backup_id\312A?\n\006B" - + "ackup\0225google.spanner.admin.database.v1." - + "CreateBackupMetadata\022\245\001\n\tGetBackup\0222.goo" - + "gle.spanner.admin.database.v1.GetBackupR" - + "equest\032(.google.spanner.admin.database.v" - + "1.Backup\":\202\323\344\223\002-\022+/v1/{name=projects/*/i" - + "nstances/*/backups/*}\332A\004name\022\310\001\n\014UpdateB" - + "ackup\0225.google.spanner.admin.database.v1" - + ".UpdateBackupRequest\032(.google.spanner.ad" - + "min.database.v1.Backup\"W\202\323\344\223\002<22/v1/{bac" - + "kup.name=projects/*/instances/*/backups/" - + "*}:\006backup\332A\022backup,update_mask\022\231\001\n\014Dele" - + "teBackup\0225.google.spanner.admin.database" - + ".v1.DeleteBackupRequest\032\026.google.protobu" - + "f.Empty\":\202\323\344\223\002-*+/v1/{name=projects/*/in" - + "stances/*/backups/*}\332A\004name\022\270\001\n\013ListBack" - + "ups\0224.google.spanner.admin.database.v1.L" - + "istBackupsRequest\0325.google.spanner.admin" - + ".database.v1.ListBackupsResponse\"<\202\323\344\223\002-" - + "\022+/v1/{parent=projects/*/instances/*}/ba" - + "ckups\332A\006parent\022\261\002\n\017RestoreDatabase\0228.goo" - + "gle.spanner.admin.database.v1.RestoreDat" - + "abaseRequest\032\035.google.longrunning.Operat" - + "ion\"\304\001\202\323\344\223\002:\"5/v1/{parent=projects/*/ins" - + "tances/*}/databases:restore:\001*\332A\031parent," - + "database_id,backup\312Ae\n)google.spanner.ad" - + "min.database.v1.Database\0228google.spanner" - + ".admin.database.v1.RestoreDatabaseMetada" - + "ta\022\344\001\n\026ListDatabaseOperations\022?.google.s" - + "panner.admin.database.v1.ListDatabaseOpe" - + "rationsRequest\032@.google.spanner.admin.da" - + "tabase.v1.ListDatabaseOperationsResponse" - + "\"G\202\323\344\223\0028\0226/v1/{parent=projects/*/instanc" - + "es/*}/databaseOperations\332A\006parent\022\334\001\n\024Li" - + "stBackupOperations\022=.google.spanner.admi" - + "n.database.v1.ListBackupOperationsReques" - + "t\032>.google.spanner.admin.database.v1.Lis" - + "tBackupOperationsResponse\"E\202\323\344\223\0026\0224/v1/{" - + "parent=projects/*/instances/*}/backupOpe" - + "rations\332A\006parent\032x\312A\026spanner.googleapis." - + "com\322A\\https://www.googleapis.com/auth/cl" - + "oud-platform,https://www.googleapis.com/" - + "auth/spanner.adminB\254\002\n$com.google.spanne" - + "r.admin.database.v1B\031SpannerDatabaseAdmi" - + "nProtoP\001ZHgoogle.golang.org/genproto/goo" - + "gleapis/spanner/admin/database/v1;databa" - + "se\252\002&Google.Cloud.Spanner.Admin.Database" - + ".V1\312\002&Google\\Cloud\\Spanner\\Admin\\Databas" - + "e\\V1\352AJ\n\037spanner.googleapis.com/Instance" - + "\022\'projects/{project}/instances/{instance" - + "}b\006proto3" + + ":\006backup\332A\027parent,backup,backup_id\312A`\n\'g" + + "oogle.spanner.admin.database.v1.Backup\0225" + + "google.spanner.admin.database.v1.CreateB" + + "ackupMetadata\022\245\001\n\tGetBackup\0222.google.spa" + + "nner.admin.database.v1.GetBackupRequest\032" + + "(.google.spanner.admin.database.v1.Backu" + + "p\":\202\323\344\223\002-\022+/v1/{name=projects/*/instance" + + "s/*/backups/*}\332A\004name\022\310\001\n\014UpdateBackup\0225" + + ".google.spanner.admin.database.v1.Update" + + "BackupRequest\032(.google.spanner.admin.dat" + + "abase.v1.Backup\"W\202\323\344\223\002<22/v1/{backup.nam" + + "e=projects/*/instances/*/backups/*}:\006bac" + + "kup\332A\022backup,update_mask\022\231\001\n\014DeleteBacku" + + "p\0225.google.spanner.admin.database.v1.Del" + + "eteBackupRequest\032\026.google.protobuf.Empty" + + "\":\202\323\344\223\002-*+/v1/{name=projects/*/instances" + + "/*/backups/*}\332A\004name\022\270\001\n\013ListBackups\0224.g" + + "oogle.spanner.admin.database.v1.ListBack" + + "upsRequest\0325.google.spanner.admin.databa" + + "se.v1.ListBackupsResponse\"<\202\323\344\223\002-\022+/v1/{" + + "parent=projects/*/instances/*}/backups\332A" + + "\006parent\022\261\002\n\017RestoreDatabase\0228.google.spa" + + "nner.admin.database.v1.RestoreDatabaseRe" + + "quest\032\035.google.longrunning.Operation\"\304\001\202" + + "\323\344\223\002:\"5/v1/{parent=projects/*/instances/" + + "*}/databases:restore:\001*\332A\031parent,databas" + + "e_id,backup\312Ae\n)google.spanner.admin.dat" + + "abase.v1.Database\0228google.spanner.admin." + + "database.v1.RestoreDatabaseMetadata\022\344\001\n\026" + + "ListDatabaseOperations\022?.google.spanner." + + "admin.database.v1.ListDatabaseOperations" + + "Request\032@.google.spanner.admin.database." + + "v1.ListDatabaseOperationsResponse\"G\202\323\344\223\002" + + "8\0226/v1/{parent=projects/*/instances/*}/d" + + "atabaseOperations\332A\006parent\022\334\001\n\024ListBacku" + + "pOperations\022=.google.spanner.admin.datab" + + "ase.v1.ListBackupOperationsRequest\032>.goo" + + "gle.spanner.admin.database.v1.ListBackup" + + "OperationsResponse\"E\202\323\344\223\0026\0224/v1/{parent=" + + "projects/*/instances/*}/backupOperations" + + "\332A\006parent\032x\312A\026spanner.googleapis.com\322A\\h" + + "ttps://www.googleapis.com/auth/cloud-pla" + + "tform,https://www.googleapis.com/auth/sp" + + "anner.adminB\332\002\n$com.google.spanner.admin" + + ".database.v1B\031SpannerDatabaseAdminProtoP" + + "\001ZHgoogle.golang.org/genproto/googleapis" + + "/spanner/admin/database/v1;database\252\002&Go" + + "ogle.Cloud.Spanner.Admin.Database.V1\312\002&G" + + "oogle\\Cloud\\Spanner\\Admin\\Database\\V1\352\002+" + + "Google::Cloud::Spanner::Admin::Database:" + + ":V1\352AJ\n\037spanner.googleapis.com/Instance\022" + + "\'projects/{project}/instances/{instance}" + + "b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/backup.proto b/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/backup.proto index b883adf34c..e33faddddf 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/backup.proto +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/backup.proto @@ -30,6 +30,7 @@ option java_multiple_files = true; option java_outer_classname = "BackupProto"; option java_package = "com.google.spanner.admin.database.v1"; option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1"; +option ruby_package = "Google::Cloud::Spanner::Admin::Database::V1"; // A backup of a Cloud Spanner database. message Backup { diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/common.proto b/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/common.proto index 4914cb8ac7..27ecb0a98b 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/common.proto +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/common.proto @@ -26,6 +26,7 @@ option java_multiple_files = true; option java_outer_classname = "CommonProto"; option java_package = "com.google.spanner.admin.database.v1"; option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1"; +option ruby_package = "Google::Cloud::Spanner::Admin::Database::V1"; // Encapsulates progress related information for a Cloud Spanner long // running operation. diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/spanner_database_admin.proto b/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/spanner_database_admin.proto index d48adc8aba..af440c1a36 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/spanner_database_admin.proto +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/spanner_database_admin.proto @@ -34,6 +34,7 @@ option java_multiple_files = true; option java_outer_classname = "SpannerDatabaseAdminProto"; option java_package = "com.google.spanner.admin.database.v1"; option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1"; +option ruby_package = "Google::Cloud::Spanner::Admin::Database::V1"; option (google.api.resource_definition) = { type: "spanner.googleapis.com/Instance" pattern: "projects/{project}/instances/{instance}" @@ -206,7 +207,7 @@ service DatabaseAdmin { }; option (google.api.method_signature) = "parent,backup,backup_id"; option (google.longrunning.operation_info) = { - response_type: "Backup" + response_type: "google.spanner.admin.database.v1.Backup" metadata_type: "google.spanner.admin.database.v1.CreateBackupMetadata" }; } diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/SpannerInstanceAdminProto.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/SpannerInstanceAdminProto.java index 62e2a4dca1..64fee15512 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/SpannerInstanceAdminProto.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/SpannerInstanceAdminProto.java @@ -222,13 +222,14 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "ce,permissions\032x\312A\026spanner.googleapis.co" + "m\322A\\https://www.googleapis.com/auth/clou" + "d-platform,https://www.googleapis.com/au" - + "th/spanner.adminB\337\001\n$com.google.spanner." + + "th/spanner.adminB\215\002\n$com.google.spanner." + "admin.instance.v1B\031SpannerInstanceAdminP" + "rotoP\001ZHgoogle.golang.org/genproto/googl" + "eapis/spanner/admin/instance/v1;instance" + "\252\002&Google.Cloud.Spanner.Admin.Instance.V" + "1\312\002&Google\\Cloud\\Spanner\\Admin\\Instance\\" - + "V1b\006proto3" + + "V1\352\002+Google::Cloud::Spanner::Admin::Inst" + + "ance::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/proto/google/spanner/admin/instance/v1/spanner_instance_admin.proto b/proto-google-cloud-spanner-admin-instance-v1/src/main/proto/google/spanner/admin/instance/v1/spanner_instance_admin.proto index 6a068baca2..54767bf263 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/proto/google/spanner/admin/instance/v1/spanner_instance_admin.proto +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/proto/google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -33,6 +33,7 @@ option java_multiple_files = true; option java_outer_classname = "SpannerInstanceAdminProto"; option java_package = "com.google.spanner.admin.instance.v1"; option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Instance\\V1"; +option ruby_package = "Google::Cloud::Spanner::Admin::Instance::V1"; // Cloud Spanner Instance Admin API // diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeysProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeysProto.java index 8021353174..9c9b6318d1 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeysProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeysProto.java @@ -55,11 +55,12 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "H\001B\020\n\016start_key_typeB\016\n\014end_key_type\"l\n\006" + "KeySet\022(\n\004keys\030\001 \003(\0132\032.google.protobuf.L" + "istValue\022+\n\006ranges\030\002 \003(\0132\033.google.spanne" - + "r.v1.KeyRange\022\013\n\003all\030\003 \001(\010B\222\001\n\025com.googl" + + "r.v1.KeyRange\022\013\n\003all\030\003 \001(\010B\257\001\n\025com.googl" + "e.spanner.v1B\tKeysProtoP\001Z8google.golang" + ".org/genproto/googleapis/spanner/v1;span" + "ner\252\002\027Google.Cloud.Spanner.V1\312\002\027Google\\C" - + "loud\\Spanner\\V1b\006proto3" + + "loud\\Spanner\\V1\352\002\032Google::Cloud::Spanner" + + "::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationProto.java index 8dd9e0420c..27ce2b4f3a 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationProto.java @@ -63,11 +63,11 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "lues\030\003 \003(\0132\032.google.protobuf.ListValue\032C" + "\n\006Delete\022\r\n\005table\030\001 \001(\t\022*\n\007key_set\030\002 \001(\013" + "2\031.google.spanner.v1.KeySetB\013\n\toperation" - + "B\226\001\n\025com.google.spanner.v1B\rMutationProt" + + "B\263\001\n\025com.google.spanner.v1B\rMutationProt" + "oP\001Z8google.golang.org/genproto/googleap" + "is/spanner/v1;spanner\252\002\027Google.Cloud.Spa" - + "nner.V1\312\002\027Google\\Cloud\\Spanner\\V1b\006proto" - + "3" + + "nner.V1\312\002\027Google\\Cloud\\Spanner\\V1\352\002\032Goog" + + "le::Cloud::Spanner::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanProto.java index 4276b984cc..03c05431d0 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanProto.java @@ -76,11 +76,12 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "ue\030\002 \001(\005:\0028\001\"8\n\004Kind\022\024\n\020KIND_UNSPECIFIED" + "\020\000\022\016\n\nRELATIONAL\020\001\022\n\n\006SCALAR\020\002\"<\n\tQueryP" + "lan\022/\n\nplan_nodes\030\001 \003(\0132\033.google.spanner" - + ".v1.PlanNodeB\227\001\n\025com.google.spanner.v1B\016" + + ".v1.PlanNodeB\264\001\n\025com.google.spanner.v1B\016" + "QueryPlanProtoP\001Z8google.golang.org/genp" + "roto/googleapis/spanner/v1;spanner\252\002\027Goo" + "gle.Cloud.Spanner.V1\312\002\027Google\\Cloud\\Span" - + "ner\\V1b\006proto3" + + "ner\\V1\352\002\032Google::Cloud::Spanner::V1b\006pro" + + "to3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetProto.java index 08e001c03b..48157af205 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetProto.java @@ -74,11 +74,12 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "gle.spanner.v1.QueryPlan\022,\n\013query_stats\030" + "\002 \001(\0132\027.google.protobuf.Struct\022\031\n\017row_co" + "unt_exact\030\003 \001(\003H\000\022\037\n\025row_count_lower_bou" - + "nd\030\004 \001(\003H\000B\013\n\trow_countB\232\001\n\025com.google.s" + + "nd\030\004 \001(\003H\000B\013\n\trow_countB\267\001\n\025com.google.s" + "panner.v1B\016ResultSetProtoP\001Z8google.gola" + "ng.org/genproto/googleapis/spanner/v1;sp" + "anner\370\001\001\252\002\027Google.Cloud.Spanner.V1\312\002\027Goo" - + "gle\\Cloud\\Spanner\\V1b\006proto3" + + "gle\\Cloud\\Spanner\\V1\352\002\032Google::Cloud::Sp" + + "anner::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerProto.java index eb528acbc1..0932ab5d52 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerProto.java @@ -332,13 +332,14 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + ":\001*\032w\312A\026spanner.googleapis.com\322A[https:/" + "/www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/spanner." - + "dataB\367\001\n\025com.google.spanner.v1B\014SpannerP" + + "dataB\224\002\n\025com.google.spanner.v1B\014SpannerP" + "rotoP\001Z8google.golang.org/genproto/googl" + "eapis/spanner/v1;spanner\252\002\027Google.Cloud." - + "Spanner.V1\312\002\027Google\\Cloud\\Spanner\\V1\352A_\n" - + "\037spanner.googleapis.com/Database\022