use std::collections::HashMap;
use serde_json::Value;
use crate::error::TombaError;
use crate::tomba::{Tomba, TombaResponse};
impl Tomba {
pub fn list_keys(&self) -> Result<TombaResponse, TombaError> {
self.call("GET", "keys", &HashMap::new())
}
pub fn get_key(&self, id: &str) -> Result<TombaResponse, TombaError> {
let path = format!("keys/{}", id);
self.call("GET", &path, &HashMap::new())
}
pub fn create_key(
&self,
body: &Value,
) -> Result<TombaResponse, TombaError> {
self.call_json("POST", "keys", body)
}
pub fn delete_key(&self, id: &str) -> Result<TombaResponse, TombaError> {
let path = format!("keys/{}", id);
self.call("DELETE", &path, &HashMap::new())
}
pub fn reset_key(&self, id: &str) -> Result<TombaResponse, TombaError> {
let path = format!("keys/{}/reset", id);
self.call_json("PUT", &path, &serde_json::json!({}))
}
}