use crate::error::MisarDevError;
use crate::sse::EventStream;
use crate::transport::Transport;
use crate::transport::body_or_empty;
use crate::transport::build_query;
use crate::transport::encode_path;
use reqwest::Method;
use serde_json::Value;
#[derive(Debug, Clone, Copy)]
pub struct ProjectsResource<'a> {
pub(crate) t: &'a Transport,
}
impl ProjectsResource<'_> {
pub async fn add_collaborator(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/projects/{}/collaborators", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn archive(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/projects/{}/archive", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn build_status(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/build-status", encode_path(id)), "", None).await
}
pub async fn cancel_build(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/projects/{}/cancel-build", encode_path(id)), "", None).await
}
pub async fn check_subdomain(self, id: &str, value: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/subdomain/check", encode_path(id)), &build_query(None, &[("value", value)]), None).await
}
pub async fn create(self, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, "/projects", "", Some(body_or_empty(body))).await
}
pub async fn create_conversation(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/projects/{}/conversations", encode_path(id)), "", None).await
}
pub async fn delete(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::DELETE, &format!("/projects/{}", encode_path(id)), "", None).await
}
pub async fn delete_env(self, id: &str, key: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::DELETE, &format!("/projects/{}/env", encode_path(id)), &build_query(None, &[("key", key)]), None).await
}
pub async fn delete_skills(self, id: &str, slug: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::DELETE, &format!("/projects/{}/skills", encode_path(id)), &build_query(None, &[("slug", slug)]), None).await
}
pub async fn deploy(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/projects/{}/deploy", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn duplicate(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/projects/{}/duplicate", encode_path(id)), "", None).await
}
pub async fn export(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/export", encode_path(id)), "", None).await
}
pub async fn get(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}", encode_path(id)), "", None).await
}
pub async fn get_backend(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/backend", encode_path(id)), "", None).await
}
pub async fn get_deployment(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/deploy", encode_path(id)), "", None).await
}
pub async fn get_domain(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/domain", encode_path(id)), "", None).await
}
pub async fn get_env(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/env", encode_path(id)), "", None).await
}
pub async fn get_knowledge(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/knowledge", encode_path(id)), "", None).await
}
pub async fn get_skills(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/skills", encode_path(id)), "", None).await
}
pub async fn get_tools(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/tools", encode_path(id)), "", None).await
}
pub async fn import_artifact(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/projects/{}/import-artifact", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn list(self, query: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, "/projects", &build_query(query.as_ref(), &[]), None).await
}
pub async fn list_checkpoints(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/checkpoints", encode_path(id)), "", None).await
}
pub async fn list_collaborators(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/collaborators", encode_path(id)), "", None).await
}
pub async fn list_conversations(self, id: &str, query: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/conversations", encode_path(id)), &build_query(query.as_ref(), &[]), None).await
}
pub async fn list_files(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/files", encode_path(id)), "", None).await
}
pub async fn provision_backend(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/projects/{}/backend", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn recommend_domains(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/projects/{}/domains/recommend", encode_path(id)), "", None).await
}
pub async fn remove_collaborator(self, id: &str, collaborator_id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::DELETE, &format!("/projects/{}/collaborators", encode_path(id)), &build_query(None, &[("collaboratorId", collaborator_id)]), None).await
}
pub async fn remove_domain(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::DELETE, &format!("/projects/{}/domain", encode_path(id)), "", None).await
}
pub async fn restore(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/projects/{}", encode_path(id)), "", None).await
}
pub async fn set_domain(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/projects/{}/domain", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn undeploy(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::DELETE, &format!("/projects/{}/deploy", encode_path(id)), "", None).await
}
pub async fn update(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::PATCH, &format!("/projects/{}", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn update_env(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::PUT, &format!("/projects/{}/env", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn update_knowledge(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::PUT, &format!("/projects/{}/knowledge", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn update_skills(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::PUT, &format!("/projects/{}/skills", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn update_subdomain(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::PATCH, &format!("/projects/{}/subdomain", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn update_tools(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::PUT, &format!("/projects/{}/tools", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn write_files(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/projects/{}/files", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn build_stream(self, id: &str) -> Result<EventStream, MisarDevError> {
self.t.stream(Method::GET, &format!("/projects/{}/build-stream", encode_path(id)), "", None, None).await
}
}