misardev 1.0.0

Async Rust client for the Misar.Dev API: create projects, write files, build and deploy, start from templates, run OpenAI-compatible chat completions, search code and read usage. Retries, typed plan-limit errors, SSE streaming.
Documentation
// GENERATED by scripts/generate-sdk-resources.mjs from sdks/manifest.json.
// Do not edit by hand — change the route, run `pnpm sdk:sync`, and regenerate.

use crate::error::MisarDevError;
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;

/// The `connectors` resource — 8 operation(s).
///
/// Connector catalogue, per-account enable state, and per-project connections.
///
/// Reached through [`crate::MisarDev::connectors`].
#[derive(Debug, Clone, Copy)]
pub struct ConnectorsResource<'a> {
    pub(crate) t: &'a Transport,
}

impl ConnectorsResource<'_> {
    /// `GET /connectors/available`
    ///
    /// misardev:method connectors.available
    pub async fn available(self) -> Result<Value, MisarDevError> {
        self.t.request(Method::GET, "/connectors/available", "", None).await
    }

    /// `POST /connectors/connections`
    ///
    /// misardev:method connectors.createConnection
    pub async fn create_connection(self, body: Option<Value>) -> Result<Value, MisarDevError> {
        self.t.request(Method::POST, "/connectors/connections", "", Some(body_or_empty(body))).await
    }

    /// `DELETE /connectors/connections/:id`
    ///
    /// misardev:method connectors.deleteConnection
    pub async fn delete_connection(self, id: &str) -> Result<Value, MisarDevError> {
        self.t.request(Method::DELETE, &format!("/connectors/connections/{}", encode_path(id)), "", None).await
    }

    /// `GET /connectors`
    ///
    /// misardev:method connectors.list
    pub async fn list(self) -> Result<Value, MisarDevError> {
        self.t.request(Method::GET, "/connectors", "", None).await
    }

    /// `GET /connectors/connections`
    ///
    /// Optional query: `projectId`.
    ///
    /// misardev:method connectors.listConnections
    pub async fn list_connections(self, query: Option<Value>) -> Result<Value, MisarDevError> {
        self.t.request(Method::GET, "/connectors/connections", &build_query(query.as_ref(), &[]), None).await
    }

    /// `POST /connectors/connections/:id/test`
    ///
    /// misardev:method connectors.testConnection
    pub async fn test_connection(self, id: &str) -> Result<Value, MisarDevError> {
        self.t.request(Method::POST, &format!("/connectors/connections/{}/test", encode_path(id)), "", None).await
    }

    /// `POST /connectors/:slug/toggle`
    ///
    /// misardev:method connectors.toggle
    pub async fn toggle(self, slug: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
        self.t.request(Method::POST, &format!("/connectors/{}/toggle", encode_path(slug)), "", Some(body_or_empty(body))).await
    }

    /// `PATCH /connectors/connections/:id`
    ///
    /// misardev:method connectors.updateConnection
    pub async fn update_connection(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
        self.t.request(Method::PATCH, &format!("/connectors/connections/{}", encode_path(id)), "", Some(body_or_empty(body))).await
    }
}