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::encode_path;
use reqwest::Method;
use serde_json::Value;

/// The `account` resource — 5 operation(s).
///
/// Account API keys (with expiry and IP allowlists) and your data export.
///
/// Reached through [`crate::MisarDev::account`].
#[derive(Debug, Clone, Copy)]
pub struct AccountResource<'a> {
    pub(crate) t: &'a Transport,
}

impl AccountResource<'_> {
    /// `POST /account/api-keys`
    ///
    /// misardev:method account.createKey
    pub async fn create_key(self, body: Option<Value>) -> Result<Value, MisarDevError> {
        self.t.request(Method::POST, "/account/api-keys", "", Some(body_or_empty(body))).await
    }

    /// `DELETE /account/api-keys/:keyId`
    ///
    /// misardev:method account.deleteKey
    pub async fn delete_key(self, key_id: &str) -> Result<Value, MisarDevError> {
        self.t.request(Method::DELETE, &format!("/account/api-keys/{}", encode_path(key_id)), "", None).await
    }

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

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

    /// `PATCH /account/api-keys/:keyId`
    ///
    /// misardev:method account.updateKey
    pub async fn update_key(self, key_id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
        self.t.request(Method::PATCH, &format!("/account/api-keys/{}", encode_path(key_id)), "", Some(body_or_empty(body))).await
    }
}