Skip to content

feat: Add samples for backup schedule feature APIs. #3339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Refactored samples' console logs.
  • Loading branch information
aman-19 committed Sep 23, 2024
commit b22ae047b869fb5234bd8e780caa323f78f6d2ab
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ static void createFullBackupSchedule(
.setBackupSchedule(backupSchedule)
.build());
System.out.println(
String.format("Created backup schedule: %s", createdBackupSchedule.getName()));
String.format(
"Created backup schedule: %s\n%s",
createdBackupSchedule.getName(), createdBackupSchedule.toString()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ static void createIncrementalBackupSchedule(
.build());
System.out.println(
String.format(
"Created incremental backup schedule: %s", createdBackupSchedule.getName()));
"Created incremental backup schedule: %s\n%s",
createdBackupSchedule.getName(), createdBackupSchedule.toString()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ static void getBackupSchedule(
databaseAdminClient.getBackupSchedule(
GetBackupScheduleRequest.newBuilder().setName(backupScheduleName.toString()).build());
System.out.println(
String.format("Retrieved backup schedule: %s", backupScheduleName.toString()));
String.format(
"Backup schedule: %s\n%s", backupSchedule.getName(), backupSchedule.toString()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
// [START spanner_list_backup_schedules]

import com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient;
import com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupSchedulesPage;
import com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupSchedulesPagedResponse;
import com.google.spanner.admin.database.v1.BackupSchedule;
import com.google.spanner.admin.database.v1.DatabaseName;
import com.google.spanner.admin.database.v1.ListBackupSchedulesRequest;
import java.io.IOException;

class ListBackupSchedulesSample {
Expand All @@ -40,16 +37,14 @@ static void listBackupSchedules(String projectId, String instanceId, String data
throws IOException {
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DatabaseName databaseName = DatabaseName.of(projectId, instanceId, databaseId);
ListBackupSchedulesPagedResponse backupSchedules =
databaseAdminClient.listBackupSchedules(
ListBackupSchedulesRequest.newBuilder().setParent(databaseName.toString()).build());

System.out.println(
String.format("Backup schedules for database '%s'", databaseName.toString()));
for (ListBackupSchedulesPage page : backupSchedules.iteratePages()) {
for (BackupSchedule backupSchedule : page.iterateAll()) {
System.out.println(String.format("Backup schedule: %s", backupSchedule.getName()));
}
for (BackupSchedule backupSchedule :
databaseAdminClient.listBackupSchedules(databaseName).iterateAll()) {
System.out.println(
String.format(
"Backup schedule: %s\n%s", backupSchedule.getName(), backupSchedule.toString()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ static void updateBackupSchedule(
.setUpdateMask(fieldMask)
.build());
System.out.println(
String.format("Updated backup schedule: %s", updatedBackupSchedule.getName()));
String.format(
"Updated backup schedule: %s\n%s",
updatedBackupSchedule.getName(), updatedBackupSchedule.toString()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ public void testGetBackupScheduleSample() throws Exception {
projectId, instanceId, databaseId, backupScheduleId);
}
});
assertThat(out).contains(String.format("Retrieved backup schedule: %s", backupScheduleName));
assertThat(out).contains(String.format("Backup schedule: %s", backupScheduleName));
}
}
Loading