use serde::Deserialize;
use crate::client::Client;
use crate::error::Result;
use crate::http::{send, send_empty, RequestOpts};
use crate::timestamp::Timestamp;
#[derive(Debug, Clone, Deserialize)]
pub struct ExportSchemaListItem {
pub id: String,
pub name: String,
pub stream_category: String,
pub is_built_in: bool,
pub created_at: Timestamp,
pub version: i32,
pub has_draft: bool,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ExportSchemaWithVersion {
pub id: String,
pub name: String,
pub stream_category: String,
pub is_built_in: bool,
pub created_at: Timestamp,
pub version: i32,
pub has_draft: bool,
pub columns: serde_json::Value,
#[serde(default)]
pub unfold: Option<serde_json::Value>,
#[serde(default)]
pub derive: Option<serde_json::Value>,
}
pub struct ExportSchemasResource<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ExportSchemasResource<'a> {
pub async fn list(&self) -> Result<Vec<ExportSchemaListItem>> {
send::<_, ()>(
self.client,
reqwest::Method::GET,
"/export-schemas",
None,
None,
RequestOpts::default(),
)
.await
}
pub async fn get(&self, id: &str) -> Result<ExportSchemaWithVersion> {
let path = format!("/export-schemas/{id}");
send::<_, ()>(
self.client,
reqwest::Method::GET,
&path,
None,
None,
RequestOpts::default(),
)
.await
}
pub async fn delete(&self, id: &str) -> Result<()> {
let path = format!("/export-schemas/{id}");
send_empty::<()>(
self.client,
reqwest::Method::DELETE,
&path,
None,
None,
RequestOpts::default(),
)
.await
}
}