Skip to content

Commit

Permalink
feat: Add support for UpdateDatabase in Cloud Spanner (#2429)
Browse files Browse the repository at this point in the history
* feat: Add support for UpdateDatabase in Cloud Spanner

PiperOrigin-RevId: 531423380

Source-Link: googleapis/googleapis@3e054d1

Source-Link: googleapis/googleapis-gen@e347738
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTM0NzczODQ4Mzc0M2U4ZTg2NmNhYzcyMmRiMGU5NDI1MzU2ZmM4MCJ9

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Mend Renovate <[email protected]>
Co-authored-by: Rajat Bhatta <[email protected]>
  • Loading branch information
4 people committed May 15, 2023
1 parent a33ea90 commit 09f20bd
Show file tree
Hide file tree
Showing 19 changed files with 4,107 additions and 263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
import com.google.spanner.admin.database.v1.UpdateBackupRequest;
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata;
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest;
import com.google.spanner.admin.database.v1.UpdateDatabaseMetadata;
import com.google.spanner.admin.database.v1.UpdateDatabaseRequest;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -725,6 +727,235 @@ public final UnaryCallable<GetDatabaseRequest, Database> getDatabaseCallable() {
return stub.getDatabaseCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates a Cloud Spanner database. The returned [long-running
* operation][google.longrunning.Operation] can be used to track the progress of updating the
* database. If the named database does not exist, returns `NOT_FOUND`.
*
* <p>While the operation is pending:
*
* <p>&#42; The database's [reconciling][google.spanner.admin.database.v1.Database.reconciling]
* field is set to true. &#42; Cancelling the operation is best-effort. If the cancellation
* succeeds, the operation metadata's
* [cancel_time][google.spanner.admin.database.v1.UpdateDatabaseMetadata.cancel_time] is set, the
* updates are reverted, and the operation terminates with a `CANCELLED` status. &#42; New
* UpdateDatabase requests will return a `FAILED_PRECONDITION` error until the pending operation
* is done (returns successfully or with error). &#42; Reading the database via the API continues
* to give the pre-request values.
*
* <p>Upon completion of the returned operation:
*
* <p>&#42; The new values are in effect and readable via the API. &#42; The database's
* [reconciling][google.spanner.admin.database.v1.Database.reconciling] field becomes false.
*
* <p>The returned [long-running operation][google.longrunning.Operation] will have a name of the
* format
* `projects/&lt;project&gt;/instances/&lt;instance&gt;/databases/&lt;database&gt;/operations/&lt;operation_id&gt;`
* and can be used to track the database modification. The
* [metadata][google.longrunning.Operation.metadata] field type is
* [UpdateDatabaseMetadata][google.spanner.admin.database.v1.UpdateDatabaseMetadata]. The
* [response][google.longrunning.Operation.response] field type is
* [Database][google.spanner.admin.database.v1.Database], if successful.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
* Database database = Database.newBuilder().build();
* FieldMask updateMask = FieldMask.newBuilder().build();
* Database response = databaseAdminClient.updateDatabaseAsync(database, updateMask).get();
* }
* }</pre>
*
* @param database Required. The database to update. The `name` field of the database is of the
* form `projects/&lt;project&gt;/instances/&lt;instance&gt;/databases/&lt;database&gt;`.
* @param updateMask Required. The list of fields to update. Currently, only
* `enable_drop_protection` field can be updated.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<Database, UpdateDatabaseMetadata> updateDatabaseAsync(
Database database, FieldMask updateMask) {
UpdateDatabaseRequest request =
UpdateDatabaseRequest.newBuilder().setDatabase(database).setUpdateMask(updateMask).build();
return updateDatabaseAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates a Cloud Spanner database. The returned [long-running
* operation][google.longrunning.Operation] can be used to track the progress of updating the
* database. If the named database does not exist, returns `NOT_FOUND`.
*
* <p>While the operation is pending:
*
* <p>&#42; The database's [reconciling][google.spanner.admin.database.v1.Database.reconciling]
* field is set to true. &#42; Cancelling the operation is best-effort. If the cancellation
* succeeds, the operation metadata's
* [cancel_time][google.spanner.admin.database.v1.UpdateDatabaseMetadata.cancel_time] is set, the
* updates are reverted, and the operation terminates with a `CANCELLED` status. &#42; New
* UpdateDatabase requests will return a `FAILED_PRECONDITION` error until the pending operation
* is done (returns successfully or with error). &#42; Reading the database via the API continues
* to give the pre-request values.
*
* <p>Upon completion of the returned operation:
*
* <p>&#42; The new values are in effect and readable via the API. &#42; The database's
* [reconciling][google.spanner.admin.database.v1.Database.reconciling] field becomes false.
*
* <p>The returned [long-running operation][google.longrunning.Operation] will have a name of the
* format
* `projects/&lt;project&gt;/instances/&lt;instance&gt;/databases/&lt;database&gt;/operations/&lt;operation_id&gt;`
* and can be used to track the database modification. The
* [metadata][google.longrunning.Operation.metadata] field type is
* [UpdateDatabaseMetadata][google.spanner.admin.database.v1.UpdateDatabaseMetadata]. The
* [response][google.longrunning.Operation.response] field type is
* [Database][google.spanner.admin.database.v1.Database], if successful.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
* UpdateDatabaseRequest request =
* UpdateDatabaseRequest.newBuilder()
* .setDatabase(Database.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* Database response = databaseAdminClient.updateDatabaseAsync(request).get();
* }
* }</pre>
*
* @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 OperationFuture<Database, UpdateDatabaseMetadata> updateDatabaseAsync(
UpdateDatabaseRequest request) {
return updateDatabaseOperationCallable().futureCall(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates a Cloud Spanner database. The returned [long-running
* operation][google.longrunning.Operation] can be used to track the progress of updating the
* database. If the named database does not exist, returns `NOT_FOUND`.
*
* <p>While the operation is pending:
*
* <p>&#42; The database's [reconciling][google.spanner.admin.database.v1.Database.reconciling]
* field is set to true. &#42; Cancelling the operation is best-effort. If the cancellation
* succeeds, the operation metadata's
* [cancel_time][google.spanner.admin.database.v1.UpdateDatabaseMetadata.cancel_time] is set, the
* updates are reverted, and the operation terminates with a `CANCELLED` status. &#42; New
* UpdateDatabase requests will return a `FAILED_PRECONDITION` error until the pending operation
* is done (returns successfully or with error). &#42; Reading the database via the API continues
* to give the pre-request values.
*
* <p>Upon completion of the returned operation:
*
* <p>&#42; The new values are in effect and readable via the API. &#42; The database's
* [reconciling][google.spanner.admin.database.v1.Database.reconciling] field becomes false.
*
* <p>The returned [long-running operation][google.longrunning.Operation] will have a name of the
* format
* `projects/&lt;project&gt;/instances/&lt;instance&gt;/databases/&lt;database&gt;/operations/&lt;operation_id&gt;`
* and can be used to track the database modification. The
* [metadata][google.longrunning.Operation.metadata] field type is
* [UpdateDatabaseMetadata][google.spanner.admin.database.v1.UpdateDatabaseMetadata]. The
* [response][google.longrunning.Operation.response] field type is
* [Database][google.spanner.admin.database.v1.Database], if successful.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
* UpdateDatabaseRequest request =
* UpdateDatabaseRequest.newBuilder()
* .setDatabase(Database.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* OperationFuture<Database, UpdateDatabaseMetadata> future =
* databaseAdminClient.updateDatabaseOperationCallable().futureCall(request);
* // Do something.
* Database response = future.get();
* }
* }</pre>
*/
public final OperationCallable<UpdateDatabaseRequest, Database, UpdateDatabaseMetadata>
updateDatabaseOperationCallable() {
return stub.updateDatabaseOperationCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates a Cloud Spanner database. The returned [long-running
* operation][google.longrunning.Operation] can be used to track the progress of updating the
* database. If the named database does not exist, returns `NOT_FOUND`.
*
* <p>While the operation is pending:
*
* <p>&#42; The database's [reconciling][google.spanner.admin.database.v1.Database.reconciling]
* field is set to true. &#42; Cancelling the operation is best-effort. If the cancellation
* succeeds, the operation metadata's
* [cancel_time][google.spanner.admin.database.v1.UpdateDatabaseMetadata.cancel_time] is set, the
* updates are reverted, and the operation terminates with a `CANCELLED` status. &#42; New
* UpdateDatabase requests will return a `FAILED_PRECONDITION` error until the pending operation
* is done (returns successfully or with error). &#42; Reading the database via the API continues
* to give the pre-request values.
*
* <p>Upon completion of the returned operation:
*
* <p>&#42; The new values are in effect and readable via the API. &#42; The database's
* [reconciling][google.spanner.admin.database.v1.Database.reconciling] field becomes false.
*
* <p>The returned [long-running operation][google.longrunning.Operation] will have a name of the
* format
* `projects/&lt;project&gt;/instances/&lt;instance&gt;/databases/&lt;database&gt;/operations/&lt;operation_id&gt;`
* and can be used to track the database modification. The
* [metadata][google.longrunning.Operation.metadata] field type is
* [UpdateDatabaseMetadata][google.spanner.admin.database.v1.UpdateDatabaseMetadata]. The
* [response][google.longrunning.Operation.response] field type is
* [Database][google.spanner.admin.database.v1.Database], if successful.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
* UpdateDatabaseRequest request =
* UpdateDatabaseRequest.newBuilder()
* .setDatabase(Database.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* ApiFuture<Operation> future =
* databaseAdminClient.updateDatabaseCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<UpdateDatabaseRequest, Operation> updateDatabaseCallable() {
return stub.updateDatabaseCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
import com.google.spanner.admin.database.v1.UpdateBackupRequest;
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata;
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest;
import com.google.spanner.admin.database.v1.UpdateDatabaseMetadata;
import com.google.spanner.admin.database.v1.UpdateDatabaseRequest;
import java.io.IOException;
import java.util.List;
import javax.annotation.Generated;
Expand Down Expand Up @@ -137,6 +139,17 @@ public UnaryCallSettings<GetDatabaseRequest, Database> getDatabaseSettings() {
return ((DatabaseAdminStubSettings) getStubSettings()).getDatabaseSettings();
}

/** Returns the object with the settings used for calls to updateDatabase. */
public UnaryCallSettings<UpdateDatabaseRequest, Operation> updateDatabaseSettings() {
return ((DatabaseAdminStubSettings) getStubSettings()).updateDatabaseSettings();
}

/** Returns the object with the settings used for calls to updateDatabase. */
public OperationCallSettings<UpdateDatabaseRequest, Database, UpdateDatabaseMetadata>
updateDatabaseOperationSettings() {
return ((DatabaseAdminStubSettings) getStubSettings()).updateDatabaseOperationSettings();
}

/** Returns the object with the settings used for calls to updateDatabaseDdl. */
public UnaryCallSettings<UpdateDatabaseDdlRequest, Operation> updateDatabaseDdlSettings() {
return ((DatabaseAdminStubSettings) getStubSettings()).updateDatabaseDdlSettings();
Expand Down Expand Up @@ -391,6 +404,17 @@ public UnaryCallSettings.Builder<GetDatabaseRequest, Database> getDatabaseSettin
return getStubSettingsBuilder().getDatabaseSettings();
}

/** Returns the builder for the settings used for calls to updateDatabase. */
public UnaryCallSettings.Builder<UpdateDatabaseRequest, Operation> updateDatabaseSettings() {
return getStubSettingsBuilder().updateDatabaseSettings();
}

/** Returns the builder for the settings used for calls to updateDatabase. */
public OperationCallSettings.Builder<UpdateDatabaseRequest, Database, UpdateDatabaseMetadata>
updateDatabaseOperationSettings() {
return getStubSettingsBuilder().updateDatabaseOperationSettings();
}

/** Returns the builder for the settings used for calls to updateDatabaseDdl. */
public UnaryCallSettings.Builder<UpdateDatabaseDdlRequest, Operation>
updateDatabaseDdlSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
"UpdateBackup": {
"methods": ["updateBackup", "updateBackup", "updateBackupCallable"]
},
"UpdateDatabase": {
"methods": ["updateDatabaseAsync", "updateDatabaseAsync", "updateDatabaseOperationCallable", "updateDatabaseCallable"]
},
"UpdateDatabaseDdl": {
"methods": ["updateDatabaseDdlAsync", "updateDatabaseDdlAsync", "updateDatabaseDdlAsync", "updateDatabaseDdlOperationCallable", "updateDatabaseDdlCallable"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
import com.google.spanner.admin.database.v1.UpdateBackupRequest;
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata;
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest;
import com.google.spanner.admin.database.v1.UpdateDatabaseMetadata;
import com.google.spanner.admin.database.v1.UpdateDatabaseRequest;
import javax.annotation.Generated;

// AUTO-GENERATED DOCUMENTATION AND CLASS.
Expand Down Expand Up @@ -103,6 +105,15 @@ public UnaryCallable<GetDatabaseRequest, Database> getDatabaseCallable() {
throw new UnsupportedOperationException("Not implemented: getDatabaseCallable()");
}

public OperationCallable<UpdateDatabaseRequest, Database, UpdateDatabaseMetadata>
updateDatabaseOperationCallable() {
throw new UnsupportedOperationException("Not implemented: updateDatabaseOperationCallable()");
}

public UnaryCallable<UpdateDatabaseRequest, Operation> updateDatabaseCallable() {
throw new UnsupportedOperationException("Not implemented: updateDatabaseCallable()");
}

public OperationCallable<UpdateDatabaseDdlRequest, Empty, UpdateDatabaseDdlMetadata>
updateDatabaseDdlOperationCallable() {
throw new UnsupportedOperationException(
Expand Down
Loading

0 comments on commit 09f20bd

Please sign in to comment.