add: app data rename method
This commit is contained in:
parent
35b66c94d0
commit
6f2d556c65
10 changed files with 100 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "tetratto-core"
|
||||
description = "The core behind Tetratto"
|
||||
version = "11.0.0"
|
||||
version = "12.0.0"
|
||||
edition = "2024"
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
|
@ -18,8 +18,8 @@ default = ["database", "types", "sdk"]
|
|||
pathbufd = "0.1.4"
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
toml = "0.9.2"
|
||||
tetratto-shared = { version = "11.0.0", path = "../shared" }
|
||||
tetratto-l10n = { version = "11.0.0", path = "../l10n" }
|
||||
tetratto-shared = { version = "12.0.0", path = "../shared" }
|
||||
tetratto-l10n = { version = "12.0.0", path = "../l10n" }
|
||||
serde_json = "1.0.141"
|
||||
totp-rs = { version = "5.7.0", features = ["qr", "gen_secret"], optional = true }
|
||||
reqwest = { version = "0.12.22", features = ["json", "multipart"], optional = true }
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue