uarp-sdk 0.5.7

Async Rust client for the UARP (Snaga) Universal Agent Runtime Platform API
Documentation
// Code generated by @uarp/codegen from spec/openapi.json. DO NOT EDIT.
//!
//! Company management

#![allow(unused_imports, clippy::too_many_arguments)]

use reqwest::Method;
use serde::{Deserialize, Serialize};

use crate::client::{Client, Request, NO_BODY, NO_QUERY};
use crate::error::Result;
use crate::generated::models;
use crate::multipart::{field_text, FilePart};
use crate::util::encode_path;

/// Company management
#[derive(Debug, Clone)]
pub struct CompaniesApi {
    pub(crate) client: Client,
}

impl Client {
    /// Company management
    pub fn companies(&self) -> CompaniesApi {
        CompaniesApi { client: self.clone() }
    }
}

impl CompaniesApi {
    /// Create a company
    ///
    /// `POST /api/v1/companies`
    ///
    /// Required scopes: `agents:write`.
    pub async fn create(&self, body: &models::CompanyCreate) -> Result<models::Company> {
        self.client
            .request_json(Request {
                method: Method::POST,
                path: "/api/v1/companies".to_string(),
                query: NO_QUERY,
                body: Some(body),
                headers: Vec::new(),
                idempotent: true,
            })
            .await
    }

    /// Delete company
    ///
    /// `DELETE /api/v1/companies/{id}`
    ///
    /// Required scopes: `agents:write`.
    pub async fn delete(&self, id: &str) -> Result<()> {
        self.client
            .request_empty(Request {
                method: Method::DELETE,
                path: format!("/api/v1/companies/{}", encode_path(id)),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: true,
            })
            .await
    }

    /// Get company
    ///
    /// `GET /api/v1/companies/{id}`
    ///
    /// Required scopes: `agents:read`.
    pub async fn get(&self, id: &str) -> Result<models::Company> {
        self.client
            .request_json(Request {
                method: Method::GET,
                path: format!("/api/v1/companies/{}", encode_path(id)),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: false,
            })
            .await
    }

    /// Get company activity log
    ///
    /// `GET /api/v1/companies/{companyId}/activity`
    ///
    /// Required scopes: `agents:read`.
    pub async fn get_company_activity(&self, company_id: &str) -> Result<models::GetCompanyActivityResponse> {
        self.client
            .request_json(Request {
                method: Method::GET,
                path: format!("/api/v1/companies/{}/activity", encode_path(company_id)),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: false,
            })
            .await
    }

    /// Get company budget allocation
    ///
    /// `GET /api/v1/companies/{companyId}/budget`
    ///
    /// Required scopes: `agents:read`.
    pub async fn get_company_budget(&self, company_id: &str) -> Result<models::GetCompanyBudgetResponse> {
        self.client
            .request_json(Request {
                method: Method::GET,
                path: format!("/api/v1/companies/{}/budget", encode_path(company_id)),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: false,
            })
            .await
    }

    /// Get company strategic objectives
    ///
    /// `GET /api/v1/companies/{companyId}/objectives`
    ///
    /// Required scopes: `agents:read`.
    pub async fn get_company_objectives(&self, company_id: &str) -> Result<models::GetCompanyObjectivesResponse> {
        self.client
            .request_json(Request {
                method: Method::GET,
                path: format!("/api/v1/companies/{}/objectives", encode_path(company_id)),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: false,
            })
            .await
    }

    /// List companies
    ///
    /// `GET /api/v1/companies`
    ///
    /// Required scopes: `agents:read`.
    pub async fn list(&self) -> Result<models::ListCompaniesResponse> {
        self.client
            .request_json(Request {
                method: Method::GET,
                path: "/api/v1/companies".to_string(),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: false,
            })
            .await
    }

    /// Pause company operations
    ///
    /// `POST /api/v1/companies/{companyId}/pause`
    ///
    /// Required scopes: `agents:write`.
    pub async fn pause_company(&self, company_id: &str) -> Result<models::PauseCompanyResponse> {
        self.client
            .request_json(Request {
                method: Method::POST,
                path: format!("/api/v1/companies/{}/pause", encode_path(company_id)),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: true,
            })
            .await
    }

    /// Resume company operations
    ///
    /// `POST /api/v1/companies/{companyId}/resume`
    ///
    /// Required scopes: `agents:write`.
    pub async fn resume(&self, company_id: &str) -> Result<models::ResumeCompanyResponse> {
        self.client
            .request_json(Request {
                method: Method::POST,
                path: format!("/api/v1/companies/{}/resume", encode_path(company_id)),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: true,
            })
            .await
    }

    /// Update company
    ///
    /// `PUT /api/v1/companies/{id}`
    ///
    /// Required scopes: `agents:write`.
    pub async fn update(&self, id: &str, body: &models::CompanyUpdate) -> Result<models::Company> {
        self.client
            .request_json(Request {
                method: Method::PUT,
                path: format!("/api/v1/companies/{}", encode_path(id)),
                query: NO_QUERY,
                body: Some(body),
                headers: Vec::new(),
                idempotent: true,
            })
            .await
    }
}