Skip to content

Commit 78b09aa

Browse files
committed
Add backup download scope
1 parent 712ac54 commit 78b09aa

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/cli.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,9 @@ pub enum BackupCommands {
989989
Create {
990990
/// Site ID
991991
site_id: String,
992+
/// Backup scope (full, database, files)
993+
#[arg(long, default_value = "full")]
994+
scope: String,
992995
/// Backup description
993996
#[arg(long)]
994997
description: Option<String>,

src/commands/backup.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct PaginationQuery {
1616
#[derive(Debug, Serialize)]
1717
struct CreateBackupRequest {
1818
r#type: String,
19+
scope: String,
1920
#[serde(skip_serializing_if = "Option::is_none")]
2021
description: Option<String>,
2122
}
@@ -51,14 +52,15 @@ pub fn list(
5152
vec![
5253
b["id"].as_str().unwrap_or("-").to_string(),
5354
b["type"].as_str().unwrap_or("-").to_string(),
55+
b["scope"].as_str().unwrap_or("-").to_string(),
5456
b["status"].as_str().unwrap_or("-").to_string(),
5557
format_option(&b["description"].as_str().map(String::from)),
5658
format_option(&b["created_at"].as_str().map(String::from)),
5759
]
5860
})
5961
.collect();
6062

61-
print_table(vec!["ID", "Type", "Status", "Description", "Created"], rows);
63+
print_table(vec!["ID", "Type", "Scope", "Status", "Description", "Created"], rows);
6264

6365
if let Some((current, last, total)) = extract_pagination(&response) {
6466
print_pagination(current, last, total);
@@ -88,6 +90,10 @@ pub fn show(
8890
print_key_value(vec![
8991
("ID", backup["id"].as_str().unwrap_or("-").to_string()),
9092
("Type", backup["type"].as_str().unwrap_or("-").to_string()),
93+
(
94+
"Scope",
95+
backup["scope"].as_str().unwrap_or("-").to_string(),
96+
),
9197
(
9298
"Status",
9399
backup["status"].as_str().unwrap_or("-").to_string(),
@@ -97,8 +103,12 @@ pub fn show(
97103
format_option(&backup["description"].as_str().map(String::from)),
98104
),
99105
(
100-
"Snapshot ID",
101-
format_option(&backup["snapshot_id"].as_str().map(String::from)),
106+
"File Snapshot ID",
107+
format_option(&backup["file_snapshot_id"].as_str().map(String::from)),
108+
),
109+
(
110+
"Database Snapshot ID",
111+
format_option(&backup["database_snapshot_id"].as_str().map(String::from)),
102112
),
103113
(
104114
"Started At",
@@ -124,11 +134,13 @@ pub fn show(
124134
pub fn create(
125135
client: &ApiClient,
126136
site_id: &str,
137+
scope: &str,
127138
description: Option<String>,
128139
format: OutputFormat,
129140
) -> Result<(), ApiError> {
130141
let body = CreateBackupRequest {
131142
r#type: "manual".to_string(),
143+
scope: scope.to_string(),
132144
description,
133145
};
134146

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,9 @@ fn run_backup(command: BackupCommands, format: OutputFormat) -> Result<(), ApiEr
631631
}
632632
BackupCommands::Create {
633633
site_id,
634+
scope,
634635
description,
635-
} => backup::create(&client, &site_id, description, format),
636+
} => backup::create(&client, &site_id, &scope, description, format),
636637
}
637638
}
638639

0 commit comments

Comments
 (0)