Search in sources :

Example 1 with UpdateBackupRequest

use of com.google.spanner.admin.database.v1.UpdateBackupRequest in project java-spanner by googleapis.

the class DatabaseAdminClientTest method updateBackupTest.

@Test
public void updateBackupTest() 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<String>()).setEncryptionInfo(EncryptionInfo.newBuilder().build()).setDatabaseDialect(DatabaseDialect.forNumber(0)).build();
    mockDatabaseAdmin.addResponse(expectedResponse);
    Backup backup = Backup.newBuilder().build();
    FieldMask updateMask = FieldMask.newBuilder().build();
    Backup actualResponse = client.updateBackup(backup, updateMask);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDatabaseAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateBackupRequest actualRequest = ((UpdateBackupRequest) actualRequests.get(0));
    Assert.assertEquals(backup, actualRequest.getBackup());
    Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Backup(com.google.spanner.admin.database.v1.Backup) ArrayList(java.util.ArrayList) UpdateBackupRequest(com.google.spanner.admin.database.v1.UpdateBackupRequest) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 2 with UpdateBackupRequest

use of com.google.spanner.admin.database.v1.UpdateBackupRequest in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method updateBackupTest.

@Test
public void updateBackupTest() throws Exception {
    Backup expectedResponse = Backup.newBuilder().setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[BACKUP]").toString()).setSourceTable("sourceTable-95372173").setExpireTime(Timestamp.newBuilder().build()).setStartTime(Timestamp.newBuilder().build()).setEndTime(Timestamp.newBuilder().build()).setSizeBytes(-1796325715).setEncryptionInfo(EncryptionInfo.newBuilder().build()).build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    Backup backup = Backup.newBuilder().build();
    FieldMask updateMask = FieldMask.newBuilder().build();
    Backup actualResponse = client.updateBackup(backup, updateMask);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateBackupRequest actualRequest = ((UpdateBackupRequest) actualRequests.get(0));
    Assert.assertEquals(backup, actualRequest.getBackup());
    Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Backup(com.google.bigtable.admin.v2.Backup) UpdateBackupRequest(com.google.bigtable.admin.v2.UpdateBackupRequest) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 3 with UpdateBackupRequest

use of com.google.spanner.admin.database.v1.UpdateBackupRequest in project java-spanner by googleapis.

the class GapicSpannerRpc method updateBackup.

@Override
public Backup updateBackup(Backup backup, FieldMask updateMask) {
    acquireAdministrativeRequestsRateLimiter();
    final UpdateBackupRequest request = UpdateBackupRequest.newBuilder().setBackup(backup).setUpdateMask(updateMask).build();
    final GrpcCallContext context = newCallContext(null, backup.getName(), request, DatabaseAdminGrpc.getUpdateBackupMethod());
    return runWithRetryOnAdministrativeRequestsExceeded(() -> databaseAdminStub.updateBackupCallable().call(request, context));
}
Also used : GrpcCallContext(com.google.api.gax.grpc.GrpcCallContext) UpdateBackupRequest(com.google.spanner.admin.database.v1.UpdateBackupRequest)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)2 FieldMask (com.google.protobuf.FieldMask)2 UpdateBackupRequest (com.google.spanner.admin.database.v1.UpdateBackupRequest)2 Test (org.junit.Test)2 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)1 Backup (com.google.bigtable.admin.v2.Backup)1 UpdateBackupRequest (com.google.bigtable.admin.v2.UpdateBackupRequest)1 Backup (com.google.spanner.admin.database.v1.Backup)1 ArrayList (java.util.ArrayList)1