add: app data rename method

This commit is contained in:
trisua 2025-07-19 23:21:01 -04:00
parent 35b66c94d0
commit 6f2d556c65
10 changed files with 100 additions and 12 deletions

View file

@ -129,6 +129,25 @@ impl DataClient {
}
}
/// Update a record's key given its ID and the new key.
pub async fn rename(&self, id: usize, key: String) -> Result<()> {
match self
.http
.post(format!("{}/api/v1/app_data/{id}/key", self.host))
.header("Atto-Secret-Key", &self.api_key)
.json(&serde_json::Value::Object({
let mut map = serde_json::Map::new();
map.insert("key".to_string(), serde_json::Value::String(key));
map
}))
.send()
.await
{
Ok(x) => api_return_ok!((), x),
Err(e) => Err(Error::MiscError(e.to_string())),
}
}
/// Delete a row from the app's data by its `id`.
pub async fn remove(&self, id: usize) -> Result<()> {
match self