use super::*;
impl ApiClient {
pub async fn backups(&self, service_environment_id: &str) -> Result<BackupsPage> {
self.get(&format!(
"/api/infra/services/{service_environment_id}/backups"
))
.await
}
pub async fn take_backup(&self, service_environment_id: &str) -> Result<Backup> {
Ok(self
.post_empty::<BackupTaken>(&format!(
"/api/infra/services/{service_environment_id}/backups"
))
.await?
.backup)
}
pub async fn schedule_backups(
&self,
service_environment_id: &str,
schedules: &[String],
) -> Result<Vec<String>> {
Ok(self
.put::<BackupSchedules, _>(
&format!("/api/infra/services/{service_environment_id}/backups/schedule"),
&serde_json::json!({ "schedules": schedules }),
)
.await?
.schedules)
}
pub async fn restore_backup(&self, backup_id: &str) -> Result<Backup> {
Ok(self
.post_empty::<BackupTaken>(
&self.released(&format!("/api/infra/backups/{backup_id}/restore")),
)
.await?
.backup)
}
pub async fn lock_backup(&self, backup_id: &str, locked: bool) -> Result<Backup> {
Ok(self
.put::<BackupTaken, _>(
&format!("/api/infra/backups/{backup_id}/lock"),
&serde_json::json!({ "locked": locked }),
)
.await?
.backup)
}
pub async fn delete_backup(&self, backup_id: &str) -> Result<()> {
self.delete(&format!("/api/infra/backups/{backup_id}"))
.await
}
pub async fn volumes(&self, service_environment_id: &str) -> Result<Vec<Volume>> {
Ok(self
.get::<VolumesPage>(&format!(
"/api/infra/services/{service_environment_id}/volumes"
))
.await?
.volumes)
}
pub async fn attach_volume(
&self,
service_environment_id: &str,
mount_path: &str,
) -> Result<Volume> {
Ok(self
.post::<VolumeAttached, _>(
&format!("/api/infra/services/{service_environment_id}/volumes"),
&serde_json::json!({ "mountPath": mount_path }),
)
.await?
.volume)
}
pub async fn resize_volume(&self, volume_id: &str, size_limit_mb: u64) -> Result<Volume> {
Ok(self
.patch_for::<VolumeAttached, _>(
&format!("/api/infra/volumes/{volume_id}"),
&serde_json::json!({ "sizeLimitMb": size_limit_mb }),
)
.await?
.volume)
}
pub async fn detach_volume(&self, volume_id: &str) -> Result<()> {
self.delete(&self.released(&format!("/api/infra/volumes/{volume_id}")))
.await
}
}