diff --git a/README.md b/README.md index afe439ac3ec..c12763f9052 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,13 @@ implementation 'com.google.cloud:google-cloud-spanner' If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-spanner:6.19.0' +implementation 'com.google.cloud:google-cloud-spanner:6.20.0' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-spanner" % "6.19.0" +libraryDependencies += "com.google.cloud" % "google-cloud-spanner" % "6.20.0" ``` ## Authentication diff --git a/google-cloud-spanner/clirr-ignored-differences.xml b/google-cloud-spanner/clirr-ignored-differences.xml index 464f6e9e9f8..18805fb53c2 100644 --- a/google-cloud-spanner/clirr-ignored-differences.xml +++ b/google-cloud-spanner/clirr-ignored-differences.xml @@ -35,4 +35,29 @@ com/google/cloud/spanner/connection/ConnectionOptions com.google.cloud.spanner.Dialect getDialect() + + 7013 + com/google/cloud/spanner/BackupInfo$Builder + com.google.cloud.spanner.BackupInfo$Builder setMaxExpireTime(com.google.cloud.Timestamp) + + + 7013 + com/google/cloud/spanner/BackupInfo$Builder + com.google.cloud.spanner.BackupInfo$Builder setReferencingBackup(com.google.protobuf.ProtocolStringList) + + + 7012 + com/google/cloud/spanner/DatabaseAdminClient + com.google.api.gax.longrunning.OperationFuture copyBackup(java.lang.String, java.lang.String, java.lang.String, com.google.cloud.Timestamp) + + + 7012 + com/google/cloud/spanner/DatabaseAdminClient + com.google.api.gax.longrunning.OperationFuture copyBackup(com.google.cloud.spanner.BackupId, com.google.cloud.spanner.Backup) + + + 7012 + com/google/cloud/spanner/spi/v1/SpannerRpc + com.google.api.gax.longrunning.OperationFuture copyBackUp(com.google.cloud.spanner.BackupId, com.google.cloud.spanner.Backup) + diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Backup.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Backup.java index 27308c04009..c824cf2de15 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Backup.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Backup.java @@ -183,6 +183,8 @@ static Backup fromProto( .setDatabase(DatabaseId.of(proto.getDatabase())) .setEncryptionInfo(EncryptionInfo.fromProtoOrNull(proto.getEncryptionInfo())) .setProto(proto) + .setMaxExpireTime(Timestamp.fromProto(proto.getMaxExpireTime())) + .setReferencingBackup(proto.getReferencingBackupsList()) .build(); } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BackupInfo.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BackupInfo.java index 0657ff2b7b8..a8b19973c94 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BackupInfo.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BackupInfo.java @@ -20,6 +20,7 @@ import com.google.cloud.Timestamp; import com.google.cloud.spanner.encryption.BackupEncryptionConfig; import com.google.cloud.spanner.encryption.EncryptionInfo; +import com.google.protobuf.ProtocolStringList; import com.google.spanner.admin.database.v1.Database; import java.util.Objects; import javax.annotation.Nullable; @@ -84,6 +85,20 @@ public abstract static class Builder { /** Builds the backup from this builder. */ public abstract Backup build(); + + /** + * Output Only. + * + *

Returns the max allowed expiration time of the backup, with microseconds granularity. + */ + protected abstract Builder setMaxExpireTime(Timestamp maxExpireTime); + + /** + * Output Only. + * + *

Returns the names of the destination backups being created by copying this source backup. + */ + protected abstract Builder setReferencingBackup(ProtocolStringList referencingBackup); } abstract static class BuilderImpl extends Builder { @@ -96,6 +111,8 @@ abstract static class BuilderImpl extends Builder { private BackupEncryptionConfig encryptionConfig; private EncryptionInfo encryptionInfo; private com.google.spanner.admin.database.v1.Backup proto; + private Timestamp maxExpireTime; + private ProtocolStringList referencingBackup; BuilderImpl(BackupId id) { this.id = Preconditions.checkNotNull(id); @@ -111,6 +128,8 @@ abstract static class BuilderImpl extends Builder { this.encryptionConfig = other.encryptionConfig; this.encryptionInfo = other.encryptionInfo; this.proto = other.proto; + this.maxExpireTime = other.maxExpireTime; + this.referencingBackup = other.referencingBackup; } @Override @@ -163,6 +182,18 @@ Builder setProto(@Nullable com.google.spanner.admin.database.v1.Backup proto) { this.proto = proto; return this; } + + @Override + public Builder setMaxExpireTime(Timestamp maxExpireTime) { + this.maxExpireTime = Preconditions.checkNotNull(maxExpireTime); + return this; + } + + @Override + public Builder setReferencingBackup(ProtocolStringList referencingBackup) { + this.referencingBackup = Preconditions.checkNotNull(referencingBackup); + return this; + } } /** State of the backup. */ @@ -184,6 +215,8 @@ public enum State { private final BackupEncryptionConfig encryptionConfig; private final EncryptionInfo encryptionInfo; private final com.google.spanner.admin.database.v1.Backup proto; + private final Timestamp maxExpireTime; + private final ProtocolStringList referencingBackup; BackupInfo(BuilderImpl builder) { this.id = builder.id; @@ -195,6 +228,8 @@ public enum State { this.versionTime = builder.versionTime; this.database = builder.database; this.proto = builder.proto; + this.maxExpireTime = builder.maxExpireTime; + this.referencingBackup = builder.referencingBackup; } /** Returns the backup id. */ @@ -253,6 +288,19 @@ public DatabaseId getDatabase() { return proto; } + /** Returns the max expire time of this {@link Backup}. */ + public Timestamp getMaxExpireTime() { + return maxExpireTime; + } + + /** + * Returns the names of the destination backups being created by copying this source backup {@link + * Backup}. + */ + public ProtocolStringList getReferencingBackup() { + return referencingBackup; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -269,19 +317,30 @@ public boolean equals(Object o) { && Objects.equals(encryptionInfo, that.encryptionInfo) && Objects.equals(expireTime, that.expireTime) && Objects.equals(versionTime, that.versionTime) - && Objects.equals(database, that.database); + && Objects.equals(database, that.database) + && Objects.equals(maxExpireTime, that.maxExpireTime) + && Objects.equals(referencingBackup, that.referencingBackup); } @Override public int hashCode() { return Objects.hash( - id, state, size, encryptionConfig, encryptionInfo, expireTime, versionTime, database); + id, + state, + size, + encryptionConfig, + encryptionInfo, + expireTime, + versionTime, + database, + maxExpireTime, + referencingBackup); } @Override public String toString() { return String.format( - "Backup[%s, %s, %d, %s, %s, %s, %s, %s]", + "Backup[%s, %s, %d, %s, %s, %s, %s, %s, %s, %s]", id.getName(), state, size, @@ -289,6 +348,8 @@ public String toString() { encryptionInfo, expireTime, versionTime, - database); + database, + maxExpireTime, + referencingBackup); } } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseAdminClient.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseAdminClient.java index 2e4fd09951e..114628d136a 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseAdminClient.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseAdminClient.java @@ -22,6 +22,7 @@ import com.google.cloud.Timestamp; import com.google.cloud.spanner.Options.ListOption; import com.google.longrunning.Operation; +import com.google.spanner.admin.database.v1.CopyBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; import com.google.spanner.admin.database.v1.CreateDatabaseRequest; @@ -178,6 +179,70 @@ OperationFuture createBackup( */ OperationFuture createBackup(Backup backup) throws SpannerException; + /** + * Creates a copy of backup from an existing backup in a Cloud Spanner instance. + * + *

Example to copy a backup. + * + *

{@code
+   * String instanceId                  = "my_instance_id";
+   * String sourceBackupId              = "source_backup_id";
+   * String destinationBackupId         = "destination_backup_id";
+   * Timestamp expireTime               = Timestamp.ofTimeMicroseconds(micros);
+   * OperationFuture op = dbAdminClient
+   *     .copyBackup(
+   *         instanceId,
+   *         sourceBackupId,
+   *         destinationBackupId,
+   *         expireTime);
+   * Backup backup = op.get();
+   * }
+ * + * @param instanceId the id of the instance where the source backup is located and where the new + * backup will be created. + * @param sourceBackupId the source backup id. + * @param destinationBackupId the id of the backup which will be created. It must conform to the + * regular expression [a-z][a-z0-9_\-]*[a-z0-9] and be between 2 and 60 characters in length. + * @param expireTime the time that the new backup will automatically expire. + */ + OperationFuture copyBackup( + String instanceId, String sourceBackupId, String destinationBackupId, Timestamp expireTime) + throws SpannerException; + + /** + * Creates a copy of backup from an existing backup in Cloud Spanner. Any configuration options in + * the {@link Backup} instance will be included in the {@link + * com.google.spanner.admin.database.v1.CopyBackupRequest}. + * + *

The expire time of the new backup must be set and be at least 6 hours and at most 366 days + * after the creation time of the existing backup that is being copied. + * + *

Example to create a copy of a backup. + * + *

{@code
+   * BackupId sourceBackupId = BackupId.of("source-project", "source-instance", "source-backup-id");
+   * BackupId destinationBackupId = BackupId.of("destination-project", "destination-instance", "new-backup-id");
+   * Timestamp expireTime = Timestamp.ofTimeMicroseconds(expireTimeMicros);
+   * EncryptionConfig encryptionConfig =
+   *         EncryptionConfig.ofKey(
+   *             "projects/my-project/locations/some-location/keyRings/my-keyring/cryptoKeys/my-key"));
+   *
+   * Backup destinationBackup = dbAdminClient
+   *     .newBackupBuilder(destinationBackupId)
+   *     .setExpireTime(expireTime)
+   *     .setEncryptionConfig(encryptionConfig)
+   *     .build();
+   *
+   * OperationFuture op = dbAdminClient.copyBackUp(sourceBackupId, destinationBackup);
+   * Backup copiedBackup = op.get();
+   * }
+ * + * @param sourceBackupId the backup to be copied + * @param destinationBackup the new backup to create + */ + OperationFuture copyBackup( + BackupId sourceBackupId, Backup destinationBackup) throws SpannerException; + /** * Restore a database from a backup. The database that is restored will be created and may not * already exist. diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseAdminClientImpl.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseAdminClientImpl.java index 52df8701556..7792ec282f4 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseAdminClientImpl.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseAdminClientImpl.java @@ -32,6 +32,7 @@ import com.google.longrunning.Operation; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; +import com.google.spanner.admin.database.v1.CopyBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; import com.google.spanner.admin.database.v1.RestoreDatabaseMetadata; @@ -165,6 +166,49 @@ public OperationFuture createBackup(Backup backupI }); } + @Override + public OperationFuture copyBackup( + String instanceId, String sourceBackupId, String destinationBackupId, Timestamp expireTime) + throws SpannerException { + final Backup destinationBackup = + newBackupBuilder(BackupId.of(projectId, instanceId, destinationBackupId)) + .setExpireTime(expireTime) + .build(); + + return copyBackup(BackupId.of(projectId, instanceId, sourceBackupId), destinationBackup); + } + + @Override + public OperationFuture copyBackup( + BackupId sourceBackupId, Backup destinationBackup) throws SpannerException { + Preconditions.checkNotNull(sourceBackupId); + Preconditions.checkNotNull(destinationBackup); + + final OperationFuture + rawOperationFuture = rpc.copyBackUp(sourceBackupId, destinationBackup); + + return new OperationFutureImpl<>( + rawOperationFuture.getPollingFuture(), + rawOperationFuture.getInitialFuture(), + snapshot -> { + com.google.spanner.admin.database.v1.Backup proto = + ProtoOperationTransformers.ResponseTransformer.create( + com.google.spanner.admin.database.v1.Backup.class) + .apply(snapshot); + return Backup.fromProto( + com.google.spanner.admin.database.v1.Backup.newBuilder(proto) + .setName(proto.getName()) + .setExpireTime(proto.getExpireTime()) + .setEncryptionInfo(proto.getEncryptionInfo()) + .build(), + DatabaseAdminClientImpl.this); + }, + ProtoOperationTransformers.MetadataTransformer.create(CopyBackupMetadata.class), + e -> { + throw SpannerExceptionFactory.newSpannerException(e); + }); + } + @Override public Backup updateBackup(String instanceId, String backupId, Timestamp expireTime) { String backupName = getBackupName(instanceId, backupId); 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 ac602861ce0..d8110bd947c 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 @@ -40,8 +40,11 @@ import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; import com.google.spanner.admin.database.v1.Backup; import com.google.spanner.admin.database.v1.BackupName; +import com.google.spanner.admin.database.v1.CopyBackupMetadata; +import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupRequest; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; @@ -1548,6 +1551,327 @@ public final UnaryCallable createBackupCallable( return stub.createBackupCallable(); } + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Starts copying a 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 copying of the backup. The operation is associated with the + * destination backup. The [metadata][google.longrunning.Operation.metadata] field type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. 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 copying and delete the backup. Concurrent CopyBackup requests can run + * on the same source backup. + * + *

Sample code: + * + *

{@code
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String backupId = "backupId2121930365";
+   *   BackupName sourceBackup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
+   *   Timestamp expireTime = Timestamp.newBuilder().build();
+   *   Backup response =
+   *       databaseAdminClient.copyBackupAsync(parent, backupId, sourceBackup, expireTime).get();
+   * }
+   * }
+ * + * @param parent Required. The name of the destination instance that will contain the backup copy. + * Values are of the form: `projects/<project>/instances/<instance>`. + * @param backupId Required. The id of the backup copy. The `backup_id` appended to `parent` forms + * the full backup_uri of the form + * `projects/<project>/instances/<instance>/backups/<backup>`. + * @param sourceBackup Required. The source backup to be copied. The source backup needs to be in + * READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot + * be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the + * form: `projects/<project>/instances/<instance>/backups/<backup>`. + * @param expireTime Required. The expiration time of the backup in microsecond granularity. The + * expiration time must be at least 6 hours and at most 366 days from the `create_time` of the + * source backup. Once the `expire_time` has passed, the backup is eligible to be + * automatically deleted by Cloud Spanner to free the resources used by the backup. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture copyBackupAsync( + InstanceName parent, String backupId, BackupName sourceBackup, Timestamp expireTime) { + CopyBackupRequest request = + CopyBackupRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setBackupId(backupId) + .setSourceBackup(sourceBackup == null ? null : sourceBackup.toString()) + .setExpireTime(expireTime) + .build(); + return copyBackupAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Starts copying a 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 copying of the backup. The operation is associated with the + * destination backup. The [metadata][google.longrunning.Operation.metadata] field type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. 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 copying and delete the backup. Concurrent CopyBackup requests can run + * on the same source backup. + * + *

Sample code: + * + *

{@code
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String backupId = "backupId2121930365";
+   *   String sourceBackup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
+   *   Timestamp expireTime = Timestamp.newBuilder().build();
+   *   Backup response =
+   *       databaseAdminClient.copyBackupAsync(parent, backupId, sourceBackup, expireTime).get();
+   * }
+   * }
+ * + * @param parent Required. The name of the destination instance that will contain the backup copy. + * Values are of the form: `projects/<project>/instances/<instance>`. + * @param backupId Required. The id of the backup copy. The `backup_id` appended to `parent` forms + * the full backup_uri of the form + * `projects/<project>/instances/<instance>/backups/<backup>`. + * @param sourceBackup Required. The source backup to be copied. The source backup needs to be in + * READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot + * be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the + * form: `projects/<project>/instances/<instance>/backups/<backup>`. + * @param expireTime Required. The expiration time of the backup in microsecond granularity. The + * expiration time must be at least 6 hours and at most 366 days from the `create_time` of the + * source backup. Once the `expire_time` has passed, the backup is eligible to be + * automatically deleted by Cloud Spanner to free the resources used by the backup. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture copyBackupAsync( + InstanceName parent, String backupId, String sourceBackup, Timestamp expireTime) { + CopyBackupRequest request = + CopyBackupRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setBackupId(backupId) + .setSourceBackup(sourceBackup) + .setExpireTime(expireTime) + .build(); + return copyBackupAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Starts copying a 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 copying of the backup. The operation is associated with the + * destination backup. The [metadata][google.longrunning.Operation.metadata] field type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. 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 copying and delete the backup. Concurrent CopyBackup requests can run + * on the same source backup. + * + *

Sample code: + * + *

{@code
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
+   *   String backupId = "backupId2121930365";
+   *   BackupName sourceBackup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
+   *   Timestamp expireTime = Timestamp.newBuilder().build();
+   *   Backup response =
+   *       databaseAdminClient.copyBackupAsync(parent, backupId, sourceBackup, expireTime).get();
+   * }
+   * }
+ * + * @param parent Required. The name of the destination instance that will contain the backup copy. + * Values are of the form: `projects/<project>/instances/<instance>`. + * @param backupId Required. The id of the backup copy. The `backup_id` appended to `parent` forms + * the full backup_uri of the form + * `projects/<project>/instances/<instance>/backups/<backup>`. + * @param sourceBackup Required. The source backup to be copied. The source backup needs to be in + * READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot + * be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the + * form: `projects/<project>/instances/<instance>/backups/<backup>`. + * @param expireTime Required. The expiration time of the backup in microsecond granularity. The + * expiration time must be at least 6 hours and at most 366 days from the `create_time` of the + * source backup. Once the `expire_time` has passed, the backup is eligible to be + * automatically deleted by Cloud Spanner to free the resources used by the backup. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture copyBackupAsync( + String parent, String backupId, BackupName sourceBackup, Timestamp expireTime) { + CopyBackupRequest request = + CopyBackupRequest.newBuilder() + .setParent(parent) + .setBackupId(backupId) + .setSourceBackup(sourceBackup == null ? null : sourceBackup.toString()) + .setExpireTime(expireTime) + .build(); + return copyBackupAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Starts copying a 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 copying of the backup. The operation is associated with the + * destination backup. The [metadata][google.longrunning.Operation.metadata] field type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. 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 copying and delete the backup. Concurrent CopyBackup requests can run + * on the same source backup. + * + *

Sample code: + * + *

{@code
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
+   *   String backupId = "backupId2121930365";
+   *   String sourceBackup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
+   *   Timestamp expireTime = Timestamp.newBuilder().build();
+   *   Backup response =
+   *       databaseAdminClient.copyBackupAsync(parent, backupId, sourceBackup, expireTime).get();
+   * }
+   * }
+ * + * @param parent Required. The name of the destination instance that will contain the backup copy. + * Values are of the form: `projects/<project>/instances/<instance>`. + * @param backupId Required. The id of the backup copy. The `backup_id` appended to `parent` forms + * the full backup_uri of the form + * `projects/<project>/instances/<instance>/backups/<backup>`. + * @param sourceBackup Required. The source backup to be copied. The source backup needs to be in + * READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot + * be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the + * form: `projects/<project>/instances/<instance>/backups/<backup>`. + * @param expireTime Required. The expiration time of the backup in microsecond granularity. The + * expiration time must be at least 6 hours and at most 366 days from the `create_time` of the + * source backup. Once the `expire_time` has passed, the backup is eligible to be + * automatically deleted by Cloud Spanner to free the resources used by the backup. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture copyBackupAsync( + String parent, String backupId, String sourceBackup, Timestamp expireTime) { + CopyBackupRequest request = + CopyBackupRequest.newBuilder() + .setParent(parent) + .setBackupId(backupId) + .setSourceBackup(sourceBackup) + .setExpireTime(expireTime) + .build(); + return copyBackupAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Starts copying a 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 copying of the backup. The operation is associated with the + * destination backup. The [metadata][google.longrunning.Operation.metadata] field type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. 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 copying and delete the backup. Concurrent CopyBackup requests can run + * on the same source backup. + * + *

Sample code: + * + *

{@code
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   CopyBackupRequest request =
+   *       CopyBackupRequest.newBuilder()
+   *           .setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
+   *           .setBackupId("backupId2121930365")
+   *           .setSourceBackup(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
+   *           .setExpireTime(Timestamp.newBuilder().build())
+   *           .setEncryptionConfig(CopyBackupEncryptionConfig.newBuilder().build())
+   *           .build();
+   *   Backup response = databaseAdminClient.copyBackupAsync(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 OperationFuture copyBackupAsync( + CopyBackupRequest request) { + return copyBackupOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Starts copying a 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 copying of the backup. The operation is associated with the + * destination backup. The [metadata][google.longrunning.Operation.metadata] field type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. 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 copying and delete the backup. Concurrent CopyBackup requests can run + * on the same source backup. + * + *

Sample code: + * + *

{@code
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   CopyBackupRequest request =
+   *       CopyBackupRequest.newBuilder()
+   *           .setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
+   *           .setBackupId("backupId2121930365")
+   *           .setSourceBackup(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
+   *           .setExpireTime(Timestamp.newBuilder().build())
+   *           .setEncryptionConfig(CopyBackupEncryptionConfig.newBuilder().build())
+   *           .build();
+   *   OperationFuture future =
+   *       databaseAdminClient.copyBackupOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Backup response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + copyBackupOperationCallable() { + return stub.copyBackupOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Starts copying a 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 copying of the backup. The operation is associated with the + * destination backup. The [metadata][google.longrunning.Operation.metadata] field type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. 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 copying and delete the backup. Concurrent CopyBackup requests can run + * on the same source backup. + * + *

Sample code: + * + *

{@code
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   CopyBackupRequest request =
+   *       CopyBackupRequest.newBuilder()
+   *           .setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
+   *           .setBackupId("backupId2121930365")
+   *           .setSourceBackup(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
+   *           .setExpireTime(Timestamp.newBuilder().build())
+   *           .setEncryptionConfig(CopyBackupEncryptionConfig.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = databaseAdminClient.copyBackupCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable copyBackupCallable() { + return stub.copyBackupCallable(); + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. 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 358be3bde42..5d924f60ed6 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 @@ -42,6 +42,8 @@ import com.google.longrunning.Operation; import com.google.protobuf.Empty; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.CopyBackupMetadata; +import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupRequest; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; @@ -174,6 +176,17 @@ public UnaryCallSettings createBackupSettings() return ((DatabaseAdminStubSettings) getStubSettings()).createBackupOperationSettings(); } + /** Returns the object with the settings used for calls to copyBackup. */ + public UnaryCallSettings copyBackupSettings() { + return ((DatabaseAdminStubSettings) getStubSettings()).copyBackupSettings(); + } + + /** Returns the object with the settings used for calls to copyBackup. */ + public OperationCallSettings + copyBackupOperationSettings() { + return ((DatabaseAdminStubSettings) getStubSettings()).copyBackupOperationSettings(); + } + /** Returns the object with the settings used for calls to getBackup. */ public UnaryCallSettings getBackupSettings() { return ((DatabaseAdminStubSettings) getStubSettings()).getBackupSettings(); @@ -394,6 +407,17 @@ public UnaryCallSettings.Builder createBackupSet return getStubSettingsBuilder().createBackupOperationSettings(); } + /** Returns the builder for the settings used for calls to copyBackup. */ + public UnaryCallSettings.Builder copyBackupSettings() { + return getStubSettingsBuilder().copyBackupSettings(); + } + + /** Returns the builder for the settings used for calls to copyBackup. */ + public OperationCallSettings.Builder + copyBackupOperationSettings() { + return getStubSettingsBuilder().copyBackupOperationSettings(); + } + /** Returns the builder for the settings used for calls to getBackup. */ public UnaryCallSettings.Builder getBackupSettings() { return getStubSettingsBuilder().getBackupSettings(); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/gapic_metadata.json b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/gapic_metadata.json index bb689f4c8d4..db77a349075 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/gapic_metadata.json +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/gapic_metadata.json @@ -10,6 +10,9 @@ "grpc": { "libraryClient": "DatabaseAdminClient", "rpcs": { + "CopyBackup": { + "methods": ["copyBackupAsync", "copyBackupAsync", "copyBackupAsync", "copyBackupAsync", "copyBackupAsync", "copyBackupOperationCallable", "copyBackupCallable"] + }, "CreateBackup": { "methods": ["createBackupAsync", "createBackupAsync", "createBackupAsync", "createBackupOperationCallable", "createBackupCallable"] }, 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 cf873601ef7..5572033a6ae 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 @@ -33,6 +33,8 @@ import com.google.longrunning.stub.OperationsStub; import com.google.protobuf.Empty; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.CopyBackupMetadata; +import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupRequest; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; @@ -134,6 +136,15 @@ public UnaryCallable createBackupCallable() { throw new UnsupportedOperationException("Not implemented: createBackupCallable()"); } + public OperationCallable + copyBackupOperationCallable() { + throw new UnsupportedOperationException("Not implemented: copyBackupOperationCallable()"); + } + + public UnaryCallable copyBackupCallable() { + throw new UnsupportedOperationException("Not implemented: copyBackupCallable()"); + } + public UnaryCallable getBackupCallable() { throw new UnsupportedOperationException("Not implemented: getBackupCallable()"); } 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 aea9b512a1c..992e5a79d2b 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 @@ -59,6 +59,8 @@ import com.google.longrunning.Operation; import com.google.protobuf.Empty; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.CopyBackupMetadata; +import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupRequest; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; @@ -149,6 +151,9 @@ public class DatabaseAdminStubSettings extends StubSettings createBackupSettings; private final OperationCallSettings createBackupOperationSettings; + private final UnaryCallSettings copyBackupSettings; + private final OperationCallSettings + copyBackupOperationSettings; private final UnaryCallSettings getBackupSettings; private final UnaryCallSettings updateBackupSettings; private final UnaryCallSettings deleteBackupSettings; @@ -473,6 +478,17 @@ public UnaryCallSettings createBackupSettings() return createBackupOperationSettings; } + /** Returns the object with the settings used for calls to copyBackup. */ + public UnaryCallSettings copyBackupSettings() { + return copyBackupSettings; + } + + /** Returns the object with the settings used for calls to copyBackup. */ + public OperationCallSettings + copyBackupOperationSettings() { + return copyBackupOperationSettings; + } + /** Returns the object with the settings used for calls to getBackup. */ public UnaryCallSettings getBackupSettings() { return getBackupSettings; @@ -613,6 +629,8 @@ protected DatabaseAdminStubSettings(Builder settingsBuilder) throws IOException testIamPermissionsSettings = settingsBuilder.testIamPermissionsSettings().build(); createBackupSettings = settingsBuilder.createBackupSettings().build(); createBackupOperationSettings = settingsBuilder.createBackupOperationSettings().build(); + copyBackupSettings = settingsBuilder.copyBackupSettings().build(); + copyBackupOperationSettings = settingsBuilder.copyBackupOperationSettings().build(); getBackupSettings = settingsBuilder.getBackupSettings().build(); updateBackupSettings = settingsBuilder.updateBackupSettings().build(); deleteBackupSettings = settingsBuilder.deleteBackupSettings().build(); @@ -650,6 +668,9 @@ public static class Builder extends StubSettings.Builder createBackupSettings; private final OperationCallSettings.Builder createBackupOperationSettings; + private final UnaryCallSettings.Builder copyBackupSettings; + private final OperationCallSettings.Builder + copyBackupOperationSettings; private final UnaryCallSettings.Builder getBackupSettings; private final UnaryCallSettings.Builder updateBackupSettings; private final UnaryCallSettings.Builder deleteBackupSettings; @@ -760,6 +781,8 @@ protected Builder(ClientContext clientContext) { testIamPermissionsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); createBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); createBackupOperationSettings = OperationCallSettings.newBuilder(); + copyBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + copyBackupOperationSettings = OperationCallSettings.newBuilder(); getBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); updateBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); deleteBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); @@ -783,6 +806,7 @@ protected Builder(ClientContext clientContext) { getIamPolicySettings, testIamPermissionsSettings, createBackupSettings, + copyBackupSettings, getBackupSettings, updateBackupSettings, deleteBackupSettings, @@ -809,6 +833,8 @@ protected Builder(DatabaseAdminStubSettings settings) { testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder(); createBackupSettings = settings.createBackupSettings.toBuilder(); createBackupOperationSettings = settings.createBackupOperationSettings.toBuilder(); + copyBackupSettings = settings.copyBackupSettings.toBuilder(); + copyBackupOperationSettings = settings.copyBackupOperationSettings.toBuilder(); getBackupSettings = settings.getBackupSettings.toBuilder(); updateBackupSettings = settings.updateBackupSettings.toBuilder(); deleteBackupSettings = settings.deleteBackupSettings.toBuilder(); @@ -830,6 +856,7 @@ protected Builder(DatabaseAdminStubSettings settings) { getIamPolicySettings, testIamPermissionsSettings, createBackupSettings, + copyBackupSettings, getBackupSettings, updateBackupSettings, deleteBackupSettings, @@ -903,6 +930,11 @@ private static Builder initDefaults(Builder builder) { .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params")); + builder + .copyBackupSettings() + .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("retry_policy_0_codes")) @@ -1011,6 +1043,29 @@ private static Builder initDefaults(Builder builder) { .setTotalTimeout(Duration.ofMillis(172800000L)) .build())); + builder + .copyBackupOperationSettings() + .setInitialCallSettings( + UnaryCallSettings.newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Backup.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(CopyBackupMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + builder .restoreDatabaseOperationSettings() .setInitialCallSettings( @@ -1132,6 +1187,19 @@ public UnaryCallSettings.Builder createBackupSet return createBackupOperationSettings; } + /** Returns the builder for the settings used for calls to copyBackup. */ + public UnaryCallSettings.Builder copyBackupSettings() { + return copyBackupSettings; + } + + /** Returns the builder for the settings used for calls to copyBackup. */ + @BetaApi( + "The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder + copyBackupOperationSettings() { + return copyBackupOperationSettings; + } + /** Returns the builder for the settings used for calls to getBackup. */ public UnaryCallSettings.Builder getBackupSettings() { return getBackupSettings; 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 46cdccdbbcc..0df16f344e9 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 @@ -38,6 +38,8 @@ import com.google.longrunning.stub.GrpcOperationsStub; import com.google.protobuf.Empty; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.CopyBackupMetadata; +import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupRequest; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; @@ -171,6 +173,14 @@ public class GrpcDatabaseAdminStub extends DatabaseAdminStub { .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); + private static final MethodDescriptor copyBackupMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/CopyBackup") + .setRequestMarshaller(ProtoUtils.marshaller(CopyBackupRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + private static final MethodDescriptor getBackupMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -260,6 +270,9 @@ public class GrpcDatabaseAdminStub extends DatabaseAdminStub { private final UnaryCallable createBackupCallable; private final OperationCallable createBackupOperationCallable; + private final UnaryCallable copyBackupCallable; + private final OperationCallable + copyBackupOperationCallable; private final UnaryCallable getBackupCallable; private final UnaryCallable updateBackupCallable; private final UnaryCallable deleteBackupCallable; @@ -422,6 +435,16 @@ protected GrpcDatabaseAdminStub( return params.build(); }) .build(); + GrpcCallSettings copyBackupTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(copyBackupMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + }) + .build(); GrpcCallSettings getBackupTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getBackupMethodDescriptor) @@ -551,6 +574,15 @@ protected GrpcDatabaseAdminStub( settings.createBackupOperationSettings(), clientContext, operationsStub); + this.copyBackupCallable = + callableFactory.createUnaryCallable( + copyBackupTransportSettings, settings.copyBackupSettings(), clientContext); + this.copyBackupOperationCallable = + callableFactory.createOperationCallable( + copyBackupTransportSettings, + settings.copyBackupOperationSettings(), + clientContext, + operationsStub); this.getBackupCallable = callableFactory.createUnaryCallable( getBackupTransportSettings, settings.getBackupSettings(), clientContext); @@ -679,6 +711,17 @@ public UnaryCallable createBackupCallable() { return createBackupOperationCallable; } + @Override + public UnaryCallable copyBackupCallable() { + return copyBackupCallable; + } + + @Override + public OperationCallable + copyBackupOperationCallable() { + return copyBackupOperationCallable; + } + @Override public UnaryCallable getBackupCallable() { return getBackupCallable; diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/encryption/EncryptionConfigProtoMapper.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/encryption/EncryptionConfigProtoMapper.java index 0a18e9844a1..62d51bf76ed 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/encryption/EncryptionConfigProtoMapper.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/encryption/EncryptionConfigProtoMapper.java @@ -16,6 +16,7 @@ package com.google.cloud.spanner.encryption; +import com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig; import com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig; import com.google.spanner.admin.database.v1.EncryptionConfig; import com.google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig; @@ -50,6 +51,28 @@ public static CreateBackupEncryptionConfig createBackupEncryptionConfig( } } + /** Returns an encryption config to be used for a copy backup. */ + public static CopyBackupEncryptionConfig copyBackupEncryptionConfig( + BackupEncryptionConfig config) { + if (config instanceof CustomerManagedEncryption) { + return CopyBackupEncryptionConfig.newBuilder() + .setEncryptionType(CopyBackupEncryptionConfig.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION) + .setKmsKeyName(((CustomerManagedEncryption) config).getKmsKeyName()) + .build(); + } else if (config instanceof GoogleDefaultEncryption) { + return CopyBackupEncryptionConfig.newBuilder() + .setEncryptionType(CopyBackupEncryptionConfig.EncryptionType.GOOGLE_DEFAULT_ENCRYPTION) + .build(); + } else if (config instanceof UseBackupEncryption) { + return CopyBackupEncryptionConfig.newBuilder() + .setEncryptionType( + CopyBackupEncryptionConfig.EncryptionType.USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION) + .build(); + } else { + throw new IllegalArgumentException("Unknown backup encryption configuration " + config); + } + } + /** Returns an encryption config to be used for a database restore. */ public static RestoreDatabaseEncryptionConfig restoreDatabaseEncryptionConfig( RestoreEncryptionConfig config) { diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java index 98a7e0927f3..b065d871076 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java @@ -60,6 +60,7 @@ import com.google.cloud.grpc.GcpManagedChannelOptions.GcpMetricsOptions; import com.google.cloud.grpc.GrpcTransportOptions; import com.google.cloud.spanner.AdminRequestsPerMinuteExceededException; +import com.google.cloud.spanner.BackupId; import com.google.cloud.spanner.ErrorCode; import com.google.cloud.spanner.Restore; import com.google.cloud.spanner.SpannerException; @@ -102,6 +103,8 @@ import com.google.protobuf.Message; import com.google.protobuf.Timestamp; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.CopyBackupMetadata; +import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupRequest; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; @@ -1264,6 +1267,65 @@ public OperationFuture createBackup( NanoClock.getDefaultClock()); } + @Override + public OperationFuture copyBackUp( + BackupId sourceBackupId, final com.google.cloud.spanner.Backup destinationBackup) + throws SpannerException { + Preconditions.checkNotNull(sourceBackupId); + Preconditions.checkNotNull(destinationBackup); + final String instanceName = destinationBackup.getInstanceId().getName(); + final String backupId = destinationBackup.getId().getBackup(); + + final CopyBackupRequest.Builder requestBuilder = + CopyBackupRequest.newBuilder() + .setParent(instanceName) + .setBackupId(backupId) + .setSourceBackup(sourceBackupId.getName()) + .setExpireTime(destinationBackup.getExpireTime().toProto()); + + if (destinationBackup.getEncryptionConfig() != null) { + requestBuilder.setEncryptionConfig( + EncryptionConfigProtoMapper.copyBackupEncryptionConfig( + destinationBackup.getEncryptionConfig())); + } + final CopyBackupRequest request = requestBuilder.build(); + final OperationFutureCallable callable = + new OperationFutureCallable<>( + databaseAdminStub.copyBackupOperationCallable(), + request, + // calling copy backup method of dbClientImpl + DatabaseAdminGrpc.getCopyBackupMethod(), + instanceName, + nextPageToken -> + listBackupOperations( + instanceName, + 0, + String.format( + "(metadata.@type:type.googleapis.com/%s) AND (metadata.name:%s)", + CopyBackupMetadata.getDescriptor().getFullName(), + String.format("%s/backups/%s", instanceName, backupId)), + nextPageToken), + input -> { + try { + return input + .getMetadata() + .unpack(CopyBackupMetadata.class) + .getProgress() + .getStartTime(); + } catch (InvalidProtocolBufferException e) { + return null; + } + }); + return RetryHelper.runWithRetries( + callable, + databaseAdminStubSettings + .copyBackupOperationSettings() + .getInitialCallSettings() + .getRetrySettings(), + new OperationFutureRetryAlgorithm<>(), + NanoClock.getDefaultClock()); + } + @Override public OperationFuture restoreDatabase(final Restore restore) { final String databaseInstanceName = restore.getDestination().getInstanceId().getName(); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java index cce92e0f378..0cfd4306f03 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java @@ -22,6 +22,7 @@ import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ServerStream; import com.google.cloud.ServiceRpc; +import com.google.cloud.spanner.BackupId; import com.google.cloud.spanner.Restore; import com.google.cloud.spanner.SpannerException; import com.google.cloud.spanner.admin.database.v1.stub.DatabaseAdminStub; @@ -33,6 +34,7 @@ import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.CopyBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; import com.google.spanner.admin.database.v1.Database; @@ -230,6 +232,19 @@ Paginated listBackups( OperationFuture createBackup( com.google.cloud.spanner.Backup backupInfo) throws SpannerException; + /** + * Creates a copy backup from the source backup specified. + * + * @param destinationBackup the backup to create. The instance, database, and expireTime fields of + * the backup must be filled. It may also optionally have an encryption config set. If no + * encryption config has been set, the new backup will use the same encryption config as the + * source backup. + * @return the operation that monitors the backup creation. + */ + OperationFuture copyBackUp( + BackupId sourceBackupId, com.google.cloud.spanner.Backup destinationBackup) + throws SpannerException; + /** * Restore a backup into the given database. * diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BackupTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BackupTest.java index 2f12790437c..cf8d09eabe6 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BackupTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BackupTest.java @@ -293,9 +293,11 @@ public void fromProto() { public void testEqualsAndHashCode() { final Backup backup1 = createBackup(); final Backup backup2 = createBackup(); + final Backup copyBackup1 = copyBackup(); assertEquals(backup1, backup2); assertEquals(backup1.hashCode(), backup2.hashCode()); + assertEquals(backup1.hashCode(), copyBackup1.hashCode()); } private Backup createBackup() { @@ -312,4 +314,19 @@ private Backup createBackup() { .build(); return Backup.fromProto(proto, dbClient); } + + private Backup copyBackup() { + com.google.spanner.admin.database.v1.Backup proto = + com.google.spanner.admin.database.v1.Backup.newBuilder() + .setName(NAME) + .setDatabase(DB) + .setExpireTime( + com.google.protobuf.Timestamp.newBuilder().setSeconds(1000L).setNanos(1000).build()) + .setVersionTime( + com.google.protobuf.Timestamp.newBuilder().setSeconds(2000L).setNanos(2000).build()) + .setEncryptionInfo(ENCRYPTION_INFO) + .setState(com.google.spanner.admin.database.v1.Backup.State.CREATING) + .build(); + return Backup.fromProto(proto, dbClient); + } } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseAdminClientImplTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseAdminClientImplTest.java index 44a531d4a34..a0c389360dc 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseAdminClientImplTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseAdminClientImplTest.java @@ -44,6 +44,7 @@ import com.google.protobuf.FieldMask; import com.google.protobuf.Message; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.CopyBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; import com.google.spanner.admin.database.v1.Database; @@ -72,6 +73,7 @@ public class DatabaseAdminClientImplTest { private static final String DB_NAME2 = "projects/my-project/instances/my-instance/databases/my-db2"; private static final String BK_ID = "my-bk"; + private static final String SOURCE_BK = "my-source-bk"; private static final String BK_NAME = "projects/my-project/instances/my-instance/backups/my-bk"; private static final String BK_NAME2 = "projects/my-project/instances/my-instance/backups/my-bk2"; private static final Timestamp EARLIEST_VERSION_TIME = Timestamp.now(); @@ -454,6 +456,81 @@ public void createEncryptedBackup() throws ExecutionException, InterruptedExcept assertThat(op.get().getEncryptionInfo().getKmsKeyVersion()).isEqualTo(KMS_KEY_VERSION); } + @Test + public void copyBackupWithParams() throws Exception { + OperationFuture rawOperationFuture = + OperationFutureUtil.immediateOperationFuture( + "copyBackup", getBackupProto(), CopyBackupMetadata.getDefaultInstance()); + Timestamp t = + Timestamp.ofTimeMicroseconds( + TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()) + + TimeUnit.HOURS.toMicros(28)); + final com.google.cloud.spanner.Backup backup = + client + .newBackupBuilder(BackupId.of(PROJECT_ID, INSTANCE_ID, BK_ID)) + .setExpireTime(t) + .build(); + when(rpc.copyBackUp(BackupId.of(PROJECT_ID, INSTANCE_ID, SOURCE_BK), backup)) + .thenReturn(rawOperationFuture); + OperationFuture op = + client.copyBackup(INSTANCE_ID, SOURCE_BK, BK_ID, t); + assertThat(op.isDone()).isTrue(); + assertThat(op.get().getId().getName()).isEqualTo(BK_NAME); + } + + @Test + public void copyBackupWithBackupObject() throws ExecutionException, InterruptedException { + final OperationFuture rawOperationFuture = + OperationFutureUtil.immediateOperationFuture( + "copyBackup", getBackupProto(), CopyBackupMetadata.getDefaultInstance()); + final Timestamp expireTime = + Timestamp.ofTimeMicroseconds( + TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()) + + TimeUnit.HOURS.toMicros(28)); + final Timestamp versionTime = + Timestamp.ofTimeMicroseconds( + TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()) - TimeUnit.DAYS.toMicros(2)); + final com.google.cloud.spanner.Backup requestBackup = + client + .newBackupBuilder(BackupId.of(PROJECT_ID, INSTANCE_ID, BK_ID)) + .setExpireTime(expireTime) + .setVersionTime(versionTime) + .build(); + BackupId sourceBackupId = BackupId.of(PROJECT_ID, INSTANCE_ID, BK_ID); + + when(rpc.copyBackUp(sourceBackupId, requestBackup)).thenReturn(rawOperationFuture); + + final OperationFuture op = + client.copyBackup(sourceBackupId, requestBackup); + assertThat(op.isDone()).isTrue(); + assertThat(op.get().getId().getName()).isEqualTo(BK_NAME); + } + + @Test + public void copyEncryptedBackup() throws ExecutionException, InterruptedException { + final OperationFuture rawOperationFuture = + OperationFutureUtil.immediateOperationFuture( + "copyBackup", getEncryptedBackupProto(), CopyBackupMetadata.getDefaultInstance()); + final Timestamp t = + Timestamp.ofTimeMicroseconds( + TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()) + + TimeUnit.HOURS.toMicros(28)); + final com.google.cloud.spanner.Backup backup = + client + .newBackupBuilder(BackupId.of(PROJECT_ID, INSTANCE_ID, BK_ID)) + .setDatabase(DatabaseId.of(PROJECT_ID, INSTANCE_ID, DB_ID)) + .setExpireTime(t) + .setEncryptionConfig(EncryptionConfigs.customerManagedEncryption(KMS_KEY_NAME)) + .build(); + BackupId sourceBackupId = BackupId.of(PROJECT_ID, INSTANCE_ID, BK_ID); + when(rpc.copyBackUp(sourceBackupId, backup)).thenReturn(rawOperationFuture); + final OperationFuture op = + client.copyBackup(sourceBackupId, backup); + assertThat(op.isDone()).isTrue(); + assertThat(op.get().getId().getName()).isEqualTo(BK_NAME); + assertThat(op.get().getEncryptionInfo().getKmsKeyVersion()).isEqualTo(KMS_KEY_VERSION); + } + @Test public void deleteBackup() { client.deleteBackup(INSTANCE_ID, BK_ID); 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 ef43a4b44c2..4f6d204035f 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 @@ -46,6 +46,7 @@ import com.google.protobuf.Timestamp; import com.google.spanner.admin.database.v1.Backup; import com.google.spanner.admin.database.v1.BackupName; +import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupRequest; import com.google.spanner.admin.database.v1.CreateDatabaseRequest; import com.google.spanner.admin.database.v1.Database; @@ -906,6 +907,8 @@ public void createBackupTest() throws Exception { .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) + .addAllReferencingBackups(new ArrayList()) + .setMaxExpireTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -966,6 +969,8 @@ public void createBackupTest2() throws Exception { .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) + .addAllReferencingBackups(new ArrayList()) + .setMaxExpireTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -1013,6 +1018,270 @@ public void createBackupExceptionTest2() throws Exception { } } + @Test + public void copyBackupTest() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString()) + .setVersionTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setSizeBytes(-1796325715) + .addAllReferencingDatabases(new ArrayList()) + .setEncryptionInfo(EncryptionInfo.newBuilder().build()) + .setDatabaseDialect(DatabaseDialect.forNumber(0)) + .addAllReferencingBackups(new ArrayList()) + .setMaxExpireTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("copyBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockDatabaseAdmin.addResponse(resultOperation); + + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + String backupId = "backupId2121930365"; + BackupName sourceBackup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]"); + Timestamp expireTime = Timestamp.newBuilder().build(); + + Backup actualResponse = + client.copyBackupAsync(parent, backupId, sourceBackup, expireTime).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CopyBackupRequest actualRequest = ((CopyBackupRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(backupId, actualRequest.getBackupId()); + Assert.assertEquals(sourceBackup.toString(), actualRequest.getSourceBackup()); + Assert.assertEquals(expireTime, actualRequest.getExpireTime()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void copyBackupExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + String backupId = "backupId2121930365"; + BackupName sourceBackup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]"); + Timestamp expireTime = Timestamp.newBuilder().build(); + client.copyBackupAsync(parent, backupId, sourceBackup, expireTime).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 + public void copyBackupTest2() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString()) + .setVersionTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setSizeBytes(-1796325715) + .addAllReferencingDatabases(new ArrayList()) + .setEncryptionInfo(EncryptionInfo.newBuilder().build()) + .setDatabaseDialect(DatabaseDialect.forNumber(0)) + .addAllReferencingBackups(new ArrayList()) + .setMaxExpireTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("copyBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockDatabaseAdmin.addResponse(resultOperation); + + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + String backupId = "backupId2121930365"; + String sourceBackup = "sourceBackup823134653"; + Timestamp expireTime = Timestamp.newBuilder().build(); + + Backup actualResponse = + client.copyBackupAsync(parent, backupId, sourceBackup, expireTime).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CopyBackupRequest actualRequest = ((CopyBackupRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(backupId, actualRequest.getBackupId()); + Assert.assertEquals(sourceBackup, actualRequest.getSourceBackup()); + Assert.assertEquals(expireTime, actualRequest.getExpireTime()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void copyBackupExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + String backupId = "backupId2121930365"; + String sourceBackup = "sourceBackup823134653"; + Timestamp expireTime = Timestamp.newBuilder().build(); + client.copyBackupAsync(parent, backupId, sourceBackup, expireTime).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 + public void copyBackupTest3() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString()) + .setVersionTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setSizeBytes(-1796325715) + .addAllReferencingDatabases(new ArrayList()) + .setEncryptionInfo(EncryptionInfo.newBuilder().build()) + .setDatabaseDialect(DatabaseDialect.forNumber(0)) + .addAllReferencingBackups(new ArrayList()) + .setMaxExpireTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("copyBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockDatabaseAdmin.addResponse(resultOperation); + + String parent = "parent-995424086"; + String backupId = "backupId2121930365"; + BackupName sourceBackup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]"); + Timestamp expireTime = Timestamp.newBuilder().build(); + + Backup actualResponse = + client.copyBackupAsync(parent, backupId, sourceBackup, expireTime).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CopyBackupRequest actualRequest = ((CopyBackupRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(backupId, actualRequest.getBackupId()); + Assert.assertEquals(sourceBackup.toString(), actualRequest.getSourceBackup()); + Assert.assertEquals(expireTime, actualRequest.getExpireTime()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void copyBackupExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + String backupId = "backupId2121930365"; + BackupName sourceBackup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]"); + Timestamp expireTime = Timestamp.newBuilder().build(); + client.copyBackupAsync(parent, backupId, sourceBackup, expireTime).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 + public void copyBackupTest4() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString()) + .setVersionTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setSizeBytes(-1796325715) + .addAllReferencingDatabases(new ArrayList()) + .setEncryptionInfo(EncryptionInfo.newBuilder().build()) + .setDatabaseDialect(DatabaseDialect.forNumber(0)) + .addAllReferencingBackups(new ArrayList()) + .setMaxExpireTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("copyBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockDatabaseAdmin.addResponse(resultOperation); + + String parent = "parent-995424086"; + String backupId = "backupId2121930365"; + String sourceBackup = "sourceBackup823134653"; + Timestamp expireTime = Timestamp.newBuilder().build(); + + Backup actualResponse = + client.copyBackupAsync(parent, backupId, sourceBackup, expireTime).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CopyBackupRequest actualRequest = ((CopyBackupRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(backupId, actualRequest.getBackupId()); + Assert.assertEquals(sourceBackup, actualRequest.getSourceBackup()); + Assert.assertEquals(expireTime, actualRequest.getExpireTime()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void copyBackupExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + String backupId = "backupId2121930365"; + String sourceBackup = "sourceBackup823134653"; + Timestamp expireTime = Timestamp.newBuilder().build(); + client.copyBackupAsync(parent, backupId, sourceBackup, expireTime).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 public void getBackupTest() throws Exception { Backup expectedResponse = @@ -1026,6 +1295,8 @@ public void getBackupTest() throws Exception { .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) + .addAllReferencingBackups(new ArrayList()) + .setMaxExpireTime(Timestamp.newBuilder().build()) .build(); mockDatabaseAdmin.addResponse(expectedResponse); @@ -1072,6 +1343,8 @@ public void getBackupTest2() throws Exception { .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) + .addAllReferencingBackups(new ArrayList()) + .setMaxExpireTime(Timestamp.newBuilder().build()) .build(); mockDatabaseAdmin.addResponse(expectedResponse); @@ -1118,6 +1391,8 @@ public void updateBackupTest() throws Exception { .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) + .addAllReferencingBackups(new ArrayList()) + .setMaxExpireTime(Timestamp.newBuilder().build()) .build(); mockDatabaseAdmin.addResponse(expectedResponse); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/MockDatabaseAdminImpl.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/MockDatabaseAdminImpl.java index a0b87516293..ce169fef29f 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/MockDatabaseAdminImpl.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/MockDatabaseAdminImpl.java @@ -26,6 +26,7 @@ import com.google.protobuf.AbstractMessage; import com.google.protobuf.Empty; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupRequest; import com.google.spanner.admin.database.v1.CreateDatabaseRequest; import com.google.spanner.admin.database.v1.Database; @@ -293,6 +294,26 @@ public void createBackup( } } + @Override + public void copyBackup(CopyBackupRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CopyBackup, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } + @Override public void getBackup(GetBackupRequest request, StreamObserver responseObserver) { Object response = responses.poll(); diff --git a/grpc-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseAdminGrpc.java b/grpc-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseAdminGrpc.java index 55afe37254c..184bc2de624 100644 --- a/grpc-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseAdminGrpc.java +++ b/grpc-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseAdminGrpc.java @@ -481,6 +481,49 @@ private DatabaseAdminGrpc() {} return getCreateBackupMethod; } + private static volatile io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.CopyBackupRequest, com.google.longrunning.Operation> + getCopyBackupMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "CopyBackup", + requestType = com.google.spanner.admin.database.v1.CopyBackupRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.CopyBackupRequest, com.google.longrunning.Operation> + getCopyBackupMethod() { + io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.CopyBackupRequest, + com.google.longrunning.Operation> + getCopyBackupMethod; + if ((getCopyBackupMethod = DatabaseAdminGrpc.getCopyBackupMethod) == null) { + synchronized (DatabaseAdminGrpc.class) { + if ((getCopyBackupMethod = DatabaseAdminGrpc.getCopyBackupMethod) == null) { + DatabaseAdminGrpc.getCopyBackupMethod = + getCopyBackupMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "CopyBackup")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.spanner.admin.database.v1.CopyBackupRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor(new DatabaseAdminMethodDescriptorSupplier("CopyBackup")) + .build(); + } + } + } + return getCopyBackupMethod; + } + private static volatile io.grpc.MethodDescriptor< com.google.spanner.admin.database.v1.GetBackupRequest, com.google.spanner.admin.database.v1.Backup> @@ -1054,6 +1097,30 @@ public void createBackup( getCreateBackupMethod(), responseObserver); } + /** + * + * + *
+     * Starts copying a 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 copying of the backup. The operation is associated
+     * with the destination backup.
+     * The [metadata][google.longrunning.Operation.metadata] field type is
+     * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata].
+     * 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
+     * copying and delete the backup.
+     * Concurrent CopyBackup requests can run on the same source backup.
+     * 
+ */ + public void copyBackup( + com.google.spanner.admin.database.v1.CopyBackupRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getCopyBackupMethod(), responseObserver); + } + /** * * @@ -1256,6 +1323,12 @@ public final io.grpc.ServerServiceDefinition bindService() { new MethodHandlers< com.google.spanner.admin.database.v1.CreateBackupRequest, com.google.longrunning.Operation>(this, METHODID_CREATE_BACKUP))) + .addMethod( + getCopyBackupMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.spanner.admin.database.v1.CopyBackupRequest, + com.google.longrunning.Operation>(this, METHODID_COPY_BACKUP))) .addMethod( getGetBackupMethod(), io.grpc.stub.ServerCalls.asyncUnaryCall( @@ -1541,6 +1614,31 @@ public void createBackup( responseObserver); } + /** + * + * + *
+     * Starts copying a 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 copying of the backup. The operation is associated
+     * with the destination backup.
+     * The [metadata][google.longrunning.Operation.metadata] field type is
+     * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata].
+     * 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
+     * copying and delete the backup.
+     * Concurrent CopyBackup requests can run on the same source backup.
+     * 
+ */ + public void copyBackup( + com.google.spanner.admin.database.v1.CopyBackupRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getCopyBackupMethod(), getCallOptions()), request, responseObserver); + } + /** * * @@ -1892,6 +1990,30 @@ public com.google.longrunning.Operation createBackup( getChannel(), getCreateBackupMethod(), getCallOptions(), request); } + /** + * + * + *
+     * Starts copying a 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 copying of the backup. The operation is associated
+     * with the destination backup.
+     * The [metadata][google.longrunning.Operation.metadata] field type is
+     * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata].
+     * 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
+     * copying and delete the backup.
+     * Concurrent CopyBackup requests can run on the same source backup.
+     * 
+ */ + public com.google.longrunning.Operation copyBackup( + com.google.spanner.admin.database.v1.CopyBackupRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCopyBackupMethod(), getCallOptions(), request); + } + /** * * @@ -2226,6 +2348,30 @@ protected DatabaseAdminFutureStub build( getChannel().newCall(getCreateBackupMethod(), getCallOptions()), request); } + /** + * + * + *
+     * Starts copying a 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 copying of the backup. The operation is associated
+     * with the destination backup.
+     * The [metadata][google.longrunning.Operation.metadata] field type is
+     * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata].
+     * 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
+     * copying and delete the backup.
+     * Concurrent CopyBackup requests can run on the same source backup.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + copyBackup(com.google.spanner.admin.database.v1.CopyBackupRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCopyBackupMethod(), getCallOptions()), request); + } + /** * * @@ -2369,13 +2515,14 @@ protected DatabaseAdminFutureStub build( private static final int METHODID_GET_IAM_POLICY = 7; private static final int METHODID_TEST_IAM_PERMISSIONS = 8; private static final int METHODID_CREATE_BACKUP = 9; - private static final int METHODID_GET_BACKUP = 10; - private static final int METHODID_UPDATE_BACKUP = 11; - private static final int METHODID_DELETE_BACKUP = 12; - private static final int METHODID_LIST_BACKUPS = 13; - private static final int METHODID_RESTORE_DATABASE = 14; - private static final int METHODID_LIST_DATABASE_OPERATIONS = 15; - private static final int METHODID_LIST_BACKUP_OPERATIONS = 16; + private static final int METHODID_COPY_BACKUP = 10; + private static final int METHODID_GET_BACKUP = 11; + private static final int METHODID_UPDATE_BACKUP = 12; + private static final int METHODID_DELETE_BACKUP = 13; + private static final int METHODID_LIST_BACKUPS = 14; + private static final int METHODID_RESTORE_DATABASE = 15; + private static final int METHODID_LIST_DATABASE_OPERATIONS = 16; + private static final int METHODID_LIST_BACKUP_OPERATIONS = 17; private static final class MethodHandlers implements io.grpc.stub.ServerCalls.UnaryMethod, @@ -2450,6 +2597,11 @@ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserv (com.google.spanner.admin.database.v1.CreateBackupRequest) request, (io.grpc.stub.StreamObserver) responseObserver); break; + case METHODID_COPY_BACKUP: + serviceImpl.copyBackup( + (com.google.spanner.admin.database.v1.CopyBackupRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; case METHODID_GET_BACKUP: serviceImpl.getBackup( (com.google.spanner.admin.database.v1.GetBackupRequest) request, @@ -2567,6 +2719,7 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() { .addMethod(getGetIamPolicyMethod()) .addMethod(getTestIamPermissionsMethod()) .addMethod(getCreateBackupMethod()) + .addMethod(getCopyBackupMethod()) .addMethod(getGetBackupMethod()) .addMethod(getUpdateBackupMethod()) .addMethod(getDeleteBackupMethod()) diff --git a/patch.patch b/patch.patch new file mode 100644 index 00000000000..e5a1256475c --- /dev/null +++ b/patch.patch @@ -0,0 +1,42 @@ +diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml +index f5d1351a..9ede6f23 100644 +--- a/samples/snippets/pom.xml ++++ b/samples/snippets/pom.xml +@@ -47,6 +47,11 @@ + 6.19.1-SNAPSHOT + + ++ ++ com.google.api.grpc ++ proto-google-cloud-spanner-admin-database-v1 ++ 6.19.1-SNAPSHOT ++ + + + io.opencensus +diff --git a/samples/snippets/src/main/java/com/example/spanner/SpannerSample.java b/samples/snippets/src/main/java/com/example/spanner/SpannerSample.java +index 2a4db98c..c44a012d 100644 +--- a/samples/snippets/src/main/java/com/example/spanner/SpannerSample.java ++++ b/samples/snippets/src/main/java/com/example/spanner/SpannerSample.java +@@ -1625,9 +1625,9 @@ public class SpannerSample { + Timestamp expireTime = Timestamp.ofTimeMicroseconds(TimeUnit.MICROSECONDS.convert( + System.currentTimeMillis() + TimeUnit.DAYS.toMillis(14), TimeUnit.MILLISECONDS)); + +- // Initiate the request which returns an OperationFuture. ++ // Initiate the requefst which returns an OperationFuture. + System.out.println("Copying backup [" + backup.getId() + "]..."); +- OperationFuture op = backup.copyBackup(); ++ OperationFuture op = dbAdminClient.copyBackup(backup); + try { + // Wait for the backup operation to complete. + backup = op.get(); +@@ -1886,7 +1886,8 @@ public class SpannerSample { + TimeUnit.SECONDS.toMicros(backup.getExpireTime().getSeconds()) + + TimeUnit.NANOSECONDS.toMicros(backup.getExpireTime().getNanos()) + + TimeUnit.DAYS.toMicros(30L)); +- Timestamp newExpireTime = Math.min(expireTime, backup.getExpireTime()); ++ int timeDiff = expireTime.compareTo(backup.getExpireTime()); ++ Timestamp newExpireTime = (timeDiff < 0) ? expireTime : backup.getExpireTime(); + + System.out.println(String.format( + "Updating expire time of backup [%s] to %s...", diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/Backup.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/Backup.java index 3a974718685..ff197cea3fb 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/Backup.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/Backup.java @@ -43,6 +43,7 @@ private Backup() { state_ = 0; referencingDatabases_ = com.google.protobuf.LazyStringArrayList.EMPTY; databaseDialect_ = 0; + referencingBackups_ = com.google.protobuf.LazyStringArrayList.EMPTY; } @java.lang.Override @@ -178,6 +179,31 @@ private Backup( int rawValue = input.readEnum(); databaseDialect_ = rawValue; + break; + } + case 90: + { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000002) != 0)) { + referencingBackups_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000002; + } + referencingBackups_.add(s); + break; + } + case 98: + { + com.google.protobuf.Timestamp.Builder subBuilder = null; + if (maxExpireTime_ != null) { + subBuilder = maxExpireTime_.toBuilder(); + } + maxExpireTime_ = + input.readMessage(com.google.protobuf.Timestamp.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(maxExpireTime_); + maxExpireTime_ = subBuilder.buildPartial(); + } + break; } default: @@ -197,6 +223,9 @@ private Backup( if (((mutable_bitField0_ & 0x00000001) != 0)) { referencingDatabases_ = referencingDatabases_.getUnmodifiableView(); } + if (((mutable_bitField0_ & 0x00000002) != 0)) { + referencingBackups_ = referencingBackups_.getUnmodifiableView(); + } this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); } @@ -920,6 +949,165 @@ public com.google.spanner.admin.database.v1.DatabaseDialect getDatabaseDialect() : result; } + public static final int REFERENCING_BACKUPS_FIELD_NUMBER = 11; + private com.google.protobuf.LazyStringList referencingBackups_; + /** + * + * + *
+   * Output only. The names of the destination backups being created by copying
+   * this source backup. The backup names are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * Referencing backups may exist in different instances. The existence of
+   * any referencing backup prevents the backup from being deleted. When the
+   * copy operation is done (either successfully completed or cancelled or the
+   * destination backup is deleted), the reference to the backup is removed.
+   * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return A list containing the referencingBackups. + */ + public com.google.protobuf.ProtocolStringList getReferencingBackupsList() { + return referencingBackups_; + } + /** + * + * + *
+   * Output only. The names of the destination backups being created by copying
+   * this source backup. The backup names are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * Referencing backups may exist in different instances. The existence of
+   * any referencing backup prevents the backup from being deleted. When the
+   * copy operation is done (either successfully completed or cancelled or the
+   * destination backup is deleted), the reference to the backup is removed.
+   * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The count of referencingBackups. + */ + public int getReferencingBackupsCount() { + return referencingBackups_.size(); + } + /** + * + * + *
+   * Output only. The names of the destination backups being created by copying
+   * this source backup. The backup names are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * Referencing backups may exist in different instances. The existence of
+   * any referencing backup prevents the backup from being deleted. When the
+   * copy operation is done (either successfully completed or cancelled or the
+   * destination backup is deleted), the reference to the backup is removed.
+   * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param index The index of the element to return. + * @return The referencingBackups at the given index. + */ + public java.lang.String getReferencingBackups(int index) { + return referencingBackups_.get(index); + } + /** + * + * + *
+   * Output only. The names of the destination backups being created by copying
+   * this source backup. The backup names are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * Referencing backups may exist in different instances. The existence of
+   * any referencing backup prevents the backup from being deleted. When the
+   * copy operation is done (either successfully completed or cancelled or the
+   * destination backup is deleted), the reference to the backup is removed.
+   * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param index The index of the value to return. + * @return The bytes of the referencingBackups at the given index. + */ + public com.google.protobuf.ByteString getReferencingBackupsBytes(int index) { + return referencingBackups_.getByteString(index); + } + + public static final int MAX_EXPIRE_TIME_FIELD_NUMBER = 12; + private com.google.protobuf.Timestamp maxExpireTime_; + /** + * + * + *
+   * Output only. The max allowed expiration time of the backup, with
+   * microseconds granularity. A backup's expiration time can be configured in
+   * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+   * copying an existing backup, the expiration time specified must be
+   * less than `Backup.max_expire_time`.
+   * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the maxExpireTime field is set. + */ + @java.lang.Override + public boolean hasMaxExpireTime() { + return maxExpireTime_ != null; + } + /** + * + * + *
+   * Output only. The max allowed expiration time of the backup, with
+   * microseconds granularity. A backup's expiration time can be configured in
+   * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+   * copying an existing backup, the expiration time specified must be
+   * less than `Backup.max_expire_time`.
+   * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The maxExpireTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getMaxExpireTime() { + return maxExpireTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : maxExpireTime_; + } + /** + * + * + *
+   * Output only. The max allowed expiration time of the backup, with
+   * microseconds granularity. A backup's expiration time can be configured in
+   * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+   * copying an existing backup, the expiration time specified must be
+   * less than `Backup.max_expire_time`.
+   * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getMaxExpireTimeOrBuilder() { + return getMaxExpireTime(); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -967,6 +1155,12 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io .getNumber()) { output.writeEnum(10, databaseDialect_); } + for (int i = 0; i < referencingBackups_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 11, referencingBackups_.getRaw(i)); + } + if (maxExpireTime_ != null) { + output.writeMessage(12, getMaxExpireTime()); + } unknownFields.writeTo(output); } @@ -1013,6 +1207,17 @@ public int getSerializedSize() { .getNumber()) { size += com.google.protobuf.CodedOutputStream.computeEnumSize(10, databaseDialect_); } + { + int dataSize = 0; + for (int i = 0; i < referencingBackups_.size(); i++) { + dataSize += computeStringSizeNoTag(referencingBackups_.getRaw(i)); + } + size += dataSize; + size += 1 * getReferencingBackupsList().size(); + } + if (maxExpireTime_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(12, getMaxExpireTime()); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -1051,6 +1256,11 @@ public boolean equals(final java.lang.Object obj) { if (!getEncryptionInfo().equals(other.getEncryptionInfo())) return false; } if (databaseDialect_ != other.databaseDialect_) return false; + if (!getReferencingBackupsList().equals(other.getReferencingBackupsList())) return false; + if (hasMaxExpireTime() != other.hasMaxExpireTime()) return false; + if (hasMaxExpireTime()) { + if (!getMaxExpireTime().equals(other.getMaxExpireTime())) return false; + } if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -1092,6 +1302,14 @@ public int hashCode() { } hash = (37 * hash) + DATABASE_DIALECT_FIELD_NUMBER; hash = (53 * hash) + databaseDialect_; + if (getReferencingBackupsCount() > 0) { + hash = (37 * hash) + REFERENCING_BACKUPS_FIELD_NUMBER; + hash = (53 * hash) + getReferencingBackupsList().hashCode(); + } + if (hasMaxExpireTime()) { + hash = (37 * hash) + MAX_EXPIRE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getMaxExpireTime().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -1273,6 +1491,14 @@ public Builder clear() { } databaseDialect_ = 0; + referencingBackups_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + if (maxExpireTimeBuilder_ == null) { + maxExpireTime_ = null; + } else { + maxExpireTime_ = null; + maxExpireTimeBuilder_ = null; + } return this; } @@ -1331,6 +1557,16 @@ public com.google.spanner.admin.database.v1.Backup buildPartial() { result.encryptionInfo_ = encryptionInfoBuilder_.build(); } result.databaseDialect_ = databaseDialect_; + if (((bitField0_ & 0x00000002) != 0)) { + referencingBackups_ = referencingBackups_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.referencingBackups_ = referencingBackups_; + if (maxExpireTimeBuilder_ == null) { + result.maxExpireTime_ = maxExpireTime_; + } else { + result.maxExpireTime_ = maxExpireTimeBuilder_.build(); + } onBuilt(); return result; } @@ -1419,6 +1655,19 @@ public Builder mergeFrom(com.google.spanner.admin.database.v1.Backup other) { if (other.databaseDialect_ != 0) { setDatabaseDialectValue(other.getDatabaseDialectValue()); } + if (!other.referencingBackups_.isEmpty()) { + if (referencingBackups_.isEmpty()) { + referencingBackups_ = other.referencingBackups_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureReferencingBackupsIsMutable(); + referencingBackups_.addAll(other.referencingBackups_); + } + onChanged(); + } + if (other.hasMaxExpireTime()) { + mergeMaxExpireTime(other.getMaxExpireTime()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -3094,6 +3343,485 @@ public Builder clearDatabaseDialect() { return this; } + private com.google.protobuf.LazyStringList referencingBackups_ = + com.google.protobuf.LazyStringArrayList.EMPTY; + + private void ensureReferencingBackupsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + referencingBackups_ = new com.google.protobuf.LazyStringArrayList(referencingBackups_); + bitField0_ |= 0x00000002; + } + } + /** + * + * + *
+     * Output only. The names of the destination backups being created by copying
+     * this source backup. The backup names are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * Referencing backups may exist in different instances. The existence of
+     * any referencing backup prevents the backup from being deleted. When the
+     * copy operation is done (either successfully completed or cancelled or the
+     * destination backup is deleted), the reference to the backup is removed.
+     * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return A list containing the referencingBackups. + */ + public com.google.protobuf.ProtocolStringList getReferencingBackupsList() { + return referencingBackups_.getUnmodifiableView(); + } + /** + * + * + *
+     * Output only. The names of the destination backups being created by copying
+     * this source backup. The backup names are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * Referencing backups may exist in different instances. The existence of
+     * any referencing backup prevents the backup from being deleted. When the
+     * copy operation is done (either successfully completed or cancelled or the
+     * destination backup is deleted), the reference to the backup is removed.
+     * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The count of referencingBackups. + */ + public int getReferencingBackupsCount() { + return referencingBackups_.size(); + } + /** + * + * + *
+     * Output only. The names of the destination backups being created by copying
+     * this source backup. The backup names are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * Referencing backups may exist in different instances. The existence of
+     * any referencing backup prevents the backup from being deleted. When the
+     * copy operation is done (either successfully completed or cancelled or the
+     * destination backup is deleted), the reference to the backup is removed.
+     * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param index The index of the element to return. + * @return The referencingBackups at the given index. + */ + public java.lang.String getReferencingBackups(int index) { + return referencingBackups_.get(index); + } + /** + * + * + *
+     * Output only. The names of the destination backups being created by copying
+     * this source backup. The backup names are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * Referencing backups may exist in different instances. The existence of
+     * any referencing backup prevents the backup from being deleted. When the
+     * copy operation is done (either successfully completed or cancelled or the
+     * destination backup is deleted), the reference to the backup is removed.
+     * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param index The index of the value to return. + * @return The bytes of the referencingBackups at the given index. + */ + public com.google.protobuf.ByteString getReferencingBackupsBytes(int index) { + return referencingBackups_.getByteString(index); + } + /** + * + * + *
+     * Output only. The names of the destination backups being created by copying
+     * this source backup. The backup names are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * Referencing backups may exist in different instances. The existence of
+     * any referencing backup prevents the backup from being deleted. When the
+     * copy operation is done (either successfully completed or cancelled or the
+     * destination backup is deleted), the reference to the backup is removed.
+     * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param index The index to set the value at. + * @param value The referencingBackups to set. + * @return This builder for chaining. + */ + public Builder setReferencingBackups(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureReferencingBackupsIsMutable(); + referencingBackups_.set(index, value); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The names of the destination backups being created by copying
+     * this source backup. The backup names are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * Referencing backups may exist in different instances. The existence of
+     * any referencing backup prevents the backup from being deleted. When the
+     * copy operation is done (either successfully completed or cancelled or the
+     * destination backup is deleted), the reference to the backup is removed.
+     * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param value The referencingBackups to add. + * @return This builder for chaining. + */ + public Builder addReferencingBackups(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureReferencingBackupsIsMutable(); + referencingBackups_.add(value); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The names of the destination backups being created by copying
+     * this source backup. The backup names are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * Referencing backups may exist in different instances. The existence of
+     * any referencing backup prevents the backup from being deleted. When the
+     * copy operation is done (either successfully completed or cancelled or the
+     * destination backup is deleted), the reference to the backup is removed.
+     * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param values The referencingBackups to add. + * @return This builder for chaining. + */ + public Builder addAllReferencingBackups(java.lang.Iterable values) { + ensureReferencingBackupsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, referencingBackups_); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The names of the destination backups being created by copying
+     * this source backup. The backup names are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * Referencing backups may exist in different instances. The existence of
+     * any referencing backup prevents the backup from being deleted. When the
+     * copy operation is done (either successfully completed or cancelled or the
+     * destination backup is deleted), the reference to the backup is removed.
+     * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearReferencingBackups() { + referencingBackups_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The names of the destination backups being created by copying
+     * this source backup. The backup names are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * Referencing backups may exist in different instances. The existence of
+     * any referencing backup prevents the backup from being deleted. When the
+     * copy operation is done (either successfully completed or cancelled or the
+     * destination backup is deleted), the reference to the backup is removed.
+     * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes of the referencingBackups to add. + * @return This builder for chaining. + */ + public Builder addReferencingBackupsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureReferencingBackupsIsMutable(); + referencingBackups_.add(value); + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp maxExpireTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + maxExpireTimeBuilder_; + /** + * + * + *
+     * Output only. The max allowed expiration time of the backup, with
+     * microseconds granularity. A backup's expiration time can be configured in
+     * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+     * copying an existing backup, the expiration time specified must be
+     * less than `Backup.max_expire_time`.
+     * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the maxExpireTime field is set. + */ + public boolean hasMaxExpireTime() { + return maxExpireTimeBuilder_ != null || maxExpireTime_ != null; + } + /** + * + * + *
+     * Output only. The max allowed expiration time of the backup, with
+     * microseconds granularity. A backup's expiration time can be configured in
+     * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+     * copying an existing backup, the expiration time specified must be
+     * less than `Backup.max_expire_time`.
+     * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The maxExpireTime. + */ + public com.google.protobuf.Timestamp getMaxExpireTime() { + if (maxExpireTimeBuilder_ == null) { + return maxExpireTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : maxExpireTime_; + } else { + return maxExpireTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. The max allowed expiration time of the backup, with
+     * microseconds granularity. A backup's expiration time can be configured in
+     * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+     * copying an existing backup, the expiration time specified must be
+     * less than `Backup.max_expire_time`.
+     * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setMaxExpireTime(com.google.protobuf.Timestamp value) { + if (maxExpireTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + maxExpireTime_ = value; + onChanged(); + } else { + maxExpireTimeBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Output only. The max allowed expiration time of the backup, with
+     * microseconds granularity. A backup's expiration time can be configured in
+     * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+     * copying an existing backup, the expiration time specified must be
+     * less than `Backup.max_expire_time`.
+     * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setMaxExpireTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (maxExpireTimeBuilder_ == null) { + maxExpireTime_ = builderForValue.build(); + onChanged(); + } else { + maxExpireTimeBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Output only. The max allowed expiration time of the backup, with
+     * microseconds granularity. A backup's expiration time can be configured in
+     * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+     * copying an existing backup, the expiration time specified must be
+     * less than `Backup.max_expire_time`.
+     * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeMaxExpireTime(com.google.protobuf.Timestamp value) { + if (maxExpireTimeBuilder_ == null) { + if (maxExpireTime_ != null) { + maxExpireTime_ = + com.google.protobuf.Timestamp.newBuilder(maxExpireTime_) + .mergeFrom(value) + .buildPartial(); + } else { + maxExpireTime_ = value; + } + onChanged(); + } else { + maxExpireTimeBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Output only. The max allowed expiration time of the backup, with
+     * microseconds granularity. A backup's expiration time can be configured in
+     * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+     * copying an existing backup, the expiration time specified must be
+     * less than `Backup.max_expire_time`.
+     * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearMaxExpireTime() { + if (maxExpireTimeBuilder_ == null) { + maxExpireTime_ = null; + onChanged(); + } else { + maxExpireTime_ = null; + maxExpireTimeBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Output only. The max allowed expiration time of the backup, with
+     * microseconds granularity. A backup's expiration time can be configured in
+     * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+     * copying an existing backup, the expiration time specified must be
+     * less than `Backup.max_expire_time`.
+     * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getMaxExpireTimeBuilder() { + + onChanged(); + return getMaxExpireTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. The max allowed expiration time of the backup, with
+     * microseconds granularity. A backup's expiration time can be configured in
+     * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+     * copying an existing backup, the expiration time specified must be
+     * less than `Backup.max_expire_time`.
+     * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getMaxExpireTimeOrBuilder() { + if (maxExpireTimeBuilder_ != null) { + return maxExpireTimeBuilder_.getMessageOrBuilder(); + } else { + return maxExpireTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : maxExpireTime_; + } + } + /** + * + * + *
+     * Output only. The max allowed expiration time of the backup, with
+     * microseconds granularity. A backup's expiration time can be configured in
+     * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+     * copying an existing backup, the expiration time specified must be
+     * less than `Backup.max_expire_time`.
+     * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getMaxExpireTimeFieldBuilder() { + if (maxExpireTimeBuilder_ == null) { + maxExpireTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getMaxExpireTime(), getParentForChildren(), isClean()); + maxExpireTime_ = null; + } + return maxExpireTimeBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupOrBuilder.java index 8810b28ee0c..e3fe5ccf08c 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupOrBuilder.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupOrBuilder.java @@ -433,4 +433,140 @@ public interface BackupOrBuilder * @return The databaseDialect. */ com.google.spanner.admin.database.v1.DatabaseDialect getDatabaseDialect(); + + /** + * + * + *
+   * Output only. The names of the destination backups being created by copying
+   * this source backup. The backup names are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * Referencing backups may exist in different instances. The existence of
+   * any referencing backup prevents the backup from being deleted. When the
+   * copy operation is done (either successfully completed or cancelled or the
+   * destination backup is deleted), the reference to the backup is removed.
+   * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return A list containing the referencingBackups. + */ + java.util.List getReferencingBackupsList(); + /** + * + * + *
+   * Output only. The names of the destination backups being created by copying
+   * this source backup. The backup names are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * Referencing backups may exist in different instances. The existence of
+   * any referencing backup prevents the backup from being deleted. When the
+   * copy operation is done (either successfully completed or cancelled or the
+   * destination backup is deleted), the reference to the backup is removed.
+   * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The count of referencingBackups. + */ + int getReferencingBackupsCount(); + /** + * + * + *
+   * Output only. The names of the destination backups being created by copying
+   * this source backup. The backup names are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * Referencing backups may exist in different instances. The existence of
+   * any referencing backup prevents the backup from being deleted. When the
+   * copy operation is done (either successfully completed or cancelled or the
+   * destination backup is deleted), the reference to the backup is removed.
+   * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param index The index of the element to return. + * @return The referencingBackups at the given index. + */ + java.lang.String getReferencingBackups(int index); + /** + * + * + *
+   * Output only. The names of the destination backups being created by copying
+   * this source backup. The backup names are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * Referencing backups may exist in different instances. The existence of
+   * any referencing backup prevents the backup from being deleted. When the
+   * copy operation is done (either successfully completed or cancelled or the
+   * destination backup is deleted), the reference to the backup is removed.
+   * 
+ * + * + * repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param index The index of the value to return. + * @return The bytes of the referencingBackups at the given index. + */ + com.google.protobuf.ByteString getReferencingBackupsBytes(int index); + + /** + * + * + *
+   * Output only. The max allowed expiration time of the backup, with
+   * microseconds granularity. A backup's expiration time can be configured in
+   * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+   * copying an existing backup, the expiration time specified must be
+   * less than `Backup.max_expire_time`.
+   * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the maxExpireTime field is set. + */ + boolean hasMaxExpireTime(); + /** + * + * + *
+   * Output only. The max allowed expiration time of the backup, with
+   * microseconds granularity. A backup's expiration time can be configured in
+   * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+   * copying an existing backup, the expiration time specified must be
+   * less than `Backup.max_expire_time`.
+   * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The maxExpireTime. + */ + com.google.protobuf.Timestamp getMaxExpireTime(); + /** + * + * + *
+   * Output only. The max allowed expiration time of the backup, with
+   * microseconds granularity. A backup's expiration time can be configured in
+   * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
+   * copying an existing backup, the expiration time specified must be
+   * less than `Backup.max_expire_time`.
+   * 
+ * + * + * .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getMaxExpireTimeOrBuilder(); } 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 aafa5c2fc9b..82e4021aff2 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 @@ -39,6 +39,14 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_spanner_admin_database_v1_CreateBackupMetadata_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_spanner_admin_database_v1_CreateBackupMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_spanner_admin_database_v1_CopyBackupRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_CopyBackupRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_spanner_admin_database_v1_CopyBackupMetadata_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_CopyBackupMetadata_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_google_spanner_admin_database_v1_UpdateBackupRequest_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable @@ -75,6 +83,10 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_spanner_admin_database_v1_CreateBackupEncryptionConfig_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_spanner_admin_database_v1_CreateBackupEncryptionConfig_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_spanner_admin_database_v1_CopyBackupEncryptionConfig_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_CopyBackupEncryptionConfig_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { return descriptor; @@ -92,7 +104,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "ns.proto\032 google/protobuf/field_mask.pro" + "to\032\037google/protobuf/timestamp.proto\032-goo" + "gle/spanner/admin/database/v1/common.pro" - + "to\"\305\005\n\006Backup\0226\n\010database\030\002 \001(\tB$\372A!\n\037sp" + + "to\"\303\006\n\006Backup\0226\n\010database\030\002 \001(\tB$\372A!\n\037sp" + "anner.googleapis.com/Database\0220\n\014version" + "_time\030\t \001(\0132\032.google.protobuf.Timestamp\022" + "/\n\013expire_time\030\003 \001(\0132\032.google.protobuf.T" @@ -106,64 +118,90 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "ner.admin.database.v1.EncryptionInfoB\003\340A" + "\003\022P\n\020database_dialect\030\n \001(\01621.google.spa" + "nner.admin.database.v1.DatabaseDialectB\003" - + "\340A\003\"7\n\005State\022\025\n\021STATE_UNSPECIFIED\020\000\022\014\n\010C" - + "REATING\020\001\022\t\n\005READY\020\002:\\\352AY\n\035spanner.googl" - + "eapis.com/Backup\0228projects/{project}/ins" - + "tances/{instance}/backups/{backup}\"\205\002\n\023C" - + "reateBackupRequest\0227\n\006parent\030\001 \001(\tB\'\340A\002\372" - + "A!\n\037spanner.googleapis.com/Instance\022\026\n\tb" - + "ackup_id\030\002 \001(\tB\003\340A\002\022=\n\006backup\030\003 \001(\0132(.go" - + "ogle.spanner.admin.database.v1.BackupB\003\340" - + "A\002\022^\n\021encryption_config\030\004 \001(\0132>.google.s" - + "panner.admin.database.v1.CreateBackupEnc" - + "ryptionConfigB\003\340A\001\"\370\001\n\024CreateBackupMetad" - + "ata\0220\n\004name\030\001 \001(\tB\"\372A\037\n\035spanner.googleap" - + "is.com/Backup\0226\n\010database\030\002 \001(\tB$\372A!\n\037sp" - + "anner.googleapis.com/Database\022E\n\010progres" - + "s\030\003 \001(\01323.google.spanner.admin.database." - + "v1.OperationProgress\022/\n\013cancel_time\030\004 \001(" - + "\0132\032.google.protobuf.Timestamp\"\212\001\n\023Update" - + "BackupRequest\022=\n\006backup\030\001 \001(\0132(.google.s" - + "panner.admin.database.v1.BackupB\003\340A\002\0224\n\013" - + "update_mask\030\002 \001(\0132\032.google.protobuf.Fiel" - + "dMaskB\003\340A\002\"G\n\020GetBackupRequest\0223\n\004name\030\001" - + " \001(\tB%\340A\002\372A\037\n\035spanner.googleapis.com/Bac" - + "kup\"J\n\023DeleteBackupRequest\0223\n\004name\030\001 \001(\t" - + "B%\340A\002\372A\037\n\035spanner.googleapis.com/Backup\"" - + "\204\001\n\022ListBackupsRequest\0227\n\006parent\030\001 \001(\tB\'" - + "\340A\002\372A!\n\037spanner.googleapis.com/Instance\022" - + "\016\n\006filter\030\002 \001(\t\022\021\n\tpage_size\030\003 \001(\005\022\022\n\npa" - + "ge_token\030\004 \001(\t\"i\n\023ListBackupsResponse\0229\n" - + "\007backups\030\001 \003(\0132(.google.spanner.admin.da" - + "tabase.v1.Backup\022\027\n\017next_page_token\030\002 \001(" - + "\t\"\215\001\n\033ListBackupOperationsRequest\0227\n\006par" + + "\340A\003\022B\n\023referencing_backups\030\013 \003(\tB%\340A\003\372A\037" + + "\n\035spanner.googleapis.com/Backup\0228\n\017max_e" + + "xpire_time\030\014 \001(\0132\032.google.protobuf.Times" + + "tampB\003\340A\003\"7\n\005State\022\025\n\021STATE_UNSPECIFIED\020" + + "\000\022\014\n\010CREATING\020\001\022\t\n\005READY\020\002:\\\352AY\n\035spanner" + + ".googleapis.com/Backup\0228projects/{projec" + + "t}/instances/{instance}/backups/{backup}" + + "\"\205\002\n\023CreateBackupRequest\0227\n\006parent\030\001 \001(\t" + + "B\'\340A\002\372A!\n\037spanner.googleapis.com/Instanc" + + "e\022\026\n\tbackup_id\030\002 \001(\tB\003\340A\002\022=\n\006backup\030\003 \001(" + + "\0132(.google.spanner.admin.database.v1.Bac" + + "kupB\003\340A\002\022^\n\021encryption_config\030\004 \001(\0132>.go" + + "ogle.spanner.admin.database.v1.CreateBac" + + "kupEncryptionConfigB\003\340A\001\"\370\001\n\024CreateBacku" + + "pMetadata\0220\n\004name\030\001 \001(\tB\"\372A\037\n\035spanner.go" + + "ogleapis.com/Backup\0226\n\010database\030\002 \001(\tB$\372" + + "A!\n\037spanner.googleapis.com/Database\022E\n\010p" + + "rogress\030\003 \001(\01323.google.spanner.admin.dat" + + "abase.v1.OperationProgress\022/\n\013cancel_tim" + + "e\030\004 \001(\0132\032.google.protobuf.Timestamp\"\266\002\n\021" + + "CopyBackupRequest\0227\n\006parent\030\001 \001(\tB\'\340A\002\372A" + + "!\n\037spanner.googleapis.com/Instance\022\026\n\tba" + + "ckup_id\030\002 \001(\tB\003\340A\002\022<\n\rsource_backup\030\003 \001(" + + "\tB%\340A\002\372A\037\n\035spanner.googleapis.com/Backup" + + "\0224\n\013expire_time\030\004 \001(\0132\032.google.protobuf." + + "TimestampB\003\340A\002\022\\\n\021encryption_config\030\005 \001(" + + "\0132<.google.spanner.admin.database.v1.Cop" + + "yBackupEncryptionConfigB\003\340A\001\"\371\001\n\022CopyBac" + + "kupMetadata\0220\n\004name\030\001 \001(\tB\"\372A\037\n\035spanner." + + "googleapis.com/Backup\0229\n\rsource_backup\030\002" + + " \001(\tB\"\372A\037\n\035spanner.googleapis.com/Backup" + + "\022E\n\010progress\030\003 \001(\01323.google.spanner.admi" + + "n.database.v1.OperationProgress\022/\n\013cance" + + "l_time\030\004 \001(\0132\032.google.protobuf.Timestamp" + + "\"\212\001\n\023UpdateBackupRequest\022=\n\006backup\030\001 \001(\013" + + "2(.google.spanner.admin.database.v1.Back" + + "upB\003\340A\002\0224\n\013update_mask\030\002 \001(\0132\032.google.pr" + + "otobuf.FieldMaskB\003\340A\002\"G\n\020GetBackupReques" + + "t\0223\n\004name\030\001 \001(\tB%\340A\002\372A\037\n\035spanner.googlea" + + "pis.com/Backup\"J\n\023DeleteBackupRequest\0223\n" + + "\004name\030\001 \001(\tB%\340A\002\372A\037\n\035spanner.googleapis." + + "com/Backup\"\204\001\n\022ListBackupsRequest\0227\n\006par" + "ent\030\001 \001(\tB\'\340A\002\372A!\n\037spanner.googleapis.co" + "m/Instance\022\016\n\006filter\030\002 \001(\t\022\021\n\tpage_size\030" - + "\003 \001(\005\022\022\n\npage_token\030\004 \001(\t\"j\n\034ListBackupO" - + "perationsResponse\0221\n\noperations\030\001 \003(\0132\035." - + "google.longrunning.Operation\022\027\n\017next_pag" - + "e_token\030\002 \001(\t\"\342\001\n\nBackupInfo\0222\n\006backup\030\001" - + " \001(\tB\"\372A\037\n\035spanner.googleapis.com/Backup" - + "\0220\n\014version_time\030\004 \001(\0132\032.google.protobuf" - + ".Timestamp\022/\n\013create_time\030\002 \001(\0132\032.google" - + ".protobuf.Timestamp\022=\n\017source_database\030\003" - + " \001(\tB$\372A!\n\037spanner.googleapis.com/Databa" - + "se\"\335\002\n\034CreateBackupEncryptionConfig\022k\n\017e" - + "ncryption_type\030\001 \001(\0162M.google.spanner.ad" - + "min.database.v1.CreateBackupEncryptionCo" - + "nfig.EncryptionTypeB\003\340A\002\022?\n\014kms_key_name" - + "\030\002 \001(\tB)\340A\001\372A#\n!cloudkms.googleapis.com/" - + "CryptoKey\"\216\001\n\016EncryptionType\022\037\n\033ENCRYPTI" - + "ON_TYPE_UNSPECIFIED\020\000\022\033\n\027USE_DATABASE_EN" - + "CRYPTION\020\001\022\035\n\031GOOGLE_DEFAULT_ENCRYPTION\020" - + "\002\022\037\n\033CUSTOMER_MANAGED_ENCRYPTION\020\003B\377\001\n$c" - + "om.google.spanner.admin.database.v1B\013Bac" - + "kupProtoP\001ZHgoogle.golang.org/genproto/g" - + "oogleapis/spanner/admin/database/v1;data" - + "base\252\002&Google.Cloud.Spanner.Admin.Databa" - + "se.V1\312\002&Google\\Cloud\\Spanner\\Admin\\Datab" - + "ase\\V1\352\002+Google::Cloud::Spanner::Admin::" - + "Database::V1b\006proto3" + + "\003 \001(\005\022\022\n\npage_token\030\004 \001(\t\"i\n\023ListBackups" + + "Response\0229\n\007backups\030\001 \003(\0132(.google.spann" + + "er.admin.database.v1.Backup\022\027\n\017next_page" + + "_token\030\002 \001(\t\"\215\001\n\033ListBackupOperationsReq" + + "uest\0227\n\006parent\030\001 \001(\tB\'\340A\002\372A!\n\037spanner.go" + + "ogleapis.com/Instance\022\016\n\006filter\030\002 \001(\t\022\021\n" + + "\tpage_size\030\003 \001(\005\022\022\n\npage_token\030\004 \001(\t\"j\n\034" + + "ListBackupOperationsResponse\0221\n\noperatio" + + "ns\030\001 \003(\0132\035.google.longrunning.Operation\022" + + "\027\n\017next_page_token\030\002 \001(\t\"\342\001\n\nBackupInfo\022" + + "2\n\006backup\030\001 \001(\tB\"\372A\037\n\035spanner.googleapis" + + ".com/Backup\0220\n\014version_time\030\004 \001(\0132\032.goog" + + "le.protobuf.Timestamp\022/\n\013create_time\030\002 \001" + + "(\0132\032.google.protobuf.Timestamp\022=\n\017source" + + "_database\030\003 \001(\tB$\372A!\n\037spanner.googleapis" + + ".com/Database\"\335\002\n\034CreateBackupEncryption" + + "Config\022k\n\017encryption_type\030\001 \001(\0162M.google" + + ".spanner.admin.database.v1.CreateBackupE" + + "ncryptionConfig.EncryptionTypeB\003\340A\002\022?\n\014k" + + "ms_key_name\030\002 \001(\tB)\340A\001\372A#\n!cloudkms.goog" + + "leapis.com/CryptoKey\"\216\001\n\016EncryptionType\022" + + "\037\n\033ENCRYPTION_TYPE_UNSPECIFIED\020\000\022\033\n\027USE_" + + "DATABASE_ENCRYPTION\020\001\022\035\n\031GOOGLE_DEFAULT_" + + "ENCRYPTION\020\002\022\037\n\033CUSTOMER_MANAGED_ENCRYPT" + + "ION\020\003\"\351\002\n\032CopyBackupEncryptionConfig\022i\n\017" + + "encryption_type\030\001 \001(\0162K.google.spanner.a" + + "dmin.database.v1.CopyBackupEncryptionCon" + + "fig.EncryptionTypeB\003\340A\002\022?\n\014kms_key_name\030" + + "\002 \001(\tB)\340A\001\372A#\n!cloudkms.googleapis.com/C" + + "ryptoKey\"\236\001\n\016EncryptionType\022\037\n\033ENCRYPTIO" + + "N_TYPE_UNSPECIFIED\020\000\022+\n\'USE_CONFIG_DEFAU" + + "LT_OR_BACKUP_ENCRYPTION\020\001\022\035\n\031GOOGLE_DEFA" + + "ULT_ENCRYPTION\020\002\022\037\n\033CUSTOMER_MANAGED_ENC" + + "RYPTION\020\003B\377\001\n$com.google.spanner.admin.d" + + "atabase.v1B\013BackupProtoP\001ZHgoogle.golang" + + ".org/genproto/googleapis/spanner/admin/d" + + "atabase/v1;database\252\002&Google.Cloud.Spann" + + "er.Admin.Database.V1\312\002&Google\\Cloud\\Span" + + "ner\\Admin\\Database\\V1\352\002+Google::Cloud::S" + + "panner::Admin::Database::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -193,6 +231,8 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "ReferencingDatabases", "EncryptionInfo", "DatabaseDialect", + "ReferencingBackups", + "MaxExpireTime", }); internal_static_google_spanner_admin_database_v1_CreateBackupRequest_descriptor = getDescriptor().getMessageTypes().get(1); @@ -210,8 +250,24 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new java.lang.String[] { "Name", "Database", "Progress", "CancelTime", }); - internal_static_google_spanner_admin_database_v1_UpdateBackupRequest_descriptor = + internal_static_google_spanner_admin_database_v1_CopyBackupRequest_descriptor = getDescriptor().getMessageTypes().get(3); + internal_static_google_spanner_admin_database_v1_CopyBackupRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_CopyBackupRequest_descriptor, + new java.lang.String[] { + "Parent", "BackupId", "SourceBackup", "ExpireTime", "EncryptionConfig", + }); + internal_static_google_spanner_admin_database_v1_CopyBackupMetadata_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_spanner_admin_database_v1_CopyBackupMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_CopyBackupMetadata_descriptor, + new java.lang.String[] { + "Name", "SourceBackup", "Progress", "CancelTime", + }); + internal_static_google_spanner_admin_database_v1_UpdateBackupRequest_descriptor = + getDescriptor().getMessageTypes().get(5); internal_static_google_spanner_admin_database_v1_UpdateBackupRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_spanner_admin_database_v1_UpdateBackupRequest_descriptor, @@ -219,7 +275,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Backup", "UpdateMask", }); internal_static_google_spanner_admin_database_v1_GetBackupRequest_descriptor = - getDescriptor().getMessageTypes().get(4); + getDescriptor().getMessageTypes().get(6); internal_static_google_spanner_admin_database_v1_GetBackupRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_spanner_admin_database_v1_GetBackupRequest_descriptor, @@ -227,7 +283,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Name", }); internal_static_google_spanner_admin_database_v1_DeleteBackupRequest_descriptor = - getDescriptor().getMessageTypes().get(5); + getDescriptor().getMessageTypes().get(7); internal_static_google_spanner_admin_database_v1_DeleteBackupRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_spanner_admin_database_v1_DeleteBackupRequest_descriptor, @@ -235,7 +291,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Name", }); internal_static_google_spanner_admin_database_v1_ListBackupsRequest_descriptor = - getDescriptor().getMessageTypes().get(6); + getDescriptor().getMessageTypes().get(8); internal_static_google_spanner_admin_database_v1_ListBackupsRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_spanner_admin_database_v1_ListBackupsRequest_descriptor, @@ -243,7 +299,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Parent", "Filter", "PageSize", "PageToken", }); internal_static_google_spanner_admin_database_v1_ListBackupsResponse_descriptor = - getDescriptor().getMessageTypes().get(7); + getDescriptor().getMessageTypes().get(9); internal_static_google_spanner_admin_database_v1_ListBackupsResponse_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_spanner_admin_database_v1_ListBackupsResponse_descriptor, @@ -251,7 +307,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Backups", "NextPageToken", }); internal_static_google_spanner_admin_database_v1_ListBackupOperationsRequest_descriptor = - getDescriptor().getMessageTypes().get(8); + getDescriptor().getMessageTypes().get(10); internal_static_google_spanner_admin_database_v1_ListBackupOperationsRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_spanner_admin_database_v1_ListBackupOperationsRequest_descriptor, @@ -259,7 +315,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Parent", "Filter", "PageSize", "PageToken", }); internal_static_google_spanner_admin_database_v1_ListBackupOperationsResponse_descriptor = - getDescriptor().getMessageTypes().get(9); + getDescriptor().getMessageTypes().get(11); internal_static_google_spanner_admin_database_v1_ListBackupOperationsResponse_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_spanner_admin_database_v1_ListBackupOperationsResponse_descriptor, @@ -267,7 +323,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Operations", "NextPageToken", }); internal_static_google_spanner_admin_database_v1_BackupInfo_descriptor = - getDescriptor().getMessageTypes().get(10); + getDescriptor().getMessageTypes().get(12); internal_static_google_spanner_admin_database_v1_BackupInfo_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_spanner_admin_database_v1_BackupInfo_descriptor, @@ -275,13 +331,21 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Backup", "VersionTime", "CreateTime", "SourceDatabase", }); internal_static_google_spanner_admin_database_v1_CreateBackupEncryptionConfig_descriptor = - getDescriptor().getMessageTypes().get(11); + getDescriptor().getMessageTypes().get(13); internal_static_google_spanner_admin_database_v1_CreateBackupEncryptionConfig_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_spanner_admin_database_v1_CreateBackupEncryptionConfig_descriptor, new java.lang.String[] { "EncryptionType", "KmsKeyName", }); + internal_static_google_spanner_admin_database_v1_CopyBackupEncryptionConfig_descriptor = + getDescriptor().getMessageTypes().get(14); + internal_static_google_spanner_admin_database_v1_CopyBackupEncryptionConfig_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_CopyBackupEncryptionConfig_descriptor, + new java.lang.String[] { + "EncryptionType", "KmsKeyName", + }); com.google.protobuf.ExtensionRegistry registry = com.google.protobuf.ExtensionRegistry.newInstance(); registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupEncryptionConfig.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupEncryptionConfig.java new file mode 100644 index 00000000000..ea29df0725f --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupEncryptionConfig.java @@ -0,0 +1,1057 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup.proto + +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * Encryption configuration for the copied backup.
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.CopyBackupEncryptionConfig} + */ +public final class CopyBackupEncryptionConfig extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.CopyBackupEncryptionConfig) + CopyBackupEncryptionConfigOrBuilder { + private static final long serialVersionUID = 0L; + // Use CopyBackupEncryptionConfig.newBuilder() to construct. + private CopyBackupEncryptionConfig(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CopyBackupEncryptionConfig() { + encryptionType_ = 0; + kmsKeyName_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CopyBackupEncryptionConfig(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private CopyBackupEncryptionConfig( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + int rawValue = input.readEnum(); + + encryptionType_ = rawValue; + break; + } + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + + kmsKeyName_ = s; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupEncryptionConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupEncryptionConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.class, + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.Builder.class); + } + + /** + * + * + *
+   * Encryption types for the backup.
+   * 
+ * + * Protobuf enum {@code + * google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType} + */ + public enum EncryptionType implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified. Do not use.
+     * 
+ * + * ENCRYPTION_TYPE_UNSPECIFIED = 0; + */ + ENCRYPTION_TYPE_UNSPECIFIED(0), + /** + * + * + *
+     * This is the default option for [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]
+     * when [encryption_config][google.spanner.admin.database.v1.CopyBackupEncryptionConfig] is not specified.
+     * For example, if the source backup is using `Customer_Managed_Encryption`,
+     * the backup will be using the same Cloud KMS key as the source backup.
+     * 
+ * + * USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1; + */ + USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION(1), + /** + * + * + *
+     * Use Google default encryption.
+     * 
+ * + * GOOGLE_DEFAULT_ENCRYPTION = 2; + */ + GOOGLE_DEFAULT_ENCRYPTION(2), + /** + * + * + *
+     * Use customer managed encryption. If specified, `kms_key_name`
+     * must contain a valid Cloud KMS key.
+     * 
+ * + * CUSTOMER_MANAGED_ENCRYPTION = 3; + */ + CUSTOMER_MANAGED_ENCRYPTION(3), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * Unspecified. Do not use.
+     * 
+ * + * ENCRYPTION_TYPE_UNSPECIFIED = 0; + */ + public static final int ENCRYPTION_TYPE_UNSPECIFIED_VALUE = 0; + /** + * + * + *
+     * This is the default option for [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]
+     * when [encryption_config][google.spanner.admin.database.v1.CopyBackupEncryptionConfig] is not specified.
+     * For example, if the source backup is using `Customer_Managed_Encryption`,
+     * the backup will be using the same Cloud KMS key as the source backup.
+     * 
+ * + * USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1; + */ + public static final int USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION_VALUE = 1; + /** + * + * + *
+     * Use Google default encryption.
+     * 
+ * + * GOOGLE_DEFAULT_ENCRYPTION = 2; + */ + public static final int GOOGLE_DEFAULT_ENCRYPTION_VALUE = 2; + /** + * + * + *
+     * Use customer managed encryption. If specified, `kms_key_name`
+     * must contain a valid Cloud KMS key.
+     * 
+ * + * CUSTOMER_MANAGED_ENCRYPTION = 3; + */ + public static final int CUSTOMER_MANAGED_ENCRYPTION_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static EncryptionType valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static EncryptionType forNumber(int value) { + switch (value) { + case 0: + return ENCRYPTION_TYPE_UNSPECIFIED; + case 1: + return USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION; + case 2: + return GOOGLE_DEFAULT_ENCRYPTION; + case 3: + return CUSTOMER_MANAGED_ENCRYPTION; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public EncryptionType findValueByNumber(int number) { + return EncryptionType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.getDescriptor() + .getEnumTypes() + .get(0); + } + + private static final EncryptionType[] VALUES = values(); + + public static EncryptionType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private EncryptionType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType) + } + + public static final int ENCRYPTION_TYPE_FIELD_NUMBER = 1; + private int encryptionType_; + /** + * + * + *
+   * Required. The encryption type of the backup.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for encryptionType. + */ + @java.lang.Override + public int getEncryptionTypeValue() { + return encryptionType_; + } + /** + * + * + *
+   * Required. The encryption type of the backup.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The encryptionType. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType + getEncryptionType() { + @SuppressWarnings("deprecation") + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType result = + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType.valueOf( + encryptionType_); + return result == null + ? com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType + .UNRECOGNIZED + : result; + } + + public static final int KMS_KEY_NAME_FIELD_NUMBER = 2; + private volatile java.lang.Object kmsKeyName_; + /** + * + * + *
+   * Optional. The Cloud KMS key that will be used to protect the backup.
+   * This field should be set only when
+   * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] is
+   * `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
+   * `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
+   * 
+ * + * + * string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { ... } + * + * + * @return The kmsKeyName. + */ + @java.lang.Override + public java.lang.String getKmsKeyName() { + java.lang.Object ref = kmsKeyName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + kmsKeyName_ = s; + return s; + } + } + /** + * + * + *
+   * Optional. The Cloud KMS key that will be used to protect the backup.
+   * This field should be set only when
+   * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] is
+   * `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
+   * `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
+   * 
+ * + * + * string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for kmsKeyName. + */ + @java.lang.Override + public com.google.protobuf.ByteString getKmsKeyNameBytes() { + java.lang.Object ref = kmsKeyName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + kmsKeyName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (encryptionType_ + != com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType + .ENCRYPTION_TYPE_UNSPECIFIED + .getNumber()) { + output.writeEnum(1, encryptionType_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(kmsKeyName_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, kmsKeyName_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (encryptionType_ + != com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType + .ENCRYPTION_TYPE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, encryptionType_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(kmsKeyName_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, kmsKeyName_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig other = + (com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig) obj; + + if (encryptionType_ != other.encryptionType_) return false; + if (!getKmsKeyName().equals(other.getKmsKeyName())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ENCRYPTION_TYPE_FIELD_NUMBER; + hash = (53 * hash) + encryptionType_; + hash = (37 * hash) + KMS_KEY_NAME_FIELD_NUMBER; + hash = (53 * hash) + getKmsKeyName().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Encryption configuration for the copied backup.
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.CopyBackupEncryptionConfig} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.CopyBackupEncryptionConfig) + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfigOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupEncryptionConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupEncryptionConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.class, + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + encryptionType_ = 0; + + kmsKeyName_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupEncryptionConfig_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig + getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig build() { + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig buildPartial() { + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig result = + new com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig(this); + result.encryptionType_ = encryptionType_; + result.kmsKeyName_ = kmsKeyName_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig) { + return mergeFrom((com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig other) { + if (other + == com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.getDefaultInstance()) + return this; + if (other.encryptionType_ != 0) { + setEncryptionTypeValue(other.getEncryptionTypeValue()); + } + if (!other.getKmsKeyName().isEmpty()) { + kmsKeyName_ = other.kmsKeyName_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig) + e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int encryptionType_ = 0; + /** + * + * + *
+     * Required. The encryption type of the backup.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for encryptionType. + */ + @java.lang.Override + public int getEncryptionTypeValue() { + return encryptionType_; + } + /** + * + * + *
+     * Required. The encryption type of the backup.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @param value The enum numeric value on the wire for encryptionType to set. + * @return This builder for chaining. + */ + public Builder setEncryptionTypeValue(int value) { + + encryptionType_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The encryption type of the backup.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The encryptionType. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType + getEncryptionType() { + @SuppressWarnings("deprecation") + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType result = + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType.valueOf( + encryptionType_); + return result == null + ? com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType + .UNRECOGNIZED + : result; + } + /** + * + * + *
+     * Required. The encryption type of the backup.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @param value The encryptionType to set. + * @return This builder for chaining. + */ + public Builder setEncryptionType( + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType value) { + if (value == null) { + throw new NullPointerException(); + } + + encryptionType_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The encryption type of the backup.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return This builder for chaining. + */ + public Builder clearEncryptionType() { + + encryptionType_ = 0; + onChanged(); + return this; + } + + private java.lang.Object kmsKeyName_ = ""; + /** + * + * + *
+     * Optional. The Cloud KMS key that will be used to protect the backup.
+     * This field should be set only when
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] is
+     * `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
+     * `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
+     * 
+ * + * + * string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { ... } + * + * + * @return The kmsKeyName. + */ + public java.lang.String getKmsKeyName() { + java.lang.Object ref = kmsKeyName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + kmsKeyName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Optional. The Cloud KMS key that will be used to protect the backup.
+     * This field should be set only when
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] is
+     * `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
+     * `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
+     * 
+ * + * + * string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for kmsKeyName. + */ + public com.google.protobuf.ByteString getKmsKeyNameBytes() { + java.lang.Object ref = kmsKeyName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + kmsKeyName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Optional. The Cloud KMS key that will be used to protect the backup.
+     * This field should be set only when
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] is
+     * `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
+     * `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
+     * 
+ * + * + * string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { ... } + * + * + * @param value The kmsKeyName to set. + * @return This builder for chaining. + */ + public Builder setKmsKeyName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + kmsKeyName_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. The Cloud KMS key that will be used to protect the backup.
+     * This field should be set only when
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] is
+     * `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
+     * `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
+     * 
+ * + * + * string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearKmsKeyName() { + + kmsKeyName_ = getDefaultInstance().getKmsKeyName(); + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. The Cloud KMS key that will be used to protect the backup.
+     * This field should be set only when
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] is
+     * `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
+     * `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
+     * 
+ * + * + * string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for kmsKeyName to set. + * @return This builder for chaining. + */ + public Builder setKmsKeyNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + kmsKeyName_ = value; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.spanner.admin.database.v1.CopyBackupEncryptionConfig) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.CopyBackupEncryptionConfig) + private static final com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig(); + } + + public static com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CopyBackupEncryptionConfig parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CopyBackupEncryptionConfig(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupEncryptionConfigOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupEncryptionConfigOrBuilder.java new file mode 100644 index 00000000000..a6117dfb660 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupEncryptionConfigOrBuilder.java @@ -0,0 +1,92 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup.proto + +package com.google.spanner.admin.database.v1; + +public interface CopyBackupEncryptionConfigOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.CopyBackupEncryptionConfig) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The encryption type of the backup.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for encryptionType. + */ + int getEncryptionTypeValue(); + /** + * + * + *
+   * Required. The encryption type of the backup.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The encryptionType. + */ + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType + getEncryptionType(); + + /** + * + * + *
+   * Optional. The Cloud KMS key that will be used to protect the backup.
+   * This field should be set only when
+   * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] is
+   * `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
+   * `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
+   * 
+ * + * + * string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { ... } + * + * + * @return The kmsKeyName. + */ + java.lang.String getKmsKeyName(); + /** + * + * + *
+   * Optional. The Cloud KMS key that will be used to protect the backup.
+   * This field should be set only when
+   * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] is
+   * `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
+   * `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
+   * 
+ * + * + * string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for kmsKeyName. + */ + com.google.protobuf.ByteString getKmsKeyNameBytes(); +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupMetadata.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupMetadata.java new file mode 100644 index 00000000000..b4702fd1be4 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupMetadata.java @@ -0,0 +1,1541 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup.proto + +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * Metadata type for the google.longrunning.Operation returned by
+ * [CopyBackup][DatabaseAdmin.CopyBackup].
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.CopyBackupMetadata} + */ +public final class CopyBackupMetadata extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.CopyBackupMetadata) + CopyBackupMetadataOrBuilder { + private static final long serialVersionUID = 0L; + // Use CopyBackupMetadata.newBuilder() to construct. + private CopyBackupMetadata(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CopyBackupMetadata() { + name_ = ""; + sourceBackup_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CopyBackupMetadata(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private CopyBackupMetadata( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + + sourceBackup_ = s; + break; + } + case 26: + { + com.google.spanner.admin.database.v1.OperationProgress.Builder subBuilder = null; + if (progress_ != null) { + subBuilder = progress_.toBuilder(); + } + progress_ = + input.readMessage( + com.google.spanner.admin.database.v1.OperationProgress.parser(), + extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(progress_); + progress_ = subBuilder.buildPartial(); + } + + break; + } + case 34: + { + com.google.protobuf.Timestamp.Builder subBuilder = null; + if (cancelTime_ != null) { + subBuilder = cancelTime_.toBuilder(); + } + cancelTime_ = + input.readMessage(com.google.protobuf.Timestamp.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(cancelTime_); + cancelTime_ = subBuilder.buildPartial(); + } + + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.CopyBackupMetadata.class, + com.google.spanner.admin.database.v1.CopyBackupMetadata.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * + * + *
+   * The name of the backup being created through the copy operation.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * string name = 1 [(.google.api.resource_reference) = { ... } + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * The name of the backup being created through the copy operation.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * string name = 1 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SOURCE_BACKUP_FIELD_NUMBER = 2; + private volatile java.lang.Object sourceBackup_; + /** + * + * + *
+   * The name of the source backup that is being copied.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * string source_backup = 2 [(.google.api.resource_reference) = { ... } + * + * @return The sourceBackup. + */ + @java.lang.Override + public java.lang.String getSourceBackup() { + java.lang.Object ref = sourceBackup_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + sourceBackup_ = s; + return s; + } + } + /** + * + * + *
+   * The name of the source backup that is being copied.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * string source_backup = 2 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for sourceBackup. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSourceBackupBytes() { + java.lang.Object ref = sourceBackup_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + sourceBackup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PROGRESS_FIELD_NUMBER = 3; + private com.google.spanner.admin.database.v1.OperationProgress progress_; + /** + * + * + *
+   * The progress of the
+   * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+   * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + * + * @return Whether the progress field is set. + */ + @java.lang.Override + public boolean hasProgress() { + return progress_ != null; + } + /** + * + * + *
+   * The progress of the
+   * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+   * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + * + * @return The progress. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.OperationProgress getProgress() { + return progress_ == null + ? com.google.spanner.admin.database.v1.OperationProgress.getDefaultInstance() + : progress_; + } + /** + * + * + *
+   * The progress of the
+   * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+   * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.OperationProgressOrBuilder getProgressOrBuilder() { + return getProgress(); + } + + public static final int CANCEL_TIME_FIELD_NUMBER = 4; + private com.google.protobuf.Timestamp cancelTime_; + /** + * + * + *
+   * The time at which cancellation of CopyBackup operation was received.
+   * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+   * starts asynchronous cancellation on a long-running operation. The server
+   * makes a best effort to cancel the operation, but success is not guaranteed.
+   * Clients can use
+   * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+   * other methods to check whether the cancellation succeeded or whether the
+   * operation completed despite cancellation. On successful cancellation,
+   * the operation is not deleted; instead, it becomes an operation with
+   * an [Operation.error][google.longrunning.Operation.error] value with a
+   * [google.rpc.Status.code][] of 1,
+   * corresponding to `Code.CANCELLED`.
+   * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + * + * @return Whether the cancelTime field is set. + */ + @java.lang.Override + public boolean hasCancelTime() { + return cancelTime_ != null; + } + /** + * + * + *
+   * The time at which cancellation of CopyBackup operation was received.
+   * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+   * starts asynchronous cancellation on a long-running operation. The server
+   * makes a best effort to cancel the operation, but success is not guaranteed.
+   * Clients can use
+   * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+   * other methods to check whether the cancellation succeeded or whether the
+   * operation completed despite cancellation. On successful cancellation,
+   * the operation is not deleted; instead, it becomes an operation with
+   * an [Operation.error][google.longrunning.Operation.error] value with a
+   * [google.rpc.Status.code][] of 1,
+   * corresponding to `Code.CANCELLED`.
+   * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + * + * @return The cancelTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCancelTime() { + return cancelTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : cancelTime_; + } + /** + * + * + *
+   * The time at which cancellation of CopyBackup operation was received.
+   * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+   * starts asynchronous cancellation on a long-running operation. The server
+   * makes a best effort to cancel the operation, but success is not guaranteed.
+   * Clients can use
+   * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+   * other methods to check whether the cancellation succeeded or whether the
+   * operation completed despite cancellation. On successful cancellation,
+   * the operation is not deleted; instead, it becomes an operation with
+   * an [Operation.error][google.longrunning.Operation.error] value with a
+   * [google.rpc.Status.code][] of 1,
+   * corresponding to `Code.CANCELLED`.
+   * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getCancelTimeOrBuilder() { + return getCancelTime(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(sourceBackup_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, sourceBackup_); + } + if (progress_ != null) { + output.writeMessage(3, getProgress()); + } + if (cancelTime_ != null) { + output.writeMessage(4, getCancelTime()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(sourceBackup_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, sourceBackup_); + } + if (progress_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getProgress()); + } + if (cancelTime_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getCancelTime()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.spanner.admin.database.v1.CopyBackupMetadata)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.CopyBackupMetadata other = + (com.google.spanner.admin.database.v1.CopyBackupMetadata) obj; + + if (!getName().equals(other.getName())) return false; + if (!getSourceBackup().equals(other.getSourceBackup())) return false; + if (hasProgress() != other.hasProgress()) return false; + if (hasProgress()) { + if (!getProgress().equals(other.getProgress())) return false; + } + if (hasCancelTime() != other.hasCancelTime()) return false; + if (hasCancelTime()) { + if (!getCancelTime().equals(other.getCancelTime())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + SOURCE_BACKUP_FIELD_NUMBER; + hash = (53 * hash) + getSourceBackup().hashCode(); + if (hasProgress()) { + hash = (37 * hash) + PROGRESS_FIELD_NUMBER; + hash = (53 * hash) + getProgress().hashCode(); + } + if (hasCancelTime()) { + hash = (37 * hash) + CANCEL_TIME_FIELD_NUMBER; + hash = (53 * hash) + getCancelTime().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.spanner.admin.database.v1.CopyBackupMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CopyBackupMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CopyBackupMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CopyBackupMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CopyBackupMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CopyBackupMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CopyBackupMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.spanner.admin.database.v1.CopyBackupMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Metadata type for the google.longrunning.Operation returned by
+   * [CopyBackup][DatabaseAdmin.CopyBackup].
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.CopyBackupMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.CopyBackupMetadata) + com.google.spanner.admin.database.v1.CopyBackupMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.CopyBackupMetadata.class, + com.google.spanner.admin.database.v1.CopyBackupMetadata.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.CopyBackupMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + name_ = ""; + + sourceBackup_ = ""; + + if (progressBuilder_ == null) { + progress_ = null; + } else { + progress_ = null; + progressBuilder_ = null; + } + if (cancelTimeBuilder_ == null) { + cancelTime_ = null; + } else { + cancelTime_ = null; + cancelTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupMetadata_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupMetadata getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.CopyBackupMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupMetadata build() { + com.google.spanner.admin.database.v1.CopyBackupMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupMetadata buildPartial() { + com.google.spanner.admin.database.v1.CopyBackupMetadata result = + new com.google.spanner.admin.database.v1.CopyBackupMetadata(this); + result.name_ = name_; + result.sourceBackup_ = sourceBackup_; + if (progressBuilder_ == null) { + result.progress_ = progress_; + } else { + result.progress_ = progressBuilder_.build(); + } + if (cancelTimeBuilder_ == null) { + result.cancelTime_ = cancelTime_; + } else { + result.cancelTime_ = cancelTimeBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.spanner.admin.database.v1.CopyBackupMetadata) { + return mergeFrom((com.google.spanner.admin.database.v1.CopyBackupMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.spanner.admin.database.v1.CopyBackupMetadata other) { + if (other == com.google.spanner.admin.database.v1.CopyBackupMetadata.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getSourceBackup().isEmpty()) { + sourceBackup_ = other.sourceBackup_; + onChanged(); + } + if (other.hasProgress()) { + mergeProgress(other.getProgress()); + } + if (other.hasCancelTime()) { + mergeCancelTime(other.getCancelTime()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.spanner.admin.database.v1.CopyBackupMetadata parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.spanner.admin.database.v1.CopyBackupMetadata) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * The name of the backup being created through the copy operation.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string name = 1 [(.google.api.resource_reference) = { ... } + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * The name of the backup being created through the copy operation.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string name = 1 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * The name of the backup being created through the copy operation.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string name = 1 [(.google.api.resource_reference) = { ... } + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * The name of the backup being created through the copy operation.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string name = 1 [(.google.api.resource_reference) = { ... } + * + * @return This builder for chaining. + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * + * + *
+     * The name of the backup being created through the copy operation.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string name = 1 [(.google.api.resource_reference) = { ... } + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.lang.Object sourceBackup_ = ""; + /** + * + * + *
+     * The name of the source backup that is being copied.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string source_backup = 2 [(.google.api.resource_reference) = { ... } + * + * @return The sourceBackup. + */ + public java.lang.String getSourceBackup() { + java.lang.Object ref = sourceBackup_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + sourceBackup_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * The name of the source backup that is being copied.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string source_backup = 2 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for sourceBackup. + */ + public com.google.protobuf.ByteString getSourceBackupBytes() { + java.lang.Object ref = sourceBackup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + sourceBackup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * The name of the source backup that is being copied.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string source_backup = 2 [(.google.api.resource_reference) = { ... } + * + * @param value The sourceBackup to set. + * @return This builder for chaining. + */ + public Builder setSourceBackup(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + sourceBackup_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * The name of the source backup that is being copied.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string source_backup = 2 [(.google.api.resource_reference) = { ... } + * + * @return This builder for chaining. + */ + public Builder clearSourceBackup() { + + sourceBackup_ = getDefaultInstance().getSourceBackup(); + onChanged(); + return this; + } + /** + * + * + *
+     * The name of the source backup that is being copied.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string source_backup = 2 [(.google.api.resource_reference) = { ... } + * + * @param value The bytes for sourceBackup to set. + * @return This builder for chaining. + */ + public Builder setSourceBackupBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + sourceBackup_ = value; + onChanged(); + return this; + } + + private com.google.spanner.admin.database.v1.OperationProgress progress_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.OperationProgress, + com.google.spanner.admin.database.v1.OperationProgress.Builder, + com.google.spanner.admin.database.v1.OperationProgressOrBuilder> + progressBuilder_; + /** + * + * + *
+     * The progress of the
+     * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+     * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + * + * @return Whether the progress field is set. + */ + public boolean hasProgress() { + return progressBuilder_ != null || progress_ != null; + } + /** + * + * + *
+     * The progress of the
+     * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+     * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + * + * @return The progress. + */ + public com.google.spanner.admin.database.v1.OperationProgress getProgress() { + if (progressBuilder_ == null) { + return progress_ == null + ? com.google.spanner.admin.database.v1.OperationProgress.getDefaultInstance() + : progress_; + } else { + return progressBuilder_.getMessage(); + } + } + /** + * + * + *
+     * The progress of the
+     * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+     * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + */ + public Builder setProgress(com.google.spanner.admin.database.v1.OperationProgress value) { + if (progressBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progress_ = value; + onChanged(); + } else { + progressBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * The progress of the
+     * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+     * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + */ + public Builder setProgress( + com.google.spanner.admin.database.v1.OperationProgress.Builder builderForValue) { + if (progressBuilder_ == null) { + progress_ = builderForValue.build(); + onChanged(); + } else { + progressBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * The progress of the
+     * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+     * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + */ + public Builder mergeProgress(com.google.spanner.admin.database.v1.OperationProgress value) { + if (progressBuilder_ == null) { + if (progress_ != null) { + progress_ = + com.google.spanner.admin.database.v1.OperationProgress.newBuilder(progress_) + .mergeFrom(value) + .buildPartial(); + } else { + progress_ = value; + } + onChanged(); + } else { + progressBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * The progress of the
+     * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+     * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + */ + public Builder clearProgress() { + if (progressBuilder_ == null) { + progress_ = null; + onChanged(); + } else { + progress_ = null; + progressBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * The progress of the
+     * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+     * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + */ + public com.google.spanner.admin.database.v1.OperationProgress.Builder getProgressBuilder() { + + onChanged(); + return getProgressFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * The progress of the
+     * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+     * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + */ + public com.google.spanner.admin.database.v1.OperationProgressOrBuilder getProgressOrBuilder() { + if (progressBuilder_ != null) { + return progressBuilder_.getMessageOrBuilder(); + } else { + return progress_ == null + ? com.google.spanner.admin.database.v1.OperationProgress.getDefaultInstance() + : progress_; + } + } + /** + * + * + *
+     * The progress of the
+     * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+     * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.OperationProgress, + com.google.spanner.admin.database.v1.OperationProgress.Builder, + com.google.spanner.admin.database.v1.OperationProgressOrBuilder> + getProgressFieldBuilder() { + if (progressBuilder_ == null) { + progressBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.OperationProgress, + com.google.spanner.admin.database.v1.OperationProgress.Builder, + com.google.spanner.admin.database.v1.OperationProgressOrBuilder>( + getProgress(), getParentForChildren(), isClean()); + progress_ = null; + } + return progressBuilder_; + } + + private com.google.protobuf.Timestamp cancelTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + cancelTimeBuilder_; + /** + * + * + *
+     * The time at which cancellation of CopyBackup operation was received.
+     * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+     * starts asynchronous cancellation on a long-running operation. The server
+     * makes a best effort to cancel the operation, but success is not guaranteed.
+     * Clients can use
+     * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+     * other methods to check whether the cancellation succeeded or whether the
+     * operation completed despite cancellation. On successful cancellation,
+     * the operation is not deleted; instead, it becomes an operation with
+     * an [Operation.error][google.longrunning.Operation.error] value with a
+     * [google.rpc.Status.code][] of 1,
+     * corresponding to `Code.CANCELLED`.
+     * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + * + * @return Whether the cancelTime field is set. + */ + public boolean hasCancelTime() { + return cancelTimeBuilder_ != null || cancelTime_ != null; + } + /** + * + * + *
+     * The time at which cancellation of CopyBackup operation was received.
+     * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+     * starts asynchronous cancellation on a long-running operation. The server
+     * makes a best effort to cancel the operation, but success is not guaranteed.
+     * Clients can use
+     * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+     * other methods to check whether the cancellation succeeded or whether the
+     * operation completed despite cancellation. On successful cancellation,
+     * the operation is not deleted; instead, it becomes an operation with
+     * an [Operation.error][google.longrunning.Operation.error] value with a
+     * [google.rpc.Status.code][] of 1,
+     * corresponding to `Code.CANCELLED`.
+     * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + * + * @return The cancelTime. + */ + public com.google.protobuf.Timestamp getCancelTime() { + if (cancelTimeBuilder_ == null) { + return cancelTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : cancelTime_; + } else { + return cancelTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * The time at which cancellation of CopyBackup operation was received.
+     * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+     * starts asynchronous cancellation on a long-running operation. The server
+     * makes a best effort to cancel the operation, but success is not guaranteed.
+     * Clients can use
+     * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+     * other methods to check whether the cancellation succeeded or whether the
+     * operation completed despite cancellation. On successful cancellation,
+     * the operation is not deleted; instead, it becomes an operation with
+     * an [Operation.error][google.longrunning.Operation.error] value with a
+     * [google.rpc.Status.code][] of 1,
+     * corresponding to `Code.CANCELLED`.
+     * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + */ + public Builder setCancelTime(com.google.protobuf.Timestamp value) { + if (cancelTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + cancelTime_ = value; + onChanged(); + } else { + cancelTimeBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * The time at which cancellation of CopyBackup operation was received.
+     * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+     * starts asynchronous cancellation on a long-running operation. The server
+     * makes a best effort to cancel the operation, but success is not guaranteed.
+     * Clients can use
+     * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+     * other methods to check whether the cancellation succeeded or whether the
+     * operation completed despite cancellation. On successful cancellation,
+     * the operation is not deleted; instead, it becomes an operation with
+     * an [Operation.error][google.longrunning.Operation.error] value with a
+     * [google.rpc.Status.code][] of 1,
+     * corresponding to `Code.CANCELLED`.
+     * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + */ + public Builder setCancelTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (cancelTimeBuilder_ == null) { + cancelTime_ = builderForValue.build(); + onChanged(); + } else { + cancelTimeBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * The time at which cancellation of CopyBackup operation was received.
+     * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+     * starts asynchronous cancellation on a long-running operation. The server
+     * makes a best effort to cancel the operation, but success is not guaranteed.
+     * Clients can use
+     * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+     * other methods to check whether the cancellation succeeded or whether the
+     * operation completed despite cancellation. On successful cancellation,
+     * the operation is not deleted; instead, it becomes an operation with
+     * an [Operation.error][google.longrunning.Operation.error] value with a
+     * [google.rpc.Status.code][] of 1,
+     * corresponding to `Code.CANCELLED`.
+     * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + */ + public Builder mergeCancelTime(com.google.protobuf.Timestamp value) { + if (cancelTimeBuilder_ == null) { + if (cancelTime_ != null) { + cancelTime_ = + com.google.protobuf.Timestamp.newBuilder(cancelTime_).mergeFrom(value).buildPartial(); + } else { + cancelTime_ = value; + } + onChanged(); + } else { + cancelTimeBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * The time at which cancellation of CopyBackup operation was received.
+     * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+     * starts asynchronous cancellation on a long-running operation. The server
+     * makes a best effort to cancel the operation, but success is not guaranteed.
+     * Clients can use
+     * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+     * other methods to check whether the cancellation succeeded or whether the
+     * operation completed despite cancellation. On successful cancellation,
+     * the operation is not deleted; instead, it becomes an operation with
+     * an [Operation.error][google.longrunning.Operation.error] value with a
+     * [google.rpc.Status.code][] of 1,
+     * corresponding to `Code.CANCELLED`.
+     * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + */ + public Builder clearCancelTime() { + if (cancelTimeBuilder_ == null) { + cancelTime_ = null; + onChanged(); + } else { + cancelTime_ = null; + cancelTimeBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * The time at which cancellation of CopyBackup operation was received.
+     * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+     * starts asynchronous cancellation on a long-running operation. The server
+     * makes a best effort to cancel the operation, but success is not guaranteed.
+     * Clients can use
+     * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+     * other methods to check whether the cancellation succeeded or whether the
+     * operation completed despite cancellation. On successful cancellation,
+     * the operation is not deleted; instead, it becomes an operation with
+     * an [Operation.error][google.longrunning.Operation.error] value with a
+     * [google.rpc.Status.code][] of 1,
+     * corresponding to `Code.CANCELLED`.
+     * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + */ + public com.google.protobuf.Timestamp.Builder getCancelTimeBuilder() { + + onChanged(); + return getCancelTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * The time at which cancellation of CopyBackup operation was received.
+     * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+     * starts asynchronous cancellation on a long-running operation. The server
+     * makes a best effort to cancel the operation, but success is not guaranteed.
+     * Clients can use
+     * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+     * other methods to check whether the cancellation succeeded or whether the
+     * operation completed despite cancellation. On successful cancellation,
+     * the operation is not deleted; instead, it becomes an operation with
+     * an [Operation.error][google.longrunning.Operation.error] value with a
+     * [google.rpc.Status.code][] of 1,
+     * corresponding to `Code.CANCELLED`.
+     * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + */ + public com.google.protobuf.TimestampOrBuilder getCancelTimeOrBuilder() { + if (cancelTimeBuilder_ != null) { + return cancelTimeBuilder_.getMessageOrBuilder(); + } else { + return cancelTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : cancelTime_; + } + } + /** + * + * + *
+     * The time at which cancellation of CopyBackup operation was received.
+     * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+     * starts asynchronous cancellation on a long-running operation. The server
+     * makes a best effort to cancel the operation, but success is not guaranteed.
+     * Clients can use
+     * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+     * other methods to check whether the cancellation succeeded or whether the
+     * operation completed despite cancellation. On successful cancellation,
+     * the operation is not deleted; instead, it becomes an operation with
+     * an [Operation.error][google.longrunning.Operation.error] value with a
+     * [google.rpc.Status.code][] of 1,
+     * corresponding to `Code.CANCELLED`.
+     * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getCancelTimeFieldBuilder() { + if (cancelTimeBuilder_ == null) { + cancelTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getCancelTime(), getParentForChildren(), isClean()); + cancelTime_ = null; + } + return cancelTimeBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.spanner.admin.database.v1.CopyBackupMetadata) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.CopyBackupMetadata) + private static final com.google.spanner.admin.database.v1.CopyBackupMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.CopyBackupMetadata(); + } + + public static com.google.spanner.admin.database.v1.CopyBackupMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CopyBackupMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CopyBackupMetadata(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupMetadataOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupMetadataOrBuilder.java new file mode 100644 index 00000000000..30dcb2ecda6 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupMetadataOrBuilder.java @@ -0,0 +1,189 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup.proto + +package com.google.spanner.admin.database.v1; + +public interface CopyBackupMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.CopyBackupMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The name of the backup being created through the copy operation.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * string name = 1 [(.google.api.resource_reference) = { ... } + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * The name of the backup being created through the copy operation.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * string name = 1 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * The name of the source backup that is being copied.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * string source_backup = 2 [(.google.api.resource_reference) = { ... } + * + * @return The sourceBackup. + */ + java.lang.String getSourceBackup(); + /** + * + * + *
+   * The name of the source backup that is being copied.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * string source_backup = 2 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for sourceBackup. + */ + com.google.protobuf.ByteString getSourceBackupBytes(); + + /** + * + * + *
+   * The progress of the
+   * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+   * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + * + * @return Whether the progress field is set. + */ + boolean hasProgress(); + /** + * + * + *
+   * The progress of the
+   * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+   * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + * + * @return The progress. + */ + com.google.spanner.admin.database.v1.OperationProgress getProgress(); + /** + * + * + *
+   * The progress of the
+   * [CopyBackup][DatabaseAdmin.CopyBackup] operation.
+   * 
+ * + * .google.spanner.admin.database.v1.OperationProgress progress = 3; + */ + com.google.spanner.admin.database.v1.OperationProgressOrBuilder getProgressOrBuilder(); + + /** + * + * + *
+   * The time at which cancellation of CopyBackup operation was received.
+   * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+   * starts asynchronous cancellation on a long-running operation. The server
+   * makes a best effort to cancel the operation, but success is not guaranteed.
+   * Clients can use
+   * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+   * other methods to check whether the cancellation succeeded or whether the
+   * operation completed despite cancellation. On successful cancellation,
+   * the operation is not deleted; instead, it becomes an operation with
+   * an [Operation.error][google.longrunning.Operation.error] value with a
+   * [google.rpc.Status.code][] of 1,
+   * corresponding to `Code.CANCELLED`.
+   * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + * + * @return Whether the cancelTime field is set. + */ + boolean hasCancelTime(); + /** + * + * + *
+   * The time at which cancellation of CopyBackup operation was received.
+   * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+   * starts asynchronous cancellation on a long-running operation. The server
+   * makes a best effort to cancel the operation, but success is not guaranteed.
+   * Clients can use
+   * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+   * other methods to check whether the cancellation succeeded or whether the
+   * operation completed despite cancellation. On successful cancellation,
+   * the operation is not deleted; instead, it becomes an operation with
+   * an [Operation.error][google.longrunning.Operation.error] value with a
+   * [google.rpc.Status.code][] of 1,
+   * corresponding to `Code.CANCELLED`.
+   * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + * + * @return The cancelTime. + */ + com.google.protobuf.Timestamp getCancelTime(); + /** + * + * + *
+   * The time at which cancellation of CopyBackup operation was received.
+   * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
+   * starts asynchronous cancellation on a long-running operation. The server
+   * makes a best effort to cancel the operation, but success is not guaranteed.
+   * Clients can use
+   * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+   * other methods to check whether the cancellation succeeded or whether the
+   * operation completed despite cancellation. On successful cancellation,
+   * the operation is not deleted; instead, it becomes an operation with
+   * an [Operation.error][google.longrunning.Operation.error] value with a
+   * [google.rpc.Status.code][] of 1,
+   * corresponding to `Code.CANCELLED`.
+   * 
+ * + * .google.protobuf.Timestamp cancel_time = 4; + */ + com.google.protobuf.TimestampOrBuilder getCancelTimeOrBuilder(); +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupRequest.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupRequest.java new file mode 100644 index 00000000000..3e5aa64bae9 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupRequest.java @@ -0,0 +1,1769 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup.proto + +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * The request for [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup].
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.CopyBackupRequest} + */ +public final class CopyBackupRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.CopyBackupRequest) + CopyBackupRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use CopyBackupRequest.newBuilder() to construct. + private CopyBackupRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CopyBackupRequest() { + parent_ = ""; + backupId_ = ""; + sourceBackup_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CopyBackupRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private CopyBackupRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + parent_ = s; + break; + } + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + + backupId_ = s; + break; + } + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + + sourceBackup_ = s; + break; + } + case 34: + { + com.google.protobuf.Timestamp.Builder subBuilder = null; + if (expireTime_ != null) { + subBuilder = expireTime_.toBuilder(); + } + expireTime_ = + input.readMessage(com.google.protobuf.Timestamp.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(expireTime_); + expireTime_ = subBuilder.buildPartial(); + } + + break; + } + case 42: + { + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.Builder subBuilder = + null; + if (encryptionConfig_ != null) { + subBuilder = encryptionConfig_.toBuilder(); + } + encryptionConfig_ = + input.readMessage( + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.parser(), + extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(encryptionConfig_); + encryptionConfig_ = subBuilder.buildPartial(); + } + + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.CopyBackupRequest.class, + com.google.spanner.admin.database.v1.CopyBackupRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + private volatile java.lang.Object parent_; + /** + * + * + *
+   * Required. The name of the destination instance that will contain the backup copy.
+   * Values are of the form: `projects/<project>/instances/<instance>`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The name of the destination instance that will contain the backup copy.
+   * Values are of the form: `projects/<project>/instances/<instance>`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BACKUP_ID_FIELD_NUMBER = 2; + private volatile java.lang.Object backupId_; + /** + * + * + *
+   * Required. The id of the backup copy.
+   * The `backup_id` appended to `parent` forms the full backup_uri of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The backupId. + */ + @java.lang.Override + public java.lang.String getBackupId() { + java.lang.Object ref = backupId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + backupId_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The id of the backup copy.
+   * The `backup_id` appended to `parent` forms the full backup_uri of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for backupId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getBackupIdBytes() { + java.lang.Object ref = backupId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backupId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SOURCE_BACKUP_FIELD_NUMBER = 3; + private volatile java.lang.Object sourceBackup_; + /** + * + * + *
+   * Required. The source backup to be copied.
+   * The source backup needs to be in READY state for it to be copied.
+   * Once CopyBackup is in progress, the source backup cannot be deleted or
+   * cleaned up on expiration until CopyBackup is finished.
+   * Values are of the form:
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * + * string source_backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The sourceBackup. + */ + @java.lang.Override + public java.lang.String getSourceBackup() { + java.lang.Object ref = sourceBackup_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + sourceBackup_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The source backup to be copied.
+   * The source backup needs to be in READY state for it to be copied.
+   * Once CopyBackup is in progress, the source backup cannot be deleted or
+   * cleaned up on expiration until CopyBackup is finished.
+   * Values are of the form:
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * + * string source_backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for sourceBackup. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSourceBackupBytes() { + java.lang.Object ref = sourceBackup_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + sourceBackup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int EXPIRE_TIME_FIELD_NUMBER = 4; + private com.google.protobuf.Timestamp expireTime_; + /** + * + * + *
+   * Required. The expiration time of the backup in microsecond granularity.
+   * The expiration time must be at least 6 hours and at most 366 days
+   * from the `create_time` of the source backup. Once the `expire_time` has
+   * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+   * to free the resources used by the backup.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the expireTime field is set. + */ + @java.lang.Override + public boolean hasExpireTime() { + return expireTime_ != null; + } + /** + * + * + *
+   * Required. The expiration time of the backup in microsecond granularity.
+   * The expiration time must be at least 6 hours and at most 366 days
+   * from the `create_time` of the source backup. Once the `expire_time` has
+   * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+   * to free the resources used by the backup.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The expireTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getExpireTime() { + return expireTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : expireTime_; + } + /** + * + * + *
+   * Required. The expiration time of the backup in microsecond granularity.
+   * The expiration time must be at least 6 hours and at most 366 days
+   * from the `create_time` of the source backup. Once the `expire_time` has
+   * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+   * to free the resources used by the backup.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder() { + return getExpireTime(); + } + + public static final int ENCRYPTION_CONFIG_FIELD_NUMBER = 5; + private com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryptionConfig_; + /** + * + * + *
+   * Optional. The encryption configuration used to encrypt the backup. If this field is
+   * not specified, the backup will use the same
+   * encryption configuration as the source backup by default, namely
+   * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+   * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the encryptionConfig field is set. + */ + @java.lang.Override + public boolean hasEncryptionConfig() { + return encryptionConfig_ != null; + } + /** + * + * + *
+   * Optional. The encryption configuration used to encrypt the backup. If this field is
+   * not specified, the backup will use the same
+   * encryption configuration as the source backup by default, namely
+   * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+   * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The encryptionConfig. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig getEncryptionConfig() { + return encryptionConfig_ == null + ? com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } + /** + * + * + *
+   * Optional. The encryption configuration used to encrypt the backup. If this field is
+   * not specified, the backup will use the same
+   * encryption configuration as the source backup by default, namely
+   * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+   * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupEncryptionConfigOrBuilder + getEncryptionConfigOrBuilder() { + return getEncryptionConfig(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(backupId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, backupId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(sourceBackup_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, sourceBackup_); + } + if (expireTime_ != null) { + output.writeMessage(4, getExpireTime()); + } + if (encryptionConfig_ != null) { + output.writeMessage(5, getEncryptionConfig()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(backupId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, backupId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(sourceBackup_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, sourceBackup_); + } + if (expireTime_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getExpireTime()); + } + if (encryptionConfig_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getEncryptionConfig()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.spanner.admin.database.v1.CopyBackupRequest)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.CopyBackupRequest other = + (com.google.spanner.admin.database.v1.CopyBackupRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getBackupId().equals(other.getBackupId())) return false; + if (!getSourceBackup().equals(other.getSourceBackup())) return false; + if (hasExpireTime() != other.hasExpireTime()) return false; + if (hasExpireTime()) { + if (!getExpireTime().equals(other.getExpireTime())) return false; + } + if (hasEncryptionConfig() != other.hasEncryptionConfig()) return false; + if (hasEncryptionConfig()) { + if (!getEncryptionConfig().equals(other.getEncryptionConfig())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + BACKUP_ID_FIELD_NUMBER; + hash = (53 * hash) + getBackupId().hashCode(); + hash = (37 * hash) + SOURCE_BACKUP_FIELD_NUMBER; + hash = (53 * hash) + getSourceBackup().hashCode(); + if (hasExpireTime()) { + hash = (37 * hash) + EXPIRE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getExpireTime().hashCode(); + } + if (hasEncryptionConfig()) { + hash = (37 * hash) + ENCRYPTION_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + getEncryptionConfig().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.spanner.admin.database.v1.CopyBackupRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CopyBackupRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CopyBackupRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CopyBackupRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CopyBackupRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CopyBackupRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CopyBackupRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CopyBackupRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.spanner.admin.database.v1.CopyBackupRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup].
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.CopyBackupRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.CopyBackupRequest) + com.google.spanner.admin.database.v1.CopyBackupRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.CopyBackupRequest.class, + com.google.spanner.admin.database.v1.CopyBackupRequest.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.CopyBackupRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + parent_ = ""; + + backupId_ = ""; + + sourceBackup_ = ""; + + if (expireTimeBuilder_ == null) { + expireTime_ = null; + } else { + expireTime_ = null; + expireTimeBuilder_ = null; + } + if (encryptionConfigBuilder_ == null) { + encryptionConfig_ = null; + } else { + encryptionConfig_ = null; + encryptionConfigBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_CopyBackupRequest_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupRequest getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.CopyBackupRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupRequest build() { + com.google.spanner.admin.database.v1.CopyBackupRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupRequest buildPartial() { + com.google.spanner.admin.database.v1.CopyBackupRequest result = + new com.google.spanner.admin.database.v1.CopyBackupRequest(this); + result.parent_ = parent_; + result.backupId_ = backupId_; + result.sourceBackup_ = sourceBackup_; + if (expireTimeBuilder_ == null) { + result.expireTime_ = expireTime_; + } else { + result.expireTime_ = expireTimeBuilder_.build(); + } + if (encryptionConfigBuilder_ == null) { + result.encryptionConfig_ = encryptionConfig_; + } else { + result.encryptionConfig_ = encryptionConfigBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.spanner.admin.database.v1.CopyBackupRequest) { + return mergeFrom((com.google.spanner.admin.database.v1.CopyBackupRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.spanner.admin.database.v1.CopyBackupRequest other) { + if (other == com.google.spanner.admin.database.v1.CopyBackupRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + onChanged(); + } + if (!other.getBackupId().isEmpty()) { + backupId_ = other.backupId_; + onChanged(); + } + if (!other.getSourceBackup().isEmpty()) { + sourceBackup_ = other.sourceBackup_; + onChanged(); + } + if (other.hasExpireTime()) { + mergeExpireTime(other.getExpireTime()); + } + if (other.hasEncryptionConfig()) { + mergeEncryptionConfig(other.getEncryptionConfig()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.spanner.admin.database.v1.CopyBackupRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.spanner.admin.database.v1.CopyBackupRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object parent_ = ""; + /** + * + * + *
+     * Required. The name of the destination instance that will contain the backup copy.
+     * Values are of the form: `projects/<project>/instances/<instance>`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The name of the destination instance that will contain the backup copy.
+     * Values are of the form: `projects/<project>/instances/<instance>`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The name of the destination instance that will contain the backup copy.
+     * Values are of the form: `projects/<project>/instances/<instance>`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + parent_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the destination instance that will contain the backup copy.
+     * Values are of the form: `projects/<project>/instances/<instance>`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + + parent_ = getDefaultInstance().getParent(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the destination instance that will contain the backup copy.
+     * Values are of the form: `projects/<project>/instances/<instance>`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + parent_ = value; + onChanged(); + return this; + } + + private java.lang.Object backupId_ = ""; + /** + * + * + *
+     * Required. The id of the backup copy.
+     * The `backup_id` appended to `parent` forms the full backup_uri of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The backupId. + */ + public java.lang.String getBackupId() { + java.lang.Object ref = backupId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + backupId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The id of the backup copy.
+     * The `backup_id` appended to `parent` forms the full backup_uri of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for backupId. + */ + public com.google.protobuf.ByteString getBackupIdBytes() { + java.lang.Object ref = backupId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backupId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The id of the backup copy.
+     * The `backup_id` appended to `parent` forms the full backup_uri of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The backupId to set. + * @return This builder for chaining. + */ + public Builder setBackupId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + backupId_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The id of the backup copy.
+     * The `backup_id` appended to `parent` forms the full backup_uri of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearBackupId() { + + backupId_ = getDefaultInstance().getBackupId(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The id of the backup copy.
+     * The `backup_id` appended to `parent` forms the full backup_uri of the form
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for backupId to set. + * @return This builder for chaining. + */ + public Builder setBackupIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + backupId_ = value; + onChanged(); + return this; + } + + private java.lang.Object sourceBackup_ = ""; + /** + * + * + *
+     * Required. The source backup to be copied.
+     * The source backup needs to be in READY state for it to be copied.
+     * Once CopyBackup is in progress, the source backup cannot be deleted or
+     * cleaned up on expiration until CopyBackup is finished.
+     * Values are of the form:
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * + * string source_backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The sourceBackup. + */ + public java.lang.String getSourceBackup() { + java.lang.Object ref = sourceBackup_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + sourceBackup_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The source backup to be copied.
+     * The source backup needs to be in READY state for it to be copied.
+     * Once CopyBackup is in progress, the source backup cannot be deleted or
+     * cleaned up on expiration until CopyBackup is finished.
+     * Values are of the form:
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * + * string source_backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for sourceBackup. + */ + public com.google.protobuf.ByteString getSourceBackupBytes() { + java.lang.Object ref = sourceBackup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + sourceBackup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The source backup to be copied.
+     * The source backup needs to be in READY state for it to be copied.
+     * Once CopyBackup is in progress, the source backup cannot be deleted or
+     * cleaned up on expiration until CopyBackup is finished.
+     * Values are of the form:
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * + * string source_backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The sourceBackup to set. + * @return This builder for chaining. + */ + public Builder setSourceBackup(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + sourceBackup_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The source backup to be copied.
+     * The source backup needs to be in READY state for it to be copied.
+     * Once CopyBackup is in progress, the source backup cannot be deleted or
+     * cleaned up on expiration until CopyBackup is finished.
+     * Values are of the form:
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * + * string source_backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearSourceBackup() { + + sourceBackup_ = getDefaultInstance().getSourceBackup(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The source backup to be copied.
+     * The source backup needs to be in READY state for it to be copied.
+     * Once CopyBackup is in progress, the source backup cannot be deleted or
+     * cleaned up on expiration until CopyBackup is finished.
+     * Values are of the form:
+     * `projects/<project>/instances/<instance>/backups/<backup>`.
+     * 
+ * + * + * string source_backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for sourceBackup to set. + * @return This builder for chaining. + */ + public Builder setSourceBackupBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + sourceBackup_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp expireTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + expireTimeBuilder_; + /** + * + * + *
+     * Required. The expiration time of the backup in microsecond granularity.
+     * The expiration time must be at least 6 hours and at most 366 days
+     * from the `create_time` of the source backup. Once the `expire_time` has
+     * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+     * to free the resources used by the backup.
+     * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the expireTime field is set. + */ + public boolean hasExpireTime() { + return expireTimeBuilder_ != null || expireTime_ != null; + } + /** + * + * + *
+     * Required. The expiration time of the backup in microsecond granularity.
+     * The expiration time must be at least 6 hours and at most 366 days
+     * from the `create_time` of the source backup. Once the `expire_time` has
+     * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+     * to free the resources used by the backup.
+     * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The expireTime. + */ + public com.google.protobuf.Timestamp getExpireTime() { + if (expireTimeBuilder_ == null) { + return expireTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : expireTime_; + } else { + return expireTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. The expiration time of the backup in microsecond granularity.
+     * The expiration time must be at least 6 hours and at most 366 days
+     * from the `create_time` of the source backup. Once the `expire_time` has
+     * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+     * to free the resources used by the backup.
+     * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setExpireTime(com.google.protobuf.Timestamp value) { + if (expireTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + expireTime_ = value; + onChanged(); + } else { + expireTimeBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Required. The expiration time of the backup in microsecond granularity.
+     * The expiration time must be at least 6 hours and at most 366 days
+     * from the `create_time` of the source backup. Once the `expire_time` has
+     * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+     * to free the resources used by the backup.
+     * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setExpireTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (expireTimeBuilder_ == null) { + expireTime_ = builderForValue.build(); + onChanged(); + } else { + expireTimeBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Required. The expiration time of the backup in microsecond granularity.
+     * The expiration time must be at least 6 hours and at most 366 days
+     * from the `create_time` of the source backup. Once the `expire_time` has
+     * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+     * to free the resources used by the backup.
+     * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeExpireTime(com.google.protobuf.Timestamp value) { + if (expireTimeBuilder_ == null) { + if (expireTime_ != null) { + expireTime_ = + com.google.protobuf.Timestamp.newBuilder(expireTime_).mergeFrom(value).buildPartial(); + } else { + expireTime_ = value; + } + onChanged(); + } else { + expireTimeBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Required. The expiration time of the backup in microsecond granularity.
+     * The expiration time must be at least 6 hours and at most 366 days
+     * from the `create_time` of the source backup. Once the `expire_time` has
+     * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+     * to free the resources used by the backup.
+     * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearExpireTime() { + if (expireTimeBuilder_ == null) { + expireTime_ = null; + onChanged(); + } else { + expireTime_ = null; + expireTimeBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Required. The expiration time of the backup in microsecond granularity.
+     * The expiration time must be at least 6 hours and at most 366 days
+     * from the `create_time` of the source backup. Once the `expire_time` has
+     * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+     * to free the resources used by the backup.
+     * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.protobuf.Timestamp.Builder getExpireTimeBuilder() { + + onChanged(); + return getExpireTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. The expiration time of the backup in microsecond granularity.
+     * The expiration time must be at least 6 hours and at most 366 days
+     * from the `create_time` of the source backup. Once the `expire_time` has
+     * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+     * to free the resources used by the backup.
+     * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder() { + if (expireTimeBuilder_ != null) { + return expireTimeBuilder_.getMessageOrBuilder(); + } else { + return expireTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : expireTime_; + } + } + /** + * + * + *
+     * Required. The expiration time of the backup in microsecond granularity.
+     * The expiration time must be at least 6 hours and at most 366 days
+     * from the `create_time` of the source backup. Once the `expire_time` has
+     * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+     * to free the resources used by the backup.
+     * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getExpireTimeFieldBuilder() { + if (expireTimeBuilder_ == null) { + expireTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getExpireTime(), getParentForChildren(), isClean()); + expireTime_ = null; + } + return expireTimeBuilder_; + } + + private com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryptionConfig_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig, + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.Builder, + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfigOrBuilder> + encryptionConfigBuilder_; + /** + * + * + *
+     * Optional. The encryption configuration used to encrypt the backup. If this field is
+     * not specified, the backup will use the same
+     * encryption configuration as the source backup by default, namely
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+     * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the encryptionConfig field is set. + */ + public boolean hasEncryptionConfig() { + return encryptionConfigBuilder_ != null || encryptionConfig_ != null; + } + /** + * + * + *
+     * Optional. The encryption configuration used to encrypt the backup. If this field is
+     * not specified, the backup will use the same
+     * encryption configuration as the source backup by default, namely
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+     * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The encryptionConfig. + */ + public com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig getEncryptionConfig() { + if (encryptionConfigBuilder_ == null) { + return encryptionConfig_ == null + ? com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } else { + return encryptionConfigBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Optional. The encryption configuration used to encrypt the backup. If this field is
+     * not specified, the backup will use the same
+     * encryption configuration as the source backup by default, namely
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+     * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setEncryptionConfig( + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig value) { + if (encryptionConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + encryptionConfig_ = value; + onChanged(); + } else { + encryptionConfigBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Optional. The encryption configuration used to encrypt the backup. If this field is
+     * not specified, the backup will use the same
+     * encryption configuration as the source backup by default, namely
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+     * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setEncryptionConfig( + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.Builder builderForValue) { + if (encryptionConfigBuilder_ == null) { + encryptionConfig_ = builderForValue.build(); + onChanged(); + } else { + encryptionConfigBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Optional. The encryption configuration used to encrypt the backup. If this field is
+     * not specified, the backup will use the same
+     * encryption configuration as the source backup by default, namely
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+     * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeEncryptionConfig( + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig value) { + if (encryptionConfigBuilder_ == null) { + if (encryptionConfig_ != null) { + encryptionConfig_ = + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.newBuilder( + encryptionConfig_) + .mergeFrom(value) + .buildPartial(); + } else { + encryptionConfig_ = value; + } + onChanged(); + } else { + encryptionConfigBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Optional. The encryption configuration used to encrypt the backup. If this field is
+     * not specified, the backup will use the same
+     * encryption configuration as the source backup by default, namely
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+     * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearEncryptionConfig() { + if (encryptionConfigBuilder_ == null) { + encryptionConfig_ = null; + onChanged(); + } else { + encryptionConfig_ = null; + encryptionConfigBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Optional. The encryption configuration used to encrypt the backup. If this field is
+     * not specified, the backup will use the same
+     * encryption configuration as the source backup by default, namely
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+     * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.Builder + getEncryptionConfigBuilder() { + + onChanged(); + return getEncryptionConfigFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Optional. The encryption configuration used to encrypt the backup. If this field is
+     * not specified, the backup will use the same
+     * encryption configuration as the source backup by default, namely
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+     * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.spanner.admin.database.v1.CopyBackupEncryptionConfigOrBuilder + getEncryptionConfigOrBuilder() { + if (encryptionConfigBuilder_ != null) { + return encryptionConfigBuilder_.getMessageOrBuilder(); + } else { + return encryptionConfig_ == null + ? com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } + } + /** + * + * + *
+     * Optional. The encryption configuration used to encrypt the backup. If this field is
+     * not specified, the backup will use the same
+     * encryption configuration as the source backup by default, namely
+     * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+     * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig, + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.Builder, + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfigOrBuilder> + getEncryptionConfigFieldBuilder() { + if (encryptionConfigBuilder_ == null) { + encryptionConfigBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig, + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.Builder, + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfigOrBuilder>( + getEncryptionConfig(), getParentForChildren(), isClean()); + encryptionConfig_ = null; + } + return encryptionConfigBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.spanner.admin.database.v1.CopyBackupRequest) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.CopyBackupRequest) + private static final com.google.spanner.admin.database.v1.CopyBackupRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.CopyBackupRequest(); + } + + public static com.google.spanner.admin.database.v1.CopyBackupRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CopyBackupRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CopyBackupRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CopyBackupRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupRequestOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupRequestOrBuilder.java new file mode 100644 index 00000000000..5a8be05a57e --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CopyBackupRequestOrBuilder.java @@ -0,0 +1,228 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup.proto + +package com.google.spanner.admin.database.v1; + +public interface CopyBackupRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.CopyBackupRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The name of the destination instance that will contain the backup copy.
+   * Values are of the form: `projects/<project>/instances/<instance>`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + /** + * + * + *
+   * Required. The name of the destination instance that will contain the backup copy.
+   * Values are of the form: `projects/<project>/instances/<instance>`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. The id of the backup copy.
+   * The `backup_id` appended to `parent` forms the full backup_uri of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The backupId. + */ + java.lang.String getBackupId(); + /** + * + * + *
+   * Required. The id of the backup copy.
+   * The `backup_id` appended to `parent` forms the full backup_uri of the form
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for backupId. + */ + com.google.protobuf.ByteString getBackupIdBytes(); + + /** + * + * + *
+   * Required. The source backup to be copied.
+   * The source backup needs to be in READY state for it to be copied.
+   * Once CopyBackup is in progress, the source backup cannot be deleted or
+   * cleaned up on expiration until CopyBackup is finished.
+   * Values are of the form:
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * + * string source_backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The sourceBackup. + */ + java.lang.String getSourceBackup(); + /** + * + * + *
+   * Required. The source backup to be copied.
+   * The source backup needs to be in READY state for it to be copied.
+   * Once CopyBackup is in progress, the source backup cannot be deleted or
+   * cleaned up on expiration until CopyBackup is finished.
+   * Values are of the form:
+   * `projects/<project>/instances/<instance>/backups/<backup>`.
+   * 
+ * + * + * string source_backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for sourceBackup. + */ + com.google.protobuf.ByteString getSourceBackupBytes(); + + /** + * + * + *
+   * Required. The expiration time of the backup in microsecond granularity.
+   * The expiration time must be at least 6 hours and at most 366 days
+   * from the `create_time` of the source backup. Once the `expire_time` has
+   * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+   * to free the resources used by the backup.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the expireTime field is set. + */ + boolean hasExpireTime(); + /** + * + * + *
+   * Required. The expiration time of the backup in microsecond granularity.
+   * The expiration time must be at least 6 hours and at most 366 days
+   * from the `create_time` of the source backup. Once the `expire_time` has
+   * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+   * to free the resources used by the backup.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The expireTime. + */ + com.google.protobuf.Timestamp getExpireTime(); + /** + * + * + *
+   * Required. The expiration time of the backup in microsecond granularity.
+   * The expiration time must be at least 6 hours and at most 366 days
+   * from the `create_time` of the source backup. Once the `expire_time` has
+   * passed, the backup is eligible to be automatically deleted by Cloud Spanner
+   * to free the resources used by the backup.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder(); + + /** + * + * + *
+   * Optional. The encryption configuration used to encrypt the backup. If this field is
+   * not specified, the backup will use the same
+   * encryption configuration as the source backup by default, namely
+   * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+   * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the encryptionConfig field is set. + */ + boolean hasEncryptionConfig(); + /** + * + * + *
+   * Optional. The encryption configuration used to encrypt the backup. If this field is
+   * not specified, the backup will use the same
+   * encryption configuration as the source backup by default, namely
+   * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+   * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The encryptionConfig. + */ + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig getEncryptionConfig(); + /** + * + * + *
+   * Optional. The encryption configuration used to encrypt the backup. If this field is
+   * not specified, the backup will use the same
+   * encryption configuration as the source backup by default, namely
+   * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
+   * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.spanner.admin.database.v1.CopyBackupEncryptionConfigOrBuilder + getEncryptionConfigOrBuilder(); +} 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 1acad6985e1..acf6b082723 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 @@ -215,7 +215,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "\n\010progress\030\002 \001(\01323.google.spanner.admin." + "database.v1.OperationProgress*5\n\021Restore" + "SourceType\022\024\n\020TYPE_UNSPECIFIED\020\000\022\n\n\006BACK" - + "UP\020\0012\223\037\n\rDatabaseAdmin\022\300\001\n\rListDatabases" + + "UP\020\0012\302!\n\rDatabaseAdmin\022\300\001\n\rListDatabases" + "\0226.google.spanner.admin.database.v1.List" + "DatabasesRequest\0327.google.spanner.admin." + "database.v1.ListDatabasesResponse\">\202\323\344\223\002" @@ -274,56 +274,64 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "/*/instances/*}/backups:\006backup\332A\027parent" + ",backup,backup_id\312A`\n\'google.spanner.adm" + "in.database.v1.Backup\0225google.spanner.ad" - + "min.database.v1.CreateBackupMetadata\022\245\001\n" - + "\tGetBackup\0222.google.spanner.admin.databa" - + "se.v1.GetBackupRequest\032(.google.spanner." - + "admin.database.v1.Backup\":\202\323\344\223\002-\022+/v1/{n" - + "ame=projects/*/instances/*/backups/*}\332A\004" - + "name\022\310\001\n\014UpdateBackup\0225.google.spanner.a" - + "dmin.database.v1.UpdateBackupRequest\032(.g" - + "oogle.spanner.admin.database.v1.Backup\"W" - + "\202\323\344\223\002<22/v1/{backup.name=projects/*/inst" - + "ances/*/backups/*}:\006backup\332A\022backup,upda" - + "te_mask\022\231\001\n\014DeleteBackup\0225.google.spanne" - + "r.admin.database.v1.DeleteBackupRequest\032" - + "\026.google.protobuf.Empty\":\202\323\344\223\002-*+/v1/{na" - + "me=projects/*/instances/*/backups/*}\332A\004n" - + "ame\022\270\001\n\013ListBackups\0224.google.spanner.adm" - + "in.database.v1.ListBackupsRequest\0325.goog" - + "le.spanner.admin.database.v1.ListBackups" - + "Response\"<\202\323\344\223\002-\022+/v1/{parent=projects/*" - + "/instances/*}/backups\332A\006parent\022\261\002\n\017Resto" - + "reDatabase\0228.google.spanner.admin.databa" - + "se.v1.RestoreDatabaseRequest\032\035.google.lo" - + "ngrunning.Operation\"\304\001\202\323\344\223\002:\"5/v1/{paren" - + "t=projects/*/instances/*}/databases:rest" - + "ore:\001*\332A\031parent,database_id,backup\312Ae\n)g" - + "oogle.spanner.admin.database.v1.Database" - + "\0228google.spanner.admin.database.v1.Resto" - + "reDatabaseMetadata\022\344\001\n\026ListDatabaseOpera" - + "tions\022?.google.spanner.admin.database.v1" - + ".ListDatabaseOperationsRequest\032@.google." - + "spanner.admin.database.v1.ListDatabaseOp" - + "erationsResponse\"G\202\323\344\223\0028\0226/v1/{parent=pr" - + "ojects/*/instances/*}/databaseOperations" - + "\332A\006parent\022\334\001\n\024ListBackupOperations\022=.goo" - + "gle.spanner.admin.database.v1.ListBackup" - + "OperationsRequest\032>.google.spanner.admin" - + ".database.v1.ListBackupOperationsRespons" - + "e\"E\202\323\344\223\0026\0224/v1/{parent=projects/*/instan" - + "ces/*}/backupOperations\332A\006parent\032x\312A\026spa" - + "nner.googleapis.com\322A\\https://www.google" - + "apis.com/auth/cloud-platform,https://www" - + ".googleapis.com/auth/spanner.adminB\332\002\n$c" - + "om.google.spanner.admin.database.v1B\031Spa" - + "nnerDatabaseAdminProtoP\001ZHgoogle.golang." - + "org/genproto/googleapis/spanner/admin/da" - + "tabase/v1;database\252\002&Google.Cloud.Spanne" - + "r.Admin.Database.V1\312\002&Google\\Cloud\\Spann" - + "er\\Admin\\Database\\V1\352\002+Google::Cloud::Sp" - + "anner::Admin::Database::V1\352AJ\n\037spanner.g" - + "oogleapis.com/Instance\022\'projects/{projec" - + "t}/instances/{instance}b\006proto3" + + "min.database.v1.CreateBackupMetadata\022\254\002\n" + + "\nCopyBackup\0223.google.spanner.admin.datab" + + "ase.v1.CopyBackupRequest\032\035.google.longru" + + "nning.Operation\"\311\001\202\323\344\223\0025\"0/v1/{parent=pr" + + "ojects/*/instances/*}/backups:copy:\001*\332A*" + + "parent,backup_id,source_backup,expire_ti" + + "me\312A^\n\'google.spanner.admin.database.v1." + + "Backup\0223google.spanner.admin.database.v1" + + ".CopyBackupMetadata\022\245\001\n\tGetBackup\0222.goog" + + "le.spanner.admin.database.v1.GetBackupRe" + + "quest\032(.google.spanner.admin.database.v1" + + ".Backup\":\202\323\344\223\002-\022+/v1/{name=projects/*/in" + + "stances/*/backups/*}\332A\004name\022\310\001\n\014UpdateBa" + + "ckup\0225.google.spanner.admin.database.v1." + + "UpdateBackupRequest\032(.google.spanner.adm" + + "in.database.v1.Backup\"W\202\323\344\223\002<22/v1/{back" + + "up.name=projects/*/instances/*/backups/*" + + "}:\006backup\332A\022backup,update_mask\022\231\001\n\014Delet" + + "eBackup\0225.google.spanner.admin.database." + + "v1.DeleteBackupRequest\032\026.google.protobuf" + + ".Empty\":\202\323\344\223\002-*+/v1/{name=projects/*/ins" + + "tances/*/backups/*}\332A\004name\022\270\001\n\013ListBacku" + + "ps\0224.google.spanner.admin.database.v1.Li" + + "stBackupsRequest\0325.google.spanner.admin." + + "database.v1.ListBackupsResponse\"<\202\323\344\223\002-\022" + + "+/v1/{parent=projects/*/instances/*}/bac" + + "kups\332A\006parent\022\261\002\n\017RestoreDatabase\0228.goog" + + "le.spanner.admin.database.v1.RestoreData" + + "baseRequest\032\035.google.longrunning.Operati" + + "on\"\304\001\202\323\344\223\002:\"5/v1/{parent=projects/*/inst" + + "ances/*}/databases:restore:\001*\332A\031parent,d" + + "atabase_id,backup\312Ae\n)google.spanner.adm" + + "in.database.v1.Database\0228google.spanner." + + "admin.database.v1.RestoreDatabaseMetadat" + + "a\022\344\001\n\026ListDatabaseOperations\022?.google.sp" + + "anner.admin.database.v1.ListDatabaseOper" + + "ationsRequest\032@.google.spanner.admin.dat" + + "abase.v1.ListDatabaseOperationsResponse\"" + + "G\202\323\344\223\0028\0226/v1/{parent=projects/*/instance" + + "s/*}/databaseOperations\332A\006parent\022\334\001\n\024Lis" + + "tBackupOperations\022=.google.spanner.admin" + + ".database.v1.ListBackupOperationsRequest" + + "\032>.google.spanner.admin.database.v1.List" + + "BackupOperationsResponse\"E\202\323\344\223\0026\0224/v1/{p" + + "arent=projects/*/instances/*}/backupOper" + + "ations\332A\006parent\032x\312A\026spanner.googleapis.c" + + "om\322A\\https://www.googleapis.com/auth/clo" + + "ud-platform,https://www.googleapis.com/a" + + "uth/spanner.adminB\332\002\n$com.google.spanner" + + ".admin.database.v1B\031SpannerDatabaseAdmin" + + "ProtoP\001ZHgoogle.golang.org/genproto/goog" + + "leapis/spanner/admin/database/v1;databas" + + "e\252\002&Google.Cloud.Spanner.Admin.Database." + + "V1\312\002&Google\\Cloud\\Spanner\\Admin\\Database" + + "\\V1\352\002+Google::Cloud::Spanner::Admin::Dat" + + "abase::V1\352AJ\n\037spanner.googleapis.com/Ins" + + "tance\022\'projects/{project}/instances/{ins" + + "tance}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 1e9ce30058a..2e13de450e2 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 @@ -120,6 +120,27 @@ message Backup { // Output only. The database dialect information for the backup. DatabaseDialect database_dialect = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The names of the destination backups being created by copying + // this source backup. The backup names are of the form + // `projects//instances//backups/`. + // Referencing backups may exist in different instances. The existence of + // any referencing backup prevents the backup from being deleted. When the + // copy operation is done (either successfully completed or cancelled or the + // destination backup is deleted), the reference to the backup is removed. + repeated string referencing_backups = 11 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + } + ]; + + // Output only. The max allowed expiration time of the backup, with + // microseconds granularity. A backup's expiration time can be configured in + // multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or + // copying an existing backup, the expiration time specified must be + // less than `Backup.max_expire_time`. + google.protobuf.Timestamp max_expire_time = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; } // The request for [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]. @@ -185,6 +206,84 @@ message CreateBackupMetadata { google.protobuf.Timestamp cancel_time = 4; } +// The request for [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]. +message CopyBackupRequest { + // Required. The name of the destination instance that will contain the backup copy. + // Values are of the form: `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // Required. The id of the backup copy. + // The `backup_id` appended to `parent` forms the full backup_uri of the form + // `projects//instances//backups/`. + string backup_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The source backup to be copied. + // The source backup needs to be in READY state for it to be copied. + // Once CopyBackup is in progress, the source backup cannot be deleted or + // cleaned up on expiration until CopyBackup is finished. + // Values are of the form: + // `projects//instances//backups/`. + string source_backup = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + } + ]; + + // Required. The expiration time of the backup in microsecond granularity. + // The expiration time must be at least 6 hours and at most 366 days + // from the `create_time` of the source backup. Once the `expire_time` has + // passed, the backup is eligible to be automatically deleted by Cloud Spanner + // to free the resources used by the backup. + google.protobuf.Timestamp expire_time = 4 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The encryption configuration used to encrypt the backup. If this field is + // not specified, the backup will use the same + // encryption configuration as the source backup by default, namely + // [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] = + // `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + CopyBackupEncryptionConfig encryption_config = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +// Metadata type for the google.longrunning.Operation returned by +// [CopyBackup][DatabaseAdmin.CopyBackup]. +message CopyBackupMetadata { + // The name of the backup being created through the copy operation. + // Values are of the form + // `projects//instances//backups/`. + string name = 1 + [(google.api.resource_reference).type = "spanner.googleapis.com/Backup"]; + + // The name of the source backup that is being copied. + // Values are of the form + // `projects//instances//backups/`. + string source_backup = 2 + [(google.api.resource_reference).type = "spanner.googleapis.com/Backup"]; + + // The progress of the + // [CopyBackup][DatabaseAdmin.CopyBackup] operation. + OperationProgress progress = 3; + + // The time at which cancellation of CopyBackup operation was received. + // [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + // starts asynchronous cancellation on a long-running operation. The server + // makes a best effort to cancel the operation, but success is not guaranteed. + // Clients can use + // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + // other methods to check whether the cancellation succeeded or whether the + // operation completed despite cancellation. On successful cancellation, + // the operation is not deleted; instead, it becomes an operation with + // an [Operation.error][google.longrunning.Operation.error] value with a + // [google.rpc.Status.code][] of 1, + // corresponding to `Code.CANCELLED`. + google.protobuf.Timestamp cancel_time = 4; +} + // The request for [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup]. message UpdateBackupRequest { // Required. The backup to update. `backup.name`, and the fields to be updated @@ -442,3 +541,40 @@ message CreateBackupEncryptionConfig { } ]; } + +// Encryption configuration for the copied backup. +message CopyBackupEncryptionConfig { + // Encryption types for the backup. + enum EncryptionType { + // Unspecified. Do not use. + ENCRYPTION_TYPE_UNSPECIFIED = 0; + + // This is the default option for [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup] + // when [encryption_config][google.spanner.admin.database.v1.CopyBackupEncryptionConfig] is not specified. + // For example, if the source backup is using `Customer_Managed_Encryption`, + // the backup will be using the same Cloud KMS key as the source backup. + USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1; + + // Use Google default encryption. + GOOGLE_DEFAULT_ENCRYPTION = 2; + + // Use customer managed encryption. If specified, `kms_key_name` + // must contain a valid Cloud KMS key. + CUSTOMER_MANAGED_ENCRYPTION = 3; + } + + // Required. The encryption type of the backup. + EncryptionType encryption_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The Cloud KMS key that will be used to protect the backup. + // This field should be set only when + // [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] is + // `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + // `projects//locations//keyRings//cryptoKeys/`. + string kms_key_name = 2 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + } + ]; +} 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 89d582412db..bedaef804cf 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 @@ -216,6 +216,30 @@ service DatabaseAdmin { }; } + // Starts copying a Cloud Spanner Backup. + // The returned backup [long-running operation][google.longrunning.Operation] + // will have a name of the format + // `projects//instances//backups//operations/` + // and can be used to track copying of the backup. The operation is associated + // with the destination backup. + // The [metadata][google.longrunning.Operation.metadata] field type is + // [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + // 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 + // copying and delete the backup. + // Concurrent CopyBackup requests can run on the same source backup. + rpc CopyBackup(CopyBackupRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/instances/*}/backups:copy" + body: "*" + }; + option (google.api.method_signature) = "parent,backup_id,source_backup,expire_time"; + option (google.longrunning.operation_info) = { + response_type: "google.spanner.admin.database.v1.Backup" + metadata_type: "google.spanner.admin.database.v1.CopyBackupMetadata" + }; + } + // Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. rpc GetBackup(GetBackupRequest) returns (Backup) { option (google.api.http) = { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/Instance.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/Instance.java index b24629fb2cd..ecae61417bd 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/Instance.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/Instance.java @@ -359,7 +359,7 @@ private State(int value) { * segment of the name must be between 2 and 64 characters in length. * * - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The name. */ @@ -385,7 +385,7 @@ public java.lang.String getName() { * segment of the name must be between 2 and 64 characters in length. * * - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for name. */ @@ -414,7 +414,9 @@ public com.google.protobuf.ByteString getNameBytes() { * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. * * - * string config = 2 [(.google.api.resource_reference) = { ... } + * + * string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return The config. */ @@ -440,7 +442,9 @@ public java.lang.String getConfig() { * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. * * - * string config = 2 [(.google.api.resource_reference) = { ... } + * + * string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return The bytes for config. */ @@ -467,7 +471,7 @@ public com.google.protobuf.ByteString getConfigBytes() { * Must be unique per project and between 4 and 30 characters in length. * * - * string display_name = 3; + * string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; * * @return The displayName. */ @@ -491,7 +495,7 @@ public java.lang.String getDisplayName() { * Must be unique per project and between 4 and 30 characters in length. * * - * string display_name = 3; + * string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for displayName. */ @@ -1310,7 +1314,7 @@ public Builder mergeFrom( * segment of the name must be between 2 and 64 characters in length. * * - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The name. */ @@ -1335,7 +1339,7 @@ public java.lang.String getName() { * segment of the name must be between 2 and 64 characters in length. * * - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for name. */ @@ -1360,7 +1364,7 @@ public com.google.protobuf.ByteString getNameBytes() { * segment of the name must be between 2 and 64 characters in length. * * - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The name to set. * @return This builder for chaining. @@ -1384,7 +1388,7 @@ public Builder setName(java.lang.String value) { * segment of the name must be between 2 and 64 characters in length. * * - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return This builder for chaining. */ @@ -1404,7 +1408,7 @@ public Builder clearName() { * segment of the name must be between 2 and 64 characters in length. * * - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The bytes for name to set. * @return This builder for chaining. @@ -1431,7 +1435,9 @@ public Builder setNameBytes(com.google.protobuf.ByteString value) { * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. * * - * string config = 2 [(.google.api.resource_reference) = { ... } + * + * string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return The config. */ @@ -1456,7 +1462,9 @@ public java.lang.String getConfig() { * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. * * - * string config = 2 [(.google.api.resource_reference) = { ... } + * + * string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return The bytes for config. */ @@ -1481,7 +1489,9 @@ public com.google.protobuf.ByteString getConfigBytes() { * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. * * - * string config = 2 [(.google.api.resource_reference) = { ... } + * + * string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @param value The config to set. * @return This builder for chaining. @@ -1505,7 +1515,9 @@ public Builder setConfig(java.lang.String value) { * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. * * - * string config = 2 [(.google.api.resource_reference) = { ... } + * + * string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return This builder for chaining. */ @@ -1525,7 +1537,9 @@ public Builder clearConfig() { * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. * * - * string config = 2 [(.google.api.resource_reference) = { ... } + * + * string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @param value The bytes for config to set. * @return This builder for chaining. @@ -1550,7 +1564,7 @@ public Builder setConfigBytes(com.google.protobuf.ByteString value) { * Must be unique per project and between 4 and 30 characters in length. * * - * string display_name = 3; + * string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; * * @return The displayName. */ @@ -1573,7 +1587,7 @@ public java.lang.String getDisplayName() { * Must be unique per project and between 4 and 30 characters in length. * * - * string display_name = 3; + * string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for displayName. */ @@ -1596,7 +1610,7 @@ public com.google.protobuf.ByteString getDisplayNameBytes() { * Must be unique per project and between 4 and 30 characters in length. * * - * string display_name = 3; + * string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; * * @param value The displayName to set. * @return This builder for chaining. @@ -1618,7 +1632,7 @@ public Builder setDisplayName(java.lang.String value) { * Must be unique per project and between 4 and 30 characters in length. * * - * string display_name = 3; + * string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; * * @return This builder for chaining. */ @@ -1636,7 +1650,7 @@ public Builder clearDisplayName() { * Must be unique per project and between 4 and 30 characters in length. * * - * string display_name = 3; + * string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; * * @param value The bytes for displayName to set. * @return This builder for chaining. diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceOrBuilder.java index a41182efe90..450b7a99ddd 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceOrBuilder.java @@ -33,7 +33,7 @@ public interface InstanceOrBuilder * segment of the name must be between 2 and 64 characters in length. * * - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The name. */ @@ -48,7 +48,7 @@ public interface InstanceOrBuilder * segment of the name must be between 2 and 64 characters in length. * * - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for name. */ @@ -64,7 +64,9 @@ public interface InstanceOrBuilder * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. * * - * string config = 2 [(.google.api.resource_reference) = { ... } + * + * string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return The config. */ @@ -79,7 +81,9 @@ public interface InstanceOrBuilder * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. * * - * string config = 2 [(.google.api.resource_reference) = { ... } + * + * string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return The bytes for config. */ @@ -93,7 +97,7 @@ public interface InstanceOrBuilder * Must be unique per project and between 4 and 30 characters in length. * * - * string display_name = 3; + * string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; * * @return The displayName. */ @@ -106,7 +110,7 @@ public interface InstanceOrBuilder * Must be unique per project and between 4 and 30 characters in length. * * - * string display_name = 3; + * string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for displayName. */ 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 d0134d0cda7..dfe7849894e 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 @@ -117,120 +117,121 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "in.instance.v1.ReplicaInfo\022\026\n\016leader_opt" + "ions\030\004 \003(\t:`\352A]\n%spanner.googleapis.com/" + "InstanceConfig\0224projects/{project}/insta" - + "nceConfigs/{instance_config}\"\364\003\n\010Instanc" - + "e\022\014\n\004name\030\001 \001(\t\022:\n\006config\030\002 \001(\tB*\372A\'\n%sp" - + "anner.googleapis.com/InstanceConfig\022\024\n\014d" - + "isplay_name\030\003 \001(\t\022\022\n\nnode_count\030\005 \001(\005\022\030\n" - + "\020processing_units\030\t \001(\005\022D\n\005state\030\006 \001(\01620" - + ".google.spanner.admin.instance.v1.Instan" - + "ce.StateB\003\340A\003\022F\n\006labels\030\007 \003(\01326.google.s" - + "panner.admin.instance.v1.Instance.Labels" - + "Entry\022\025\n\rendpoint_uris\030\010 \003(\t\032-\n\013LabelsEn" - + "try\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"7\n\005S" - + "tate\022\025\n\021STATE_UNSPECIFIED\020\000\022\014\n\010CREATING\020" - + "\001\022\t\n\005READY\020\002:M\352AJ\n\037spanner.googleapis.co" - + "m/Instance\022\'projects/{project}/instances" - + "/{instance}\"\210\001\n\032ListInstanceConfigsReque" - + "st\022C\n\006parent\030\001 \001(\tB3\340A\002\372A-\n+cloudresourc" - + "emanager.googleapis.com/Project\022\021\n\tpage_" - + "size\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\"\202\001\n\033ListI" - + "nstanceConfigsResponse\022J\n\020instance_confi" - + "gs\030\001 \003(\01320.google.spanner.admin.instance" - + ".v1.InstanceConfig\022\027\n\017next_page_token\030\002 " - + "\001(\t\"W\n\030GetInstanceConfigRequest\022;\n\004name\030" - + "\001 \001(\tB-\340A\002\372A\'\n%spanner.googleapis.com/In" - + "stanceConfig\"{\n\022GetInstanceRequest\0225\n\004na" - + "me\030\001 \001(\tB\'\340A\002\372A!\n\037spanner.googleapis.com" - + "/Instance\022.\n\nfield_mask\030\002 \001(\0132\032.google.p" - + "rotobuf.FieldMask\"\271\001\n\025CreateInstanceRequ" + + "nceConfigs/{instance_config}\"\201\004\n\010Instanc" + + "e\022\021\n\004name\030\001 \001(\tB\003\340A\002\022=\n\006config\030\002 \001(\tB-\340A" + + "\002\372A\'\n%spanner.googleapis.com/InstanceCon" + + "fig\022\031\n\014display_name\030\003 \001(\tB\003\340A\002\022\022\n\nnode_c" + + "ount\030\005 \001(\005\022\030\n\020processing_units\030\t \001(\005\022D\n\005" + + "state\030\006 \001(\01620.google.spanner.admin.insta" + + "nce.v1.Instance.StateB\003\340A\003\022F\n\006labels\030\007 \003" + + "(\01326.google.spanner.admin.instance.v1.In" + + "stance.LabelsEntry\022\025\n\rendpoint_uris\030\010 \003(" + + "\t\032-\n\013LabelsEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002" + + " \001(\t:\0028\001\"7\n\005State\022\025\n\021STATE_UNSPECIFIED\020\000" + + "\022\014\n\010CREATING\020\001\022\t\n\005READY\020\002:M\352AJ\n\037spanner." + + "googleapis.com/Instance\022\'projects/{proje" + + "ct}/instances/{instance}\"\210\001\n\032ListInstanc" + + "eConfigsRequest\022C\n\006parent\030\001 \001(\tB3\340A\002\372A-\n" + + "+cloudresourcemanager.googleapis.com/Pro" + + "ject\022\021\n\tpage_size\030\002 \001(\005\022\022\n\npage_token\030\003 " + + "\001(\t\"\202\001\n\033ListInstanceConfigsResponse\022J\n\020i" + + "nstance_configs\030\001 \003(\01320.google.spanner.a" + + "dmin.instance.v1.InstanceConfig\022\027\n\017next_" + + "page_token\030\002 \001(\t\"W\n\030GetInstanceConfigReq" + + "uest\022;\n\004name\030\001 \001(\tB-\340A\002\372A\'\n%spanner.goog" + + "leapis.com/InstanceConfig\"{\n\022GetInstance" + + "Request\0225\n\004name\030\001 \001(\tB\'\340A\002\372A!\n\037spanner.g" + + "oogleapis.com/Instance\022.\n\nfield_mask\030\002 \001" + + "(\0132\032.google.protobuf.FieldMask\"\271\001\n\025Creat" + + "eInstanceRequest\022C\n\006parent\030\001 \001(\tB3\340A\002\372A-" + + "\n+cloudresourcemanager.googleapis.com/Pr" + + "oject\022\030\n\013instance_id\030\002 \001(\tB\003\340A\002\022A\n\010insta" + + "nce\030\003 \001(\0132*.google.spanner.admin.instanc" + + "e.v1.InstanceB\003\340A\002\"\222\001\n\024ListInstancesRequ" + "est\022C\n\006parent\030\001 \001(\tB3\340A\002\372A-\n+cloudresour" - + "cemanager.googleapis.com/Project\022\030\n\013inst" - + "ance_id\030\002 \001(\tB\003\340A\002\022A\n\010instance\030\003 \001(\0132*.g" + + "cemanager.googleapis.com/Project\022\021\n\tpage" + + "_size\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\022\016\n\006filte" + + "r\030\004 \001(\t\"o\n\025ListInstancesResponse\022=\n\tinst" + + "ances\030\001 \003(\0132*.google.spanner.admin.insta" + + "nce.v1.Instance\022\027\n\017next_page_token\030\002 \001(\t" + + "\"\217\001\n\025UpdateInstanceRequest\022A\n\010instance\030\001" + + " \001(\0132*.google.spanner.admin.instance.v1." + + "InstanceB\003\340A\002\0223\n\nfield_mask\030\002 \001(\0132\032.goog" + + "le.protobuf.FieldMaskB\003\340A\002\"N\n\025DeleteInst" + + "anceRequest\0225\n\004name\030\001 \001(\tB\'\340A\002\372A!\n\037spann" + + "er.googleapis.com/Instance\"\345\001\n\026CreateIns" + + "tanceMetadata\022<\n\010instance\030\001 \001(\0132*.google" + + ".spanner.admin.instance.v1.Instance\022.\n\ns" + + "tart_time\030\002 \001(\0132\032.google.protobuf.Timest" + + "amp\022/\n\013cancel_time\030\003 \001(\0132\032.google.protob" + + "uf.Timestamp\022,\n\010end_time\030\004 \001(\0132\032.google." + + "protobuf.Timestamp\"\345\001\n\026UpdateInstanceMet" + + "adata\022<\n\010instance\030\001 \001(\0132*.google.spanner" + + ".admin.instance.v1.Instance\022.\n\nstart_tim" + + "e\030\002 \001(\0132\032.google.protobuf.Timestamp\022/\n\013c" + + "ancel_time\030\003 \001(\0132\032.google.protobuf.Times" + + "tamp\022,\n\010end_time\030\004 \001(\0132\032.google.protobuf" + + ".Timestamp2\277\020\n\rInstanceAdmin\022\314\001\n\023ListIns" + + "tanceConfigs\022<.google.spanner.admin.inst" + + "ance.v1.ListInstanceConfigsRequest\032=.goo" + + "gle.spanner.admin.instance.v1.ListInstan" + + "ceConfigsResponse\"8\202\323\344\223\002)\022\'/v1/{parent=p" + + "rojects/*}/instanceConfigs\332A\006parent\022\271\001\n\021" + + "GetInstanceConfig\022:.google.spanner.admin" + + ".instance.v1.GetInstanceConfigRequest\0320." + + "google.spanner.admin.instance.v1.Instanc" + + "eConfig\"6\202\323\344\223\002)\022\'/v1/{name=projects/*/in" + + "stanceConfigs/*}\332A\004name\022\264\001\n\rListInstance" + + "s\0226.google.spanner.admin.instance.v1.Lis" + + "tInstancesRequest\0327.google.spanner.admin" + + ".instance.v1.ListInstancesResponse\"2\202\323\344\223" + + "\002#\022!/v1/{parent=projects/*}/instances\332A\006" + + "parent\022\241\001\n\013GetInstance\0224.google.spanner." + + "admin.instance.v1.GetInstanceRequest\032*.g" + "oogle.spanner.admin.instance.v1.Instance" - + "B\003\340A\002\"\222\001\n\024ListInstancesRequest\022C\n\006parent" - + "\030\001 \001(\tB3\340A\002\372A-\n+cloudresourcemanager.goo" - + "gleapis.com/Project\022\021\n\tpage_size\030\002 \001(\005\022\022" - + "\n\npage_token\030\003 \001(\t\022\016\n\006filter\030\004 \001(\t\"o\n\025Li" - + "stInstancesResponse\022=\n\tinstances\030\001 \003(\0132*" - + ".google.spanner.admin.instance.v1.Instan" - + "ce\022\027\n\017next_page_token\030\002 \001(\t\"\217\001\n\025UpdateIn" - + "stanceRequest\022A\n\010instance\030\001 \001(\0132*.google" - + ".spanner.admin.instance.v1.InstanceB\003\340A\002" - + "\0223\n\nfield_mask\030\002 \001(\0132\032.google.protobuf.F" - + "ieldMaskB\003\340A\002\"N\n\025DeleteInstanceRequest\0225" - + "\n\004name\030\001 \001(\tB\'\340A\002\372A!\n\037spanner.googleapis" - + ".com/Instance\"\345\001\n\026CreateInstanceMetadata" - + "\022<\n\010instance\030\001 \001(\0132*.google.spanner.admi" - + "n.instance.v1.Instance\022.\n\nstart_time\030\002 \001" - + "(\0132\032.google.protobuf.Timestamp\022/\n\013cancel" - + "_time\030\003 \001(\0132\032.google.protobuf.Timestamp\022" - + ",\n\010end_time\030\004 \001(\0132\032.google.protobuf.Time" - + "stamp\"\345\001\n\026UpdateInstanceMetadata\022<\n\010inst" - + "ance\030\001 \001(\0132*.google.spanner.admin.instan" - + "ce.v1.Instance\022.\n\nstart_time\030\002 \001(\0132\032.goo" - + "gle.protobuf.Timestamp\022/\n\013cancel_time\030\003 " - + "\001(\0132\032.google.protobuf.Timestamp\022,\n\010end_t" - + "ime\030\004 \001(\0132\032.google.protobuf.Timestamp2\277\020" - + "\n\rInstanceAdmin\022\314\001\n\023ListInstanceConfigs\022" - + "<.google.spanner.admin.instance.v1.ListI" - + "nstanceConfigsRequest\032=.google.spanner.a" - + "dmin.instance.v1.ListInstanceConfigsResp" - + "onse\"8\202\323\344\223\002)\022\'/v1/{parent=projects/*}/in" - + "stanceConfigs\332A\006parent\022\271\001\n\021GetInstanceCo" - + "nfig\022:.google.spanner.admin.instance.v1." - + "GetInstanceConfigRequest\0320.google.spanne" - + "r.admin.instance.v1.InstanceConfig\"6\202\323\344\223" - + "\002)\022\'/v1/{name=projects/*/instanceConfigs" - + "/*}\332A\004name\022\264\001\n\rListInstances\0226.google.sp" - + "anner.admin.instance.v1.ListInstancesReq" - + "uest\0327.google.spanner.admin.instance.v1." - + "ListInstancesResponse\"2\202\323\344\223\002#\022!/v1/{pare" - + "nt=projects/*}/instances\332A\006parent\022\241\001\n\013Ge" - + "tInstance\0224.google.spanner.admin.instanc" - + "e.v1.GetInstanceRequest\032*.google.spanner" - + ".admin.instance.v1.Instance\"0\202\323\344\223\002#\022!/v1" - + "/{name=projects/*/instances/*}\332A\004name\022\234\002" - + "\n\016CreateInstance\0227.google.spanner.admin." - + "instance.v1.CreateInstanceRequest\032\035.goog" - + "le.longrunning.Operation\"\261\001\202\323\344\223\002&\"!/v1/{" - + "parent=projects/*}/instances:\001*\332A\033parent" - + ",instance_id,instance\312Ad\n)google.spanner" - + ".admin.instance.v1.Instance\0227google.span" - + "ner.admin.instance.v1.CreateInstanceMeta" - + "data\022\235\002\n\016UpdateInstance\0227.google.spanner" - + ".admin.instance.v1.UpdateInstanceRequest" - + "\032\035.google.longrunning.Operation\"\262\001\202\323\344\223\002/" - + "2*/v1/{instance.name=projects/*/instance" - + "s/*}:\001*\332A\023instance,field_mask\312Ad\n)google" - + ".spanner.admin.instance.v1.Instance\0227goo" - + "gle.spanner.admin.instance.v1.UpdateInst" - + "anceMetadata\022\223\001\n\016DeleteInstance\0227.google" - + ".spanner.admin.instance.v1.DeleteInstanc" - + "eRequest\032\026.google.protobuf.Empty\"0\202\323\344\223\002#" - + "*!/v1/{name=projects/*/instances/*}\332A\004na" - + "me\022\232\001\n\014SetIamPolicy\022\".google.iam.v1.SetI" - + "amPolicyRequest\032\025.google.iam.v1.Policy\"O" - + "\202\323\344\223\0027\"2/v1/{resource=projects/*/instanc" - + "es/*}:setIamPolicy:\001*\332A\017resource,policy\022" - + "\223\001\n\014GetIamPolicy\022\".google.iam.v1.GetIamP" - + "olicyRequest\032\025.google.iam.v1.Policy\"H\202\323\344" - + "\223\0027\"2/v1/{resource=projects/*/instances/" - + "*}:getIamPolicy:\001*\332A\010resource\022\305\001\n\022TestIa" - + "mPermissions\022(.google.iam.v1.TestIamPerm" - + "issionsRequest\032).google.iam.v1.TestIamPe" - + "rmissionsResponse\"Z\202\323\344\223\002=\"8/v1/{resource" - + "=projects/*/instances/*}:testIamPermissi" - + "ons:\001*\332A\024resource,permissions\032x\312A\026spanne" - + "r.googleapis.com\322A\\https://www.googleapi" - + "s.com/auth/cloud-platform,https://www.go" - + "ogleapis.com/auth/spanner.adminB\215\002\n$com." - + "google.spanner.admin.instance.v1B\031Spanne" - + "rInstanceAdminProtoP\001ZHgoogle.golang.org" - + "/genproto/googleapis/spanner/admin/insta" - + "nce/v1;instance\252\002&Google.Cloud.Spanner.A" - + "dmin.Instance.V1\312\002&Google\\Cloud\\Spanner\\" - + "Admin\\Instance\\V1\352\002+Google::Cloud::Spann" - + "er::Admin::Instance::V1b\006proto3" + + "\"0\202\323\344\223\002#\022!/v1/{name=projects/*/instances" + + "/*}\332A\004name\022\234\002\n\016CreateInstance\0227.google.s" + + "panner.admin.instance.v1.CreateInstanceR" + + "equest\032\035.google.longrunning.Operation\"\261\001" + + "\202\323\344\223\002&\"!/v1/{parent=projects/*}/instance" + + "s:\001*\332A\033parent,instance_id,instance\312Ad\n)g" + + "oogle.spanner.admin.instance.v1.Instance" + + "\0227google.spanner.admin.instance.v1.Creat" + + "eInstanceMetadata\022\235\002\n\016UpdateInstance\0227.g" + + "oogle.spanner.admin.instance.v1.UpdateIn" + + "stanceRequest\032\035.google.longrunning.Opera" + + "tion\"\262\001\202\323\344\223\002/2*/v1/{instance.name=projec" + + "ts/*/instances/*}:\001*\332A\023instance,field_ma" + + "sk\312Ad\n)google.spanner.admin.instance.v1." + + "Instance\0227google.spanner.admin.instance." + + "v1.UpdateInstanceMetadata\022\223\001\n\016DeleteInst" + + "ance\0227.google.spanner.admin.instance.v1." + + "DeleteInstanceRequest\032\026.google.protobuf." + + "Empty\"0\202\323\344\223\002#*!/v1/{name=projects/*/inst" + + "ances/*}\332A\004name\022\232\001\n\014SetIamPolicy\022\".googl" + + "e.iam.v1.SetIamPolicyRequest\032\025.google.ia" + + "m.v1.Policy\"O\202\323\344\223\0027\"2/v1/{resource=proje" + + "cts/*/instances/*}:setIamPolicy:\001*\332A\017res" + + "ource,policy\022\223\001\n\014GetIamPolicy\022\".google.i" + + "am.v1.GetIamPolicyRequest\032\025.google.iam.v" + + "1.Policy\"H\202\323\344\223\0027\"2/v1/{resource=projects" + + "/*/instances/*}:getIamPolicy:\001*\332A\010resour" + + "ce\022\305\001\n\022TestIamPermissions\022(.google.iam.v" + + "1.TestIamPermissionsRequest\032).google.iam" + + ".v1.TestIamPermissionsResponse\"Z\202\323\344\223\002=\"8" + + "/v1/{resource=projects/*/instances/*}:te" + + "stIamPermissions:\001*\332A\024resource,permissio" + + "ns\032x\312A\026spanner.googleapis.com\322A\\https://" + + "www.googleapis.com/auth/cloud-platform,h" + + "ttps://www.googleapis.com/auth/spanner.a" + + "dminB\215\002\n$com.google.spanner.admin.instan" + + "ce.v1B\031SpannerInstanceAdminProtoP\001ZHgoog" + + "le.golang.org/genproto/googleapis/spanne" + + "r/admin/instance/v1;instance\252\002&Google.Cl" + + "oud.Spanner.Admin.Instance.V1\312\002&Google\\C" + + "loud\\Spanner\\Admin\\Instance\\V1\352\002+Google:" + + ":Cloud::Spanner::Admin::Instance::V1b\006pr" + + "oto3" }; 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 de86f26865e..0e6bf63feb0 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 @@ -350,19 +350,22 @@ message Instance { // after the instance is created. Values are of the form // `projects//instances/[a-z][-a-z0-9]*[a-z0-9]`. The final // segment of the name must be between 2 and 64 characters in length. - string name = 1; + string name = 1 [(google.api.field_behavior) = REQUIRED]; // Required. The name of the instance's configuration. Values are of the form // `projects//instanceConfigs/`. See // also [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and // [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. - string config = 2 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/InstanceConfig" - }]; + string config = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/InstanceConfig" + } + ]; // Required. The descriptive name for this instance as it appears in UIs. // Must be unique per project and between 4 and 30 characters in length. - string display_name = 3; + string display_name = 3 [(google.api.field_behavior) = REQUIRED]; // Required. The number of nodes allocated to this instance. This may be zero // in API responses for instances that are not yet in state `READY`. diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequest.java index e0d65d159ab..4e32e35449f 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequest.java @@ -185,10 +185,10 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * *
-   * The session to create.
+   * Required. The session to create.
    * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; * * @return Whether the session field is set. */ @@ -200,10 +200,10 @@ public boolean hasSession() { * * *
-   * The session to create.
+   * Required. The session to create.
    * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; * * @return The session. */ @@ -215,10 +215,10 @@ public com.google.spanner.v1.Session getSession() { * * *
-   * The session to create.
+   * Required. The session to create.
    * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; */ @java.lang.Override public com.google.spanner.v1.SessionOrBuilder getSessionOrBuilder() { @@ -695,10 +695,11 @@ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { * * *
-     * The session to create.
+     * Required. The session to create.
      * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; + * * * @return Whether the session field is set. */ @@ -709,10 +710,11 @@ public boolean hasSession() { * * *
-     * The session to create.
+     * Required. The session to create.
      * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; + * * * @return The session. */ @@ -727,10 +729,11 @@ public com.google.spanner.v1.Session getSession() { * * *
-     * The session to create.
+     * Required. The session to create.
      * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder setSession(com.google.spanner.v1.Session value) { if (sessionBuilder_ == null) { @@ -749,10 +752,11 @@ public Builder setSession(com.google.spanner.v1.Session value) { * * *
-     * The session to create.
+     * Required. The session to create.
      * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder setSession(com.google.spanner.v1.Session.Builder builderForValue) { if (sessionBuilder_ == null) { @@ -768,10 +772,11 @@ public Builder setSession(com.google.spanner.v1.Session.Builder builderForValue) * * *
-     * The session to create.
+     * Required. The session to create.
      * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder mergeSession(com.google.spanner.v1.Session value) { if (sessionBuilder_ == null) { @@ -792,10 +797,11 @@ public Builder mergeSession(com.google.spanner.v1.Session value) { * * *
-     * The session to create.
+     * Required. The session to create.
      * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder clearSession() { if (sessionBuilder_ == null) { @@ -812,10 +818,11 @@ public Builder clearSession() { * * *
-     * The session to create.
+     * Required. The session to create.
      * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ public com.google.spanner.v1.Session.Builder getSessionBuilder() { @@ -826,10 +833,11 @@ public com.google.spanner.v1.Session.Builder getSessionBuilder() { * * *
-     * The session to create.
+     * Required. The session to create.
      * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ public com.google.spanner.v1.SessionOrBuilder getSessionOrBuilder() { if (sessionBuilder_ != null) { @@ -842,10 +850,11 @@ public com.google.spanner.v1.SessionOrBuilder getSessionOrBuilder() { * * *
-     * The session to create.
+     * Required. The session to create.
      * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ private com.google.protobuf.SingleFieldBuilderV3< com.google.spanner.v1.Session, diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequestOrBuilder.java index 3966d85f952..e6e69132e6f 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequestOrBuilder.java @@ -56,10 +56,10 @@ public interface CreateSessionRequestOrBuilder * * *
-   * The session to create.
+   * Required. The session to create.
    * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; * * @return Whether the session field is set. */ @@ -68,10 +68,10 @@ public interface CreateSessionRequestOrBuilder * * *
-   * The session to create.
+   * Required. The session to create.
    * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; * * @return The session. */ @@ -80,10 +80,10 @@ public interface CreateSessionRequestOrBuilder * * *
-   * The session to create.
+   * Required. The session to create.
    * 
* - * .google.spanner.v1.Session session = 2; + * .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; */ com.google.spanner.v1.SessionOrBuilder getSessionOrBuilder(); } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequest.java index 8e70092a3c9..9d5558673f0 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequest.java @@ -179,7 +179,7 @@ public interface StatementOrBuilder * Required. The DML string. * * - * string sql = 1; + * string sql = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The sql. */ @@ -191,7 +191,7 @@ public interface StatementOrBuilder * Required. The DML string. * * - * string sql = 1; + * string sql = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for sql. */ @@ -482,7 +482,7 @@ protected com.google.protobuf.MapField internalGetMapField(int number) { * Required. The DML string. * * - * string sql = 1; + * string sql = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The sql. */ @@ -505,7 +505,7 @@ public java.lang.String getSql() { * Required. The DML string. * * - * string sql = 1; + * string sql = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for sql. */ @@ -1121,7 +1121,7 @@ public Builder mergeFrom( * Required. The DML string. * * - * string sql = 1; + * string sql = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The sql. */ @@ -1143,7 +1143,7 @@ public java.lang.String getSql() { * Required. The DML string. * * - * string sql = 1; + * string sql = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for sql. */ @@ -1165,7 +1165,7 @@ public com.google.protobuf.ByteString getSqlBytes() { * Required. The DML string. * * - * string sql = 1; + * string sql = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The sql to set. * @return This builder for chaining. @@ -1186,7 +1186,7 @@ public Builder setSql(java.lang.String value) { * Required. The DML string. * * - * string sql = 1; + * string sql = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return This builder for chaining. */ @@ -1203,7 +1203,7 @@ public Builder clearSql() { * Required. The DML string. * * - * string sql = 1; + * string sql = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The bytes for sql to set. * @return This builder for chaining. diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Mutation.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Mutation.java index 779b3413e4d..b06d7426160 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Mutation.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Mutation.java @@ -195,7 +195,7 @@ public interface WriteOrBuilder * Required. The table whose rows will be written. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The table. */ @@ -207,7 +207,7 @@ public interface WriteOrBuilder * Required. The table whose rows will be written. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for table. */ @@ -494,7 +494,7 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * Required. The table whose rows will be written. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The table. */ @@ -517,7 +517,7 @@ public java.lang.String getTable() { * Required. The table whose rows will be written. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for table. */ @@ -1130,7 +1130,7 @@ public Builder mergeFrom( * Required. The table whose rows will be written. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The table. */ @@ -1152,7 +1152,7 @@ public java.lang.String getTable() { * Required. The table whose rows will be written. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for table. */ @@ -1174,7 +1174,7 @@ public com.google.protobuf.ByteString getTableBytes() { * Required. The table whose rows will be written. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The table to set. * @return This builder for chaining. @@ -1195,7 +1195,7 @@ public Builder setTable(java.lang.String value) { * Required. The table whose rows will be written. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return This builder for chaining. */ @@ -1212,7 +1212,7 @@ public Builder clearTable() { * Required. The table whose rows will be written. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The bytes for table to set. * @return This builder for chaining. @@ -1959,7 +1959,7 @@ public interface DeleteOrBuilder * Required. The table whose rows will be deleted. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The table. */ @@ -1971,7 +1971,7 @@ public interface DeleteOrBuilder * Required. The table whose rows will be deleted. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for table. */ @@ -1989,7 +1989,7 @@ public interface DeleteOrBuilder * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; * * @return Whether the keySet field is set. */ @@ -2006,7 +2006,7 @@ public interface DeleteOrBuilder * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; * * @return The keySet. */ @@ -2023,7 +2023,7 @@ public interface DeleteOrBuilder * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; */ com.google.spanner.v1.KeySetOrBuilder getKeySetOrBuilder(); } @@ -2144,7 +2144,7 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * Required. The table whose rows will be deleted. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The table. */ @@ -2167,7 +2167,7 @@ public java.lang.String getTable() { * Required. The table whose rows will be deleted. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for table. */ @@ -2198,7 +2198,7 @@ public com.google.protobuf.ByteString getTableBytes() { * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; * * @return Whether the keySet field is set. */ @@ -2218,7 +2218,7 @@ public boolean hasKeySet() { * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; * * @return The keySet. */ @@ -2238,7 +2238,7 @@ public com.google.spanner.v1.KeySet getKeySet() { * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; */ @java.lang.Override public com.google.spanner.v1.KeySetOrBuilder getKeySetOrBuilder() { @@ -2600,7 +2600,7 @@ public Builder mergeFrom( * Required. The table whose rows will be deleted. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The table. */ @@ -2622,7 +2622,7 @@ public java.lang.String getTable() { * Required. The table whose rows will be deleted. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for table. */ @@ -2644,7 +2644,7 @@ public com.google.protobuf.ByteString getTableBytes() { * Required. The table whose rows will be deleted. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The table to set. * @return This builder for chaining. @@ -2665,7 +2665,7 @@ public Builder setTable(java.lang.String value) { * Required. The table whose rows will be deleted. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return This builder for chaining. */ @@ -2682,7 +2682,7 @@ public Builder clearTable() { * Required. The table whose rows will be deleted. * * - * string table = 1; + * string table = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The bytes for table to set. * @return This builder for chaining. @@ -2716,7 +2716,8 @@ public Builder setTableBytes(com.google.protobuf.ByteString value) { * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; + * * * @return Whether the keySet field is set. */ @@ -2735,7 +2736,8 @@ public boolean hasKeySet() { * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; + * * * @return The keySet. */ @@ -2758,7 +2760,8 @@ public com.google.spanner.v1.KeySet getKeySet() { * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder setKeySet(com.google.spanner.v1.KeySet value) { if (keySetBuilder_ == null) { @@ -2785,7 +2788,8 @@ public Builder setKeySet(com.google.spanner.v1.KeySet value) { * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder setKeySet(com.google.spanner.v1.KeySet.Builder builderForValue) { if (keySetBuilder_ == null) { @@ -2809,7 +2813,8 @@ public Builder setKeySet(com.google.spanner.v1.KeySet.Builder builderForValue) { * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder mergeKeySet(com.google.spanner.v1.KeySet value) { if (keySetBuilder_ == null) { @@ -2838,7 +2843,8 @@ public Builder mergeKeySet(com.google.spanner.v1.KeySet value) { * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ public Builder clearKeySet() { if (keySetBuilder_ == null) { @@ -2863,7 +2869,8 @@ public Builder clearKeySet() { * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ public com.google.spanner.v1.KeySet.Builder getKeySetBuilder() { @@ -2882,7 +2889,8 @@ public com.google.spanner.v1.KeySet.Builder getKeySetBuilder() { * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ public com.google.spanner.v1.KeySetOrBuilder getKeySetOrBuilder() { if (keySetBuilder_ != null) { @@ -2903,7 +2911,8 @@ public com.google.spanner.v1.KeySetOrBuilder getKeySetOrBuilder() { * rows do not exist. * * - * .google.spanner.v1.KeySet key_set = 2; + * .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; + * */ private com.google.protobuf.SingleFieldBuilderV3< com.google.spanner.v1.KeySet, 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 f7e439f86f0..faf23ffff0a 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 @@ -50,30 +50,32 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { java.lang.String[] descriptorData = { "\n google/spanner/v1/mutation.proto\022\021goog" + "le.spanner.v1\032\034google/api/annotations.pr" - + "oto\032\034google/protobuf/struct.proto\032\034googl" - + "e/spanner/v1/keys.proto\"\306\003\n\010Mutation\0223\n\006" - + "insert\030\001 \001(\0132!.google.spanner.v1.Mutatio" - + "n.WriteH\000\0223\n\006update\030\002 \001(\0132!.google.spann" - + "er.v1.Mutation.WriteH\000\022=\n\020insert_or_upda" - + "te\030\003 \001(\0132!.google.spanner.v1.Mutation.Wr" - + "iteH\000\0224\n\007replace\030\004 \001(\0132!.google.spanner." - + "v1.Mutation.WriteH\000\0224\n\006delete\030\005 \001(\0132\".go" - + "ogle.spanner.v1.Mutation.DeleteH\000\032S\n\005Wri" - + "te\022\r\n\005table\030\001 \001(\t\022\017\n\007columns\030\002 \003(\t\022*\n\006va" - + "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\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\\V1\352\002\032Goog" - + "le::Cloud::Spanner::V1b\006proto3" + + "oto\032\037google/api/field_behavior.proto\032\034go" + + "ogle/protobuf/struct.proto\032\034google/spann" + + "er/v1/keys.proto\"\325\003\n\010Mutation\0223\n\006insert\030" + + "\001 \001(\0132!.google.spanner.v1.Mutation.Write" + + "H\000\0223\n\006update\030\002 \001(\0132!.google.spanner.v1.M" + + "utation.WriteH\000\022=\n\020insert_or_update\030\003 \001(" + + "\0132!.google.spanner.v1.Mutation.WriteH\000\0224" + + "\n\007replace\030\004 \001(\0132!.google.spanner.v1.Muta" + + "tion.WriteH\000\0224\n\006delete\030\005 \001(\0132\".google.sp" + + "anner.v1.Mutation.DeleteH\000\032X\n\005Write\022\022\n\005t" + + "able\030\001 \001(\tB\003\340A\002\022\017\n\007columns\030\002 \003(\t\022*\n\006valu" + + "es\030\003 \003(\0132\032.google.protobuf.ListValue\032M\n\006" + + "Delete\022\022\n\005table\030\001 \001(\tB\003\340A\002\022/\n\007key_set\030\002 " + + "\001(\0132\031.google.spanner.v1.KeySetB\003\340A\002B\013\n\to" + + "perationB\263\001\n\025com.google.spanner.v1B\rMuta" + + "tionProtoP\001Z8google.golang.org/genproto/" + + "googleapis/spanner/v1;spanner\252\002\027Google.C" + + "loud.Spanner.V1\312\002\027Google\\Cloud\\Spanner\\V" + + "1\352\002\032Google::Cloud::Spanner::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { com.google.api.AnnotationsProto.getDescriptor(), + com.google.api.FieldBehaviorProto.getDescriptor(), com.google.protobuf.StructProto.getDescriptor(), com.google.spanner.v1.KeysProto.getDescriptor(), }); @@ -101,7 +103,13 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new java.lang.String[] { "Table", "KeySet", }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); com.google.api.AnnotationsProto.getDescriptor(); + com.google.api.FieldBehaviorProto.getDescriptor(); com.google.protobuf.StructProto.getDescriptor(); com.google.spanner.v1.KeysProto.getDescriptor(); } 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 3fbfef6ea9a..440f749d535 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 @@ -156,204 +156,204 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "gle/spanner/v1/mutation.proto\032\"google/sp" + "anner/v1/result_set.proto\032#google/spanne" + "r/v1/transaction.proto\032\034google/spanner/v" - + "1/type.proto\"~\n\024CreateSessionRequest\0229\n\010" - + "database\030\001 \001(\tB\'\340A\002\372A!\n\037spanner.googleap" - + "is.com/Database\022+\n\007session\030\002 \001(\0132\032.googl" - + "e.spanner.v1.Session\"\251\001\n\032BatchCreateSess" - + "ionsRequest\0229\n\010database\030\001 \001(\tB\'\340A\002\372A!\n\037s" - + "panner.googleapis.com/Database\0224\n\020sessio" - + "n_template\030\002 \001(\0132\032.google.spanner.v1.Ses" - + "sion\022\032\n\rsession_count\030\003 \001(\005B\003\340A\002\"J\n\033Batc" - + "hCreateSessionsResponse\022+\n\007session\030\001 \003(\013" - + "2\032.google.spanner.v1.Session\"\363\002\n\007Session" - + "\022\021\n\004name\030\001 \001(\tB\003\340A\003\0226\n\006labels\030\002 \003(\0132&.go" - + "ogle.spanner.v1.Session.LabelsEntry\0224\n\013c" - + "reate_time\030\003 \001(\0132\032.google.protobuf.Times" - + "tampB\003\340A\003\022B\n\031approximate_last_use_time\030\004" - + " \001(\0132\032.google.protobuf.TimestampB\003\340A\003\032-\n" - + "\013LabelsEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t" - + ":\0028\001:t\352Aq\n\036spanner.googleapis.com/Sessio" - + "n\022Oprojects/{project}/instances/{instanc" - + "e}/databases/{database}/sessions/{sessio" - + "n}\"I\n\021GetSessionRequest\0224\n\004name\030\001 \001(\tB&\340" - + "A\002\372A \n\036spanner.googleapis.com/Session\"\207\001" - + "\n\023ListSessionsRequest\0229\n\010database\030\001 \001(\tB" - + "\'\340A\002\372A!\n\037spanner.googleapis.com/Database" - + "\022\021\n\tpage_size\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\022" - + "\016\n\006filter\030\004 \001(\t\"]\n\024ListSessionsResponse\022" - + ",\n\010sessions\030\001 \003(\0132\032.google.spanner.v1.Se" - + "ssion\022\027\n\017next_page_token\030\002 \001(\t\"L\n\024Delete" - + "SessionRequest\0224\n\004name\030\001 \001(\tB&\340A\002\372A \n\036sp" - + "anner.googleapis.com/Session\"\334\001\n\016Request" - + "Options\022<\n\010priority\030\001 \001(\0162*.google.spann" - + "er.v1.RequestOptions.Priority\022\023\n\013request" - + "_tag\030\002 \001(\t\022\027\n\017transaction_tag\030\003 \001(\t\"^\n\010P" - + "riority\022\030\n\024PRIORITY_UNSPECIFIED\020\000\022\020\n\014PRI" - + "ORITY_LOW\020\001\022\023\n\017PRIORITY_MEDIUM\020\002\022\021\n\rPRIO" - + "RITY_HIGH\020\003\"\344\005\n\021ExecuteSqlRequest\0227\n\007ses" - + "sion\030\001 \001(\tB&\340A\002\372A \n\036spanner.googleapis.c" - + "om/Session\022;\n\013transaction\030\002 \001(\0132&.google" - + ".spanner.v1.TransactionSelector\022\020\n\003sql\030\003" - + " \001(\tB\003\340A\002\022\'\n\006params\030\004 \001(\0132\027.google.proto" - + "buf.Struct\022I\n\013param_types\030\005 \003(\01324.google" - + ".spanner.v1.ExecuteSqlRequest.ParamTypes" - + "Entry\022\024\n\014resume_token\030\006 \001(\014\022B\n\nquery_mod" - + "e\030\007 \001(\0162..google.spanner.v1.ExecuteSqlRe" - + "quest.QueryMode\022\027\n\017partition_token\030\010 \001(\014" - + "\022\r\n\005seqno\030\t \001(\003\022H\n\rquery_options\030\n \001(\01321" - + ".google.spanner.v1.ExecuteSqlRequest.Que" - + "ryOptions\022:\n\017request_options\030\013 \001(\0132!.goo" - + "gle.spanner.v1.RequestOptions\032O\n\014QueryOp" - + "tions\022\031\n\021optimizer_version\030\001 \001(\t\022$\n\034opti" - + "mizer_statistics_package\030\002 \001(\t\032J\n\017ParamT" - + "ypesEntry\022\013\n\003key\030\001 \001(\t\022&\n\005value\030\002 \001(\0132\027." - + "google.spanner.v1.Type:\0028\001\".\n\tQueryMode\022" - + "\n\n\006NORMAL\020\000\022\010\n\004PLAN\020\001\022\013\n\007PROFILE\020\002\"\233\004\n\026E" - + "xecuteBatchDmlRequest\0227\n\007session\030\001 \001(\tB&" - + "\340A\002\372A \n\036spanner.googleapis.com/Session\022@" - + "\n\013transaction\030\002 \001(\0132&.google.spanner.v1." - + "TransactionSelectorB\003\340A\002\022L\n\nstatements\030\003" - + " \003(\01323.google.spanner.v1.ExecuteBatchDml" - + "Request.StatementB\003\340A\002\022\022\n\005seqno\030\004 \001(\003B\003\340" - + "A\002\022:\n\017request_options\030\005 \001(\0132!.google.spa" - + "nner.v1.RequestOptions\032\347\001\n\tStatement\022\013\n\003" - + "sql\030\001 \001(\t\022\'\n\006params\030\002 \001(\0132\027.google.proto" - + "buf.Struct\022X\n\013param_types\030\003 \003(\0132C.google" - + ".spanner.v1.ExecuteBatchDmlRequest.State" - + "ment.ParamTypesEntry\032J\n\017ParamTypesEntry\022" - + "\013\n\003key\030\001 \001(\t\022&\n\005value\030\002 \001(\0132\027.google.spa" - + "nner.v1.Type:\0028\001\"p\n\027ExecuteBatchDmlRespo" - + "nse\0221\n\013result_sets\030\001 \003(\0132\034.google.spanne" - + "r.v1.ResultSet\022\"\n\006status\030\002 \001(\0132\022.google." - + "rpc.Status\"H\n\020PartitionOptions\022\034\n\024partit" - + "ion_size_bytes\030\001 \001(\003\022\026\n\016max_partitions\030\002" - + " \001(\003\"\243\003\n\025PartitionQueryRequest\0227\n\007sessio" - + "n\030\001 \001(\tB&\340A\002\372A \n\036spanner.googleapis.com/" - + "Session\022;\n\013transaction\030\002 \001(\0132&.google.sp" - + "anner.v1.TransactionSelector\022\020\n\003sql\030\003 \001(" - + "\tB\003\340A\002\022\'\n\006params\030\004 \001(\0132\027.google.protobuf" - + ".Struct\022M\n\013param_types\030\005 \003(\01328.google.sp" - + "anner.v1.PartitionQueryRequest.ParamType" - + "sEntry\022>\n\021partition_options\030\006 \001(\0132#.goog" - + "le.spanner.v1.PartitionOptions\032J\n\017ParamT" - + "ypesEntry\022\013\n\003key\030\001 \001(\t\022&\n\005value\030\002 \001(\0132\027." - + "google.spanner.v1.Type:\0028\001\"\261\002\n\024Partition" - + "ReadRequest\0227\n\007session\030\001 \001(\tB&\340A\002\372A \n\036sp" - + "anner.googleapis.com/Session\022;\n\013transact" - + "ion\030\002 \001(\0132&.google.spanner.v1.Transactio" - + "nSelector\022\022\n\005table\030\003 \001(\tB\003\340A\002\022\r\n\005index\030\004" - + " \001(\t\022\017\n\007columns\030\005 \003(\t\022/\n\007key_set\030\006 \001(\0132\031" - + ".google.spanner.v1.KeySetB\003\340A\002\022>\n\021partit" - + "ion_options\030\t \001(\0132#.google.spanner.v1.Pa" - + "rtitionOptions\"$\n\tPartition\022\027\n\017partition" - + "_token\030\001 \001(\014\"z\n\021PartitionResponse\0220\n\npar" - + "titions\030\001 \003(\0132\034.google.spanner.v1.Partit" - + "ion\0223\n\013transaction\030\002 \001(\0132\036.google.spanne" - + "r.v1.Transaction\"\347\002\n\013ReadRequest\0227\n\007sess" - + "ion\030\001 \001(\tB&\340A\002\372A \n\036spanner.googleapis.co" - + "m/Session\022;\n\013transaction\030\002 \001(\0132&.google." - + "spanner.v1.TransactionSelector\022\022\n\005table\030" - + "\003 \001(\tB\003\340A\002\022\r\n\005index\030\004 \001(\t\022\024\n\007columns\030\005 \003" - + "(\tB\003\340A\002\022/\n\007key_set\030\006 \001(\0132\031.google.spanne" - + "r.v1.KeySetB\003\340A\002\022\r\n\005limit\030\010 \001(\003\022\024\n\014resum" - + "e_token\030\t \001(\014\022\027\n\017partition_token\030\n \001(\014\022:" - + "\n\017request_options\030\013 \001(\0132!.google.spanner" - + ".v1.RequestOptions\"\313\001\n\027BeginTransactionR" - + "equest\0227\n\007session\030\001 \001(\tB&\340A\002\372A \n\036spanner" - + ".googleapis.com/Session\022;\n\007options\030\002 \001(\013" - + "2%.google.spanner.v1.TransactionOptionsB" - + "\003\340A\002\022:\n\017request_options\030\003 \001(\0132!.google.s" - + "panner.v1.RequestOptions\"\303\002\n\rCommitReque" - + "st\0227\n\007session\030\001 \001(\tB&\340A\002\372A \n\036spanner.goo" - + "gleapis.com/Session\022\030\n\016transaction_id\030\002 " - + "\001(\014H\000\022G\n\026single_use_transaction\030\003 \001(\0132%." - + "google.spanner.v1.TransactionOptionsH\000\022." - + "\n\tmutations\030\004 \003(\0132\033.google.spanner.v1.Mu" - + "tation\022\033\n\023return_commit_stats\030\005 \001(\010\022:\n\017r" - + "equest_options\030\006 \001(\0132!.google.spanner.v1" - + ".RequestOptionsB\r\n\013transaction\"g\n\017Rollba" - + "ckRequest\0227\n\007session\030\001 \001(\tB&\340A\002\372A \n\036span" - + "ner.googleapis.com/Session\022\033\n\016transactio" - + "n_id\030\002 \001(\014B\003\340A\0022\300\026\n\007Spanner\022\246\001\n\rCreateSe" - + "ssion\022\'.google.spanner.v1.CreateSessionR" - + "equest\032\032.google.spanner.v1.Session\"P\202\323\344\223" - + "\002?\":/v1/{database=projects/*/instances/*" - + "/databases/*}/sessions:\001*\332A\010database\022\340\001\n" - + "\023BatchCreateSessions\022-.google.spanner.v1" - + ".BatchCreateSessionsRequest\032..google.spa" - + "nner.v1.BatchCreateSessionsResponse\"j\202\323\344" - + "\223\002K\"F/v1/{database=projects/*/instances/" - + "*/databases/*}/sessions:batchCreate:\001*\332A" - + "\026database,session_count\022\227\001\n\nGetSession\022$" - + ".google.spanner.v1.GetSessionRequest\032\032.g" - + "oogle.spanner.v1.Session\"G\202\323\344\223\002:\0228/v1/{n" - + "ame=projects/*/instances/*/databases/*/s" - + "essions/*}\332A\004name\022\256\001\n\014ListSessions\022&.goo" - + "gle.spanner.v1.ListSessionsRequest\032\'.goo" - + "gle.spanner.v1.ListSessionsResponse\"M\202\323\344" - + "\223\002<\022:/v1/{database=projects/*/instances/" - + "*/databases/*}/sessions\332A\010database\022\231\001\n\rD" - + "eleteSession\022\'.google.spanner.v1.DeleteS" - + "essionRequest\032\026.google.protobuf.Empty\"G\202" - + "\323\344\223\002:*8/v1/{name=projects/*/instances/*/" - + "databases/*/sessions/*}\332A\004name\022\243\001\n\nExecu" - + "teSql\022$.google.spanner.v1.ExecuteSqlRequ" - + "est\032\034.google.spanner.v1.ResultSet\"Q\202\323\344\223\002" - + "K\"F/v1/{session=projects/*/instances/*/d" - + "atabases/*/sessions/*}:executeSql:\001*\022\276\001\n" - + "\023ExecuteStreamingSql\022$.google.spanner.v1" - + ".ExecuteSqlRequest\032#.google.spanner.v1.P" - + "artialResultSet\"Z\202\323\344\223\002T\"O/v1/{session=pr" - + "ojects/*/instances/*/databases/*/session" - + "s/*}:executeStreamingSql:\001*0\001\022\300\001\n\017Execut" - + "eBatchDml\022).google.spanner.v1.ExecuteBat" - + "chDmlRequest\032*.google.spanner.v1.Execute" - + "BatchDmlResponse\"V\202\323\344\223\002P\"K/v1/{session=p" - + "rojects/*/instances/*/databases/*/sessio" - + "ns/*}:executeBatchDml:\001*\022\221\001\n\004Read\022\036.goog" - + "le.spanner.v1.ReadRequest\032\034.google.spann" - + "er.v1.ResultSet\"K\202\323\344\223\002E\"@/v1/{session=pr" + + "1/type.proto\"\203\001\n\024CreateSessionRequest\0229\n" + + "\010database\030\001 \001(\tB\'\340A\002\372A!\n\037spanner.googlea" + + "pis.com/Database\0220\n\007session\030\002 \001(\0132\032.goog" + + "le.spanner.v1.SessionB\003\340A\002\"\251\001\n\032BatchCrea" + + "teSessionsRequest\0229\n\010database\030\001 \001(\tB\'\340A\002" + + "\372A!\n\037spanner.googleapis.com/Database\0224\n\020" + + "session_template\030\002 \001(\0132\032.google.spanner." + + "v1.Session\022\032\n\rsession_count\030\003 \001(\005B\003\340A\002\"J" + + "\n\033BatchCreateSessionsResponse\022+\n\007session" + + "\030\001 \003(\0132\032.google.spanner.v1.Session\"\363\002\n\007S" + + "ession\022\021\n\004name\030\001 \001(\tB\003\340A\003\0226\n\006labels\030\002 \003(" + + "\0132&.google.spanner.v1.Session.LabelsEntr" + + "y\0224\n\013create_time\030\003 \001(\0132\032.google.protobuf" + + ".TimestampB\003\340A\003\022B\n\031approximate_last_use_" + + "time\030\004 \001(\0132\032.google.protobuf.TimestampB\003" + + "\340A\003\032-\n\013LabelsEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value" + + "\030\002 \001(\t:\0028\001:t\352Aq\n\036spanner.googleapis.com/" + + "Session\022Oprojects/{project}/instances/{i" + + "nstance}/databases/{database}/sessions/{" + + "session}\"I\n\021GetSessionRequest\0224\n\004name\030\001 " + + "\001(\tB&\340A\002\372A \n\036spanner.googleapis.com/Sess" + + "ion\"\207\001\n\023ListSessionsRequest\0229\n\010database\030" + + "\001 \001(\tB\'\340A\002\372A!\n\037spanner.googleapis.com/Da" + + "tabase\022\021\n\tpage_size\030\002 \001(\005\022\022\n\npage_token\030" + + "\003 \001(\t\022\016\n\006filter\030\004 \001(\t\"]\n\024ListSessionsRes" + + "ponse\022,\n\010sessions\030\001 \003(\0132\032.google.spanner" + + ".v1.Session\022\027\n\017next_page_token\030\002 \001(\t\"L\n\024" + + "DeleteSessionRequest\0224\n\004name\030\001 \001(\tB&\340A\002\372" + + "A \n\036spanner.googleapis.com/Session\"\334\001\n\016R" + + "equestOptions\022<\n\010priority\030\001 \001(\0162*.google" + + ".spanner.v1.RequestOptions.Priority\022\023\n\013r" + + "equest_tag\030\002 \001(\t\022\027\n\017transaction_tag\030\003 \001(" + + "\t\"^\n\010Priority\022\030\n\024PRIORITY_UNSPECIFIED\020\000\022" + + "\020\n\014PRIORITY_LOW\020\001\022\023\n\017PRIORITY_MEDIUM\020\002\022\021" + + "\n\rPRIORITY_HIGH\020\003\"\344\005\n\021ExecuteSqlRequest\022" + + "7\n\007session\030\001 \001(\tB&\340A\002\372A \n\036spanner.google" + + "apis.com/Session\022;\n\013transaction\030\002 \001(\0132&." + + "google.spanner.v1.TransactionSelector\022\020\n" + + "\003sql\030\003 \001(\tB\003\340A\002\022\'\n\006params\030\004 \001(\0132\027.google" + + ".protobuf.Struct\022I\n\013param_types\030\005 \003(\01324." + + "google.spanner.v1.ExecuteSqlRequest.Para" + + "mTypesEntry\022\024\n\014resume_token\030\006 \001(\014\022B\n\nque" + + "ry_mode\030\007 \001(\0162..google.spanner.v1.Execut" + + "eSqlRequest.QueryMode\022\027\n\017partition_token" + + "\030\010 \001(\014\022\r\n\005seqno\030\t \001(\003\022H\n\rquery_options\030\n" + + " \001(\01321.google.spanner.v1.ExecuteSqlReque" + + "st.QueryOptions\022:\n\017request_options\030\013 \001(\013" + + "2!.google.spanner.v1.RequestOptions\032O\n\014Q" + + "ueryOptions\022\031\n\021optimizer_version\030\001 \001(\t\022$" + + "\n\034optimizer_statistics_package\030\002 \001(\t\032J\n\017" + + "ParamTypesEntry\022\013\n\003key\030\001 \001(\t\022&\n\005value\030\002 " + + "\001(\0132\027.google.spanner.v1.Type:\0028\001\".\n\tQuer" + + "yMode\022\n\n\006NORMAL\020\000\022\010\n\004PLAN\020\001\022\013\n\007PROFILE\020\002" + + "\"\240\004\n\026ExecuteBatchDmlRequest\0227\n\007session\030\001" + + " \001(\tB&\340A\002\372A \n\036spanner.googleapis.com/Ses" + + "sion\022@\n\013transaction\030\002 \001(\0132&.google.spann" + + "er.v1.TransactionSelectorB\003\340A\002\022L\n\nstatem" + + "ents\030\003 \003(\01323.google.spanner.v1.ExecuteBa" + + "tchDmlRequest.StatementB\003\340A\002\022\022\n\005seqno\030\004 " + + "\001(\003B\003\340A\002\022:\n\017request_options\030\005 \001(\0132!.goog" + + "le.spanner.v1.RequestOptions\032\354\001\n\tStateme" + + "nt\022\020\n\003sql\030\001 \001(\tB\003\340A\002\022\'\n\006params\030\002 \001(\0132\027.g" + + "oogle.protobuf.Struct\022X\n\013param_types\030\003 \003" + + "(\0132C.google.spanner.v1.ExecuteBatchDmlRe" + + "quest.Statement.ParamTypesEntry\032J\n\017Param" + + "TypesEntry\022\013\n\003key\030\001 \001(\t\022&\n\005value\030\002 \001(\0132\027" + + ".google.spanner.v1.Type:\0028\001\"p\n\027ExecuteBa" + + "tchDmlResponse\0221\n\013result_sets\030\001 \003(\0132\034.go" + + "ogle.spanner.v1.ResultSet\022\"\n\006status\030\002 \001(" + + "\0132\022.google.rpc.Status\"H\n\020PartitionOption" + + "s\022\034\n\024partition_size_bytes\030\001 \001(\003\022\026\n\016max_p" + + "artitions\030\002 \001(\003\"\243\003\n\025PartitionQueryReques" + + "t\0227\n\007session\030\001 \001(\tB&\340A\002\372A \n\036spanner.goog" + + "leapis.com/Session\022;\n\013transaction\030\002 \001(\0132" + + "&.google.spanner.v1.TransactionSelector\022" + + "\020\n\003sql\030\003 \001(\tB\003\340A\002\022\'\n\006params\030\004 \001(\0132\027.goog" + + "le.protobuf.Struct\022M\n\013param_types\030\005 \003(\0132" + + "8.google.spanner.v1.PartitionQueryReques" + + "t.ParamTypesEntry\022>\n\021partition_options\030\006" + + " \001(\0132#.google.spanner.v1.PartitionOption" + + "s\032J\n\017ParamTypesEntry\022\013\n\003key\030\001 \001(\t\022&\n\005val" + + "ue\030\002 \001(\0132\027.google.spanner.v1.Type:\0028\001\"\261\002" + + "\n\024PartitionReadRequest\0227\n\007session\030\001 \001(\tB" + + "&\340A\002\372A \n\036spanner.googleapis.com/Session\022" + + ";\n\013transaction\030\002 \001(\0132&.google.spanner.v1" + + ".TransactionSelector\022\022\n\005table\030\003 \001(\tB\003\340A\002" + + "\022\r\n\005index\030\004 \001(\t\022\017\n\007columns\030\005 \003(\t\022/\n\007key_" + + "set\030\006 \001(\0132\031.google.spanner.v1.KeySetB\003\340A" + + "\002\022>\n\021partition_options\030\t \001(\0132#.google.sp" + + "anner.v1.PartitionOptions\"$\n\tPartition\022\027" + + "\n\017partition_token\030\001 \001(\014\"z\n\021PartitionResp" + + "onse\0220\n\npartitions\030\001 \003(\0132\034.google.spanne" + + "r.v1.Partition\0223\n\013transaction\030\002 \001(\0132\036.go" + + "ogle.spanner.v1.Transaction\"\347\002\n\013ReadRequ" + + "est\0227\n\007session\030\001 \001(\tB&\340A\002\372A \n\036spanner.go" + + "ogleapis.com/Session\022;\n\013transaction\030\002 \001(" + + "\0132&.google.spanner.v1.TransactionSelecto" + + "r\022\022\n\005table\030\003 \001(\tB\003\340A\002\022\r\n\005index\030\004 \001(\t\022\024\n\007" + + "columns\030\005 \003(\tB\003\340A\002\022/\n\007key_set\030\006 \001(\0132\031.go" + + "ogle.spanner.v1.KeySetB\003\340A\002\022\r\n\005limit\030\010 \001" + + "(\003\022\024\n\014resume_token\030\t \001(\014\022\027\n\017partition_to" + + "ken\030\n \001(\014\022:\n\017request_options\030\013 \001(\0132!.goo" + + "gle.spanner.v1.RequestOptions\"\313\001\n\027BeginT" + + "ransactionRequest\0227\n\007session\030\001 \001(\tB&\340A\002\372" + + "A \n\036spanner.googleapis.com/Session\022;\n\007op" + + "tions\030\002 \001(\0132%.google.spanner.v1.Transact" + + "ionOptionsB\003\340A\002\022:\n\017request_options\030\003 \001(\013" + + "2!.google.spanner.v1.RequestOptions\"\303\002\n\r" + + "CommitRequest\0227\n\007session\030\001 \001(\tB&\340A\002\372A \n\036" + + "spanner.googleapis.com/Session\022\030\n\016transa" + + "ction_id\030\002 \001(\014H\000\022G\n\026single_use_transacti" + + "on\030\003 \001(\0132%.google.spanner.v1.Transaction" + + "OptionsH\000\022.\n\tmutations\030\004 \003(\0132\033.google.sp" + + "anner.v1.Mutation\022\033\n\023return_commit_stats" + + "\030\005 \001(\010\022:\n\017request_options\030\006 \001(\0132!.google" + + ".spanner.v1.RequestOptionsB\r\n\013transactio" + + "n\"g\n\017RollbackRequest\0227\n\007session\030\001 \001(\tB&\340" + + "A\002\372A \n\036spanner.googleapis.com/Session\022\033\n" + + "\016transaction_id\030\002 \001(\014B\003\340A\0022\300\026\n\007Spanner\022\246" + + "\001\n\rCreateSession\022\'.google.spanner.v1.Cre" + + "ateSessionRequest\032\032.google.spanner.v1.Se" + + "ssion\"P\202\323\344\223\002?\":/v1/{database=projects/*/" + + "instances/*/databases/*}/sessions:\001*\332A\010d" + + "atabase\022\340\001\n\023BatchCreateSessions\022-.google" + + ".spanner.v1.BatchCreateSessionsRequest\032." + + ".google.spanner.v1.BatchCreateSessionsRe" + + "sponse\"j\202\323\344\223\002K\"F/v1/{database=projects/*" + + "/instances/*/databases/*}/sessions:batch" + + "Create:\001*\332A\026database,session_count\022\227\001\n\nG" + + "etSession\022$.google.spanner.v1.GetSession" + + "Request\032\032.google.spanner.v1.Session\"G\202\323\344" + + "\223\002:\0228/v1/{name=projects/*/instances/*/da" + + "tabases/*/sessions/*}\332A\004name\022\256\001\n\014ListSes" + + "sions\022&.google.spanner.v1.ListSessionsRe" + + "quest\032\'.google.spanner.v1.ListSessionsRe" + + "sponse\"M\202\323\344\223\002<\022:/v1/{database=projects/*" + + "/instances/*/databases/*}/sessions\332A\010dat" + + "abase\022\231\001\n\rDeleteSession\022\'.google.spanner" + + ".v1.DeleteSessionRequest\032\026.google.protob" + + "uf.Empty\"G\202\323\344\223\002:*8/v1/{name=projects/*/i" + + "nstances/*/databases/*/sessions/*}\332A\004nam" + + "e\022\243\001\n\nExecuteSql\022$.google.spanner.v1.Exe" + + "cuteSqlRequest\032\034.google.spanner.v1.Resul" + + "tSet\"Q\202\323\344\223\002K\"F/v1/{session=projects/*/in" + + "stances/*/databases/*/sessions/*}:execut" + + "eSql:\001*\022\276\001\n\023ExecuteStreamingSql\022$.google" + + ".spanner.v1.ExecuteSqlRequest\032#.google.s" + + "panner.v1.PartialResultSet\"Z\202\323\344\223\002T\"O/v1/" + + "{session=projects/*/instances/*/database" + + "s/*/sessions/*}:executeStreamingSql:\001*0\001" + + "\022\300\001\n\017ExecuteBatchDml\022).google.spanner.v1" + + ".ExecuteBatchDmlRequest\032*.google.spanner" + + ".v1.ExecuteBatchDmlResponse\"V\202\323\344\223\002P\"K/v1" + + "/{session=projects/*/instances/*/databas" + + "es/*/sessions/*}:executeBatchDml:\001*\022\221\001\n\004" + + "Read\022\036.google.spanner.v1.ReadRequest\032\034.g" + + "oogle.spanner.v1.ResultSet\"K\202\323\344\223\002E\"@/v1/" + + "{session=projects/*/instances/*/database" + + "s/*/sessions/*}:read:\001*\022\254\001\n\rStreamingRea" + + "d\022\036.google.spanner.v1.ReadRequest\032#.goog" + + "le.spanner.v1.PartialResultSet\"T\202\323\344\223\002N\"I" + + "/v1/{session=projects/*/instances/*/data" + + "bases/*/sessions/*}:streamingRead:\001*0\001\022\311" + + "\001\n\020BeginTransaction\022*.google.spanner.v1." + + "BeginTransactionRequest\032\036.google.spanner" + + ".v1.Transaction\"i\202\323\344\223\002Q\"L/v1/{session=pr" + "ojects/*/instances/*/databases/*/session" - + "s/*}:read:\001*\022\254\001\n\rStreamingRead\022\036.google." - + "spanner.v1.ReadRequest\032#.google.spanner." - + "v1.PartialResultSet\"T\202\323\344\223\002N\"I/v1/{sessio" - + "n=projects/*/instances/*/databases/*/ses" - + "sions/*}:streamingRead:\001*0\001\022\311\001\n\020BeginTra" - + "nsaction\022*.google.spanner.v1.BeginTransa" - + "ctionRequest\032\036.google.spanner.v1.Transac" - + "tion\"i\202\323\344\223\002Q\"L/v1/{session=projects/*/in" - + "stances/*/databases/*/sessions/*}:beginT" - + "ransaction:\001*\332A\017session,options\022\353\001\n\006Comm" - + "it\022 .google.spanner.v1.CommitRequest\032!.g" - + "oogle.spanner.v1.CommitResponse\"\233\001\202\323\344\223\002G" - + "\"B/v1/{session=projects/*/instances/*/da" - + "tabases/*/sessions/*}:commit:\001*\332A sessio" - + "n,transaction_id,mutations\332A(session,sin" - + "gle_use_transaction,mutations\022\260\001\n\010Rollba" - + "ck\022\".google.spanner.v1.RollbackRequest\032\026" - + ".google.protobuf.Empty\"h\202\323\344\223\002I\"D/v1/{ses" + + "s/*}:beginTransaction:\001*\332A\017session,optio" + + "ns\022\353\001\n\006Commit\022 .google.spanner.v1.Commit" + + "Request\032!.google.spanner.v1.CommitRespon" + + "se\"\233\001\202\323\344\223\002G\"B/v1/{session=projects/*/ins" + + "tances/*/databases/*/sessions/*}:commit:" + + "\001*\332A session,transaction_id,mutations\332A(" + + "session,single_use_transaction,mutations" + + "\022\260\001\n\010Rollback\022\".google.spanner.v1.Rollba" + + "ckRequest\032\026.google.protobuf.Empty\"h\202\323\344\223\002" + + "I\"D/v1/{session=projects/*/instances/*/d" + + "atabases/*/sessions/*}:rollback:\001*\332A\026ses" + + "sion,transaction_id\022\267\001\n\016PartitionQuery\022(" + + ".google.spanner.v1.PartitionQueryRequest" + + "\032$.google.spanner.v1.PartitionResponse\"U" + + "\202\323\344\223\002O\"J/v1/{session=projects/*/instance" + + "s/*/databases/*/sessions/*}:partitionQue" + + "ry:\001*\022\264\001\n\rPartitionRead\022\'.google.spanner" + + ".v1.PartitionReadRequest\032$.google.spanne" + + "r.v1.PartitionResponse\"T\202\323\344\223\002N\"I/v1/{ses" + "sion=projects/*/instances/*/databases/*/" - + "sessions/*}:rollback:\001*\332A\026session,transa" - + "ction_id\022\267\001\n\016PartitionQuery\022(.google.spa" - + "nner.v1.PartitionQueryRequest\032$.google.s" - + "panner.v1.PartitionResponse\"U\202\323\344\223\002O\"J/v1" - + "/{session=projects/*/instances/*/databas" - + "es/*/sessions/*}:partitionQuery:\001*\022\264\001\n\rP" - + "artitionRead\022\'.google.spanner.v1.Partiti" - + "onReadRequest\032$.google.spanner.v1.Partit" - + "ionResponse\"T\202\323\344\223\002N\"I/v1/{session=projec" - + "ts/*/instances/*/databases/*/sessions/*}" - + ":partitionRead:\001*\032w\312A\026spanner.googleapis" - + ".com\322A[https://www.googleapis.com/auth/c" - + "loud-platform,https://www.googleapis.com" - + "/auth/spanner.dataB\224\002\n\025com.google.spanne" - + "r.v1B\014SpannerProtoP\001Z8google.golang.org/" - + "genproto/googleapis/spanner/v1;spanner\252\002" - + "\027Google.Cloud.Spanner.V1\312\002\027Google\\Cloud\\" - + "Spanner\\V1\352\002\032Google::Cloud::Spanner::V1\352" - + "A_\n\037spanner.googleapis.com/Database\022 com.google.cloud google-cloud-spanner + 6.19.1-SNAPSHOT
+ + com.google.api.grpc + grpc-google-cloud-spanner-admin-database-v1 + 6.19.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-spanner-admin-database-v1 + 6.19.1-SNAPSHOT + io.opencensus diff --git a/samples/snippets/src/main/java/com/example/spanner/CopyBackupSample.java b/samples/snippets/src/main/java/com/example/spanner/CopyBackupSample.java new file mode 100644 index 00000000000..3933fc00c3b --- /dev/null +++ b/samples/snippets/src/main/java/com/example/spanner/CopyBackupSample.java @@ -0,0 +1,123 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner; + +// [START spanner_copy_backup] + +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.Timestamp; +import com.google.cloud.spanner.Backup; +import com.google.cloud.spanner.BackupId; +import com.google.cloud.spanner.DatabaseAdminClient; +import com.google.cloud.spanner.Spanner; +import com.google.cloud.spanner.SpannerException; +import com.google.cloud.spanner.SpannerExceptionFactory; +import com.google.cloud.spanner.SpannerOptions; +import com.google.spanner.admin.database.v1.CopyBackupMetadata; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +public class CopyBackupSample { + + public static void main(String[] args) { + if (args.length != 4) { + throw new IllegalArgumentException( + "Invalid number of arguments. " + + "Usage: CopyBackupSample " + + " "); + } + String projectId = args[0]; + String instanceId = args[1]; + String sourceBackupId = args[2]; + String destinationBackupId = args[3]; + + try (Spanner spanner = + SpannerOptions.newBuilder().setProjectId(projectId).build().getService()) { + DatabaseAdminClient databaseAdminClient = spanner.getDatabaseAdminClient(); + copyBackup(databaseAdminClient, projectId, instanceId, sourceBackupId, destinationBackupId); + } + } + + static void copyBackup() { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String sourceBackupId = "my-backup"; + String destinationBackupId = "my-destination-backup"; + + try (Spanner spanner = + SpannerOptions.newBuilder().setProjectId(projectId).build().getService()) { + DatabaseAdminClient databaseAdminClient = spanner.getDatabaseAdminClient(); + copyBackup(databaseAdminClient, projectId, instanceId, sourceBackupId, destinationBackupId); + } + } + + static Void copyBackup( + DatabaseAdminClient databaseAdminClient, + String projectId, + String instanceId, + String sourceBackupId, + String destinationBackupId) { + + Timestamp expireTime = + Timestamp.ofTimeMicroseconds( + TimeUnit.MICROSECONDS.convert( + System.currentTimeMillis() + TimeUnit.DAYS.toMillis(14), TimeUnit.MILLISECONDS)); + // Creates a copy of an existing backup. + Backup destinationBackup = + databaseAdminClient + .newBackupBuilder(BackupId.of(projectId, instanceId, destinationBackupId)) + .setExpireTime(expireTime) + .build(); + + // Initiate the request which returns an OperationFuture. + System.out.println("Copying backup [" + destinationBackup.getId() + "]..."); + OperationFuture op = + databaseAdminClient.copyBackup( + BackupId.of(projectId, instanceId, sourceBackupId), destinationBackup); + try { + // Wait for the backup operation to complete. + destinationBackup = op.get(); + System.out.println("Copied backup [" + destinationBackup.getId() + "]"); + } catch (ExecutionException e) { + throw (SpannerException) e.getCause(); + } catch (InterruptedException e) { + throw SpannerExceptionFactory.propagateInterrupt(e); + } + + // Reload the metadata of the backup from the server. + destinationBackup = destinationBackup.reload(); + System.out.println( + String.format( + "Backup %s of size %d bytes was copied at %s for version of database at %s", + destinationBackup.getId().getName(), + destinationBackup.getSize(), + LocalDateTime.ofEpochSecond( + destinationBackup.getProto().getCreateTime().getSeconds(), + destinationBackup.getProto().getCreateTime().getNanos(), + OffsetDateTime.now().getOffset()), + LocalDateTime.ofEpochSecond( + destinationBackup.getProto().getVersionTime().getSeconds(), + destinationBackup.getProto().getVersionTime().getNanos(), + OffsetDateTime.now().getOffset()))); + + return null; + } +} +// [END spanner_copy_backup] diff --git a/samples/snippets/src/main/java/com/example/spanner/SpannerSample.java b/samples/snippets/src/main/java/com/example/spanner/SpannerSample.java index d0ccd108145..4db8de52573 100644 --- a/samples/snippets/src/main/java/com/example/spanner/SpannerSample.java +++ b/samples/snippets/src/main/java/com/example/spanner/SpannerSample.java @@ -56,12 +56,14 @@ import com.google.common.io.BaseEncoding; import com.google.longrunning.Operation; import com.google.protobuf.InvalidProtocolBufferException; +import com.google.spanner.admin.database.v1.CopyBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; import com.google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata; import com.google.spanner.admin.database.v1.RestoreDatabaseMetadata; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; import com.google.spanner.v1.ExecuteSqlRequest.QueryOptions; +import java.lang.Math; import java.math.BigDecimal; import java.time.Instant; import java.util.ArrayList; @@ -1659,21 +1661,17 @@ static void cancelCreateBackup( // [END spanner_cancel_backup_create] // [START spanner_list_backup_operations] - static void listBackupOperations(InstanceAdminClient instanceAdminClient, DatabaseId databaseId) { + static void listBackupOperations(InstanceAdminClient instanceAdminClient, DatabaseId databaseId, BackupId backupId) { Instance instance = instanceAdminClient.getInstance(databaseId.getInstanceId().getInstance()); // Get create backup operations for the sample database. - Timestamp last24Hours = Timestamp.ofTimeSecondsAndNanos(TimeUnit.SECONDS.convert( - TimeUnit.HOURS.convert(Timestamp.now().getSeconds(), TimeUnit.SECONDS) - 24, - TimeUnit.HOURS), 0); String filter = String.format( - "(metadata.database:%s) AND " - + "(metadata.@type:type.googleapis.com/" - + "google.spanner.admin.database.v1.CreateBackupMetadata) AND " - + "(metadata.progress.start_time > \"%s\")", - databaseId.getName(), last24Hours); - Page operations = instance.listBackupOperations(Options.filter(filter)); - for (Operation op : operations.iterateAll()) { + "(metadata.@type:type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) " + + "AND (metadata.database:%s)", + databaseId.getName()); + Page createBackupOperations = instance.listBackupOperations(Options.filter(filter)); + System.out.println("Create Backup Operations:"); + for (Operation op : createBackupOperations.iterateAll()) { try { CreateBackupMetadata metadata = op.getMetadata().unpack(CreateBackupMetadata.class); System.out.println( @@ -1687,6 +1685,30 @@ static void listBackupOperations(InstanceAdminClient instanceAdminClient, Databa System.err.println(e.getMessage()); } } + + // Get copy backup operations for the sample database. + filter = + String.format( + "(metadata.@type:type.googleapis.com/" + + "google.spanner.admin.database.v1.CopyBackupMetadata) " + + "AND (metadata.source_backup:%s)", + backupId.getName()); + Page copyBackupOperations = instance.listBackupOperations(Options.filter(filter)); + System.out.println("Copy Backup Operations:"); + for (Operation op : copyBackupOperations.iterateAll()) { + try { + CopyBackupMetadata copyBackupMetadata = op.getMetadata().unpack(CopyBackupMetadata.class); + System.out.println( + String.format( + "Copy Backup %s on backup %s pending: %d%% complete", + copyBackupMetadata.getName(), + copyBackupMetadata.getSourceBackup(), + copyBackupMetadata.getProgress().getProgressPercent())); + } catch (InvalidProtocolBufferException e) { + // The returned operation does not contain CopyBackupMetadata. + System.err.println(e.getMessage()); + } + } } // [END spanner_list_backup_operations] @@ -1840,6 +1862,11 @@ static void updateBackup(DatabaseAdminClient dbAdminClient, BackupId backupId) { TimeUnit.SECONDS.toMicros(backup.getExpireTime().getSeconds()) + TimeUnit.NANOSECONDS.toMicros(backup.getExpireTime().getNanos()) + TimeUnit.DAYS.toMicros(30L)); + // New Expire Time must be less than Max Expire Time + expireTime = expireTime.compareTo(backup.getMaxExpireTime())<0?expireTime:backup.getMaxExpireTime(); + int timeDiff = expireTime.compareTo(backup.getExpireTime()); + Timestamp newExpireTime = (timeDiff < 0) ? expireTime : backup.getExpireTime(); + System.out.println(String.format( "Updating expire time of backup [%s] to %s...", backupId.toString(), @@ -2048,7 +2075,7 @@ static void run( BackupId.of(backup.getInstanceId(), backup.getBackup() + "_cancel")); break; case "listbackupoperations": - listBackupOperations(instanceAdminClient, database); + listBackupOperations(instanceAdminClient, database, backup); break; case "listdatabaseoperations": listDatabaseOperations(instanceAdminClient, dbAdminClient, database.getInstanceId()); @@ -2144,14 +2171,14 @@ static void printUsageAndExit() { System.err.println(" SpannerExample querywithqueryoptions my-instance example-db"); System.err.println(" SpannerExample createbackup my-instance example-db"); System.err.println(" SpannerExample listbackups my-instance example-db"); - System.err.println(" SpannerExample listbackupoperations my-instance example-db"); + System.err.println(" SpannerExample listbackupoperations my-instance example-db backup-id"); System.err.println(" SpannerExample listdatabaseoperations my-instance example-db"); System.err.println(" SpannerExample restorebackup my-instance example-db"); System.exit(1); } public static void main(String[] args) throws Exception { - if (args.length != 3) { + if (args.length != 3 && args.length != 4) { printUsageAndExit(); } // [START init_client] @@ -2175,6 +2202,9 @@ public static void main(String[] args) throws Exception { String.format( "%s_%02d", db.getDatabase(), LocalDate.now().get(ChronoField.ALIGNED_WEEK_OF_YEAR)); + if( args.length == 4) { + backupName = args[3]; + } BackupId backup = BackupId.of(db.getInstanceId(), backupName); // [START init_client]