use crate::client::RestClient;
use crate::error::Result;
use serde_json::Value;
pub struct JsonSchemaHandler {
client: RestClient,
}
impl JsonSchemaHandler {
pub fn new(client: RestClient) -> Self {
JsonSchemaHandler { client }
}
pub async fn list(&self) -> Result<Vec<String>> {
self.client.get("/v1/jsonschema").await
}
pub async fn get(&self, schema_name: &str) -> Result<Value> {
self.client
.get(&format!("/v1/jsonschema/{}", schema_name))
.await
}
pub async fn database_schema(&self) -> Result<Value> {
self.client.get("/v1/jsonschema/bdb").await
}
pub async fn cluster_schema(&self) -> Result<Value> {
self.client.get("/v1/jsonschema/cluster").await
}
pub async fn node_schema(&self) -> Result<Value> {
self.client.get("/v1/jsonschema/node").await
}
pub async fn user_schema(&self) -> Result<Value> {
self.client.get("/v1/jsonschema/user").await
}
pub async fn crdb_schema(&self) -> Result<Value> {
self.client.get("/v1/jsonschema/crdb").await
}
pub async fn validate(&self, schema_name: &str, object: &Value) -> Result<Value> {
self.client
.post(&format!("/v1/jsonschema/{}/validate", schema_name), object)
.await
}
}