use crate::client::Client;
use crate::error::Result;
use crate::types::{CollectionListResponse, CollectionResponse};
use serde::Serialize;
pub struct Collections<'a> {
client: &'a Client,
}
impl<'a> Collections<'a> {
pub(crate) fn new(client: &'a Client) -> Self {
Self { client }
}
pub async fn add(&self, collection_name: impl Into<String>) -> Result<CollectionResponse> {
#[derive(Serialize)]
struct Request {
collection_name: String,
}
let body = Request {
collection_name: collection_name.into(),
};
self.client.post("/collections/add-collection", &body).await
}
pub async fn delete(&self, collection_name: impl Into<String>) -> Result<CollectionResponse> {
#[derive(Serialize)]
struct Request {
collection_name: String,
}
let body = Request {
collection_name: collection_name.into(),
};
self.client.post("/collections/delete-collection", &body).await
}
pub async fn get_list(&self) -> Result<CollectionListResponse> {
self.client.post("/collections/get-collection-list", &serde_json::json!({})).await
}
}