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.
//!
//! Program (curriculum) 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;

/// Program (curriculum) management
#[derive(Debug, Clone)]
pub struct ProgramsApi {
    pub(crate) client: Client,
}

impl Client {
    /// Program (curriculum) management
    pub fn programs(&self) -> ProgramsApi {
        ProgramsApi { client: self.clone() }
    }
}

impl ProgramsApi {
    /// Apply program to session (create todos)
    ///
    /// `POST /api/v1/programs/{programId}/apply`
    ///
    /// Required scopes: `sessions:write`.
    pub async fn apply_program(&self, program_id: &str, body: &models::ApplyProgramRequest) -> Result<serde_json::Value> {
        self.client
            .request_json(Request {
                method: Method::POST,
                path: format!("/api/v1/programs/{}/apply", encode_path(program_id)),
                query: NO_QUERY,
                body: Some(body),
                headers: Vec::new(),
                idempotent: true,
            })
            .await
    }

    /// Create a program (curriculum)
    ///
    /// `POST /api/v1/programs`
    ///
    /// Required scopes: `agents:write`.
    pub async fn create(&self, body: &models::CreateProgramRequest) -> Result<serde_json::Value> {
        self.client
            .request_json(Request {
                method: Method::POST,
                path: "/api/v1/programs".to_string(),
                query: NO_QUERY,
                body: Some(body),
                headers: Vec::new(),
                idempotent: true,
            })
            .await
    }

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

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