Skip to main content

uarp_sdk/generated/api/
programs.rs

1// Code generated by @uarp/codegen from spec/openapi.json. DO NOT EDIT.
2//!
3//! Program (curriculum) management
4
5#![allow(unused_imports, clippy::too_many_arguments)]
6
7use reqwest::Method;
8use serde::{Deserialize, Serialize};
9
10use crate::client::{Client, Request, NO_BODY, NO_QUERY};
11use crate::error::Result;
12use crate::generated::models;
13use crate::multipart::{field_text, FilePart};
14use crate::util::encode_path;
15
16/// Program (curriculum) management
17#[derive(Debug, Clone)]
18pub struct ProgramsApi {
19    pub(crate) client: Client,
20}
21
22impl Client {
23    /// Program (curriculum) management
24    pub fn programs(&self) -> ProgramsApi {
25        ProgramsApi { client: self.clone() }
26    }
27}
28
29impl ProgramsApi {
30    /// Apply program to session (create todos)
31    ///
32    /// Materialises the program into a session as todos. `session_id` and `start_date` are required
33    /// and both must resolve — an unknown program, session or overriding `agent_id` is 404, an
34    /// unparseable `start_date` is 422. One todo is created per step, due at 09:00 on `start_date`
35    /// plus the step's `suggested_due_offset_days` (falling back to the step's index in days),
36    /// assigned to `agent_id` or the program's default agent; each todo whose due time is still in
37    /// the future also gets a `todo_schedule` row so the scheduler fires it. Not idempotent —
38    /// applying the same program twice creates two full sets of todos. 201 with the created todos.
39    /// Requires the `sessions` write permission and the `sessions:write` scope.
40    ///
41    /// `POST /api/v1/programs/{programId}/apply`
42    ///
43    /// Required scopes: `sessions:write`.
44    pub async fn apply_program(&self, program_id: &str, body: &models::ApplyProgramRequest) -> Result<models::ApplyProgramResponse> {
45        self.client
46            .request_json(Request {
47                method: Method::POST,
48                path: format!("/api/v1/programs/{}/apply", encode_path(program_id)),
49                query: NO_QUERY,
50                body: Some(body),
51                headers: Vec::new(),
52                idempotent: true,
53            })
54            .await
55    }
56
57    /// Create a program (curriculum)
58    ///
59    /// Creates a program: an ordered list of steps that `POST /programs/{programId}/apply` later
60    /// turns into session todos. `name`, `agent_id` and at least one step are required (422
61    /// otherwise); each step is given a server-minted `step_id` and an `order_index` defaulting to
62    /// its position in the array. The `agent_id` is stored as the program's default assignee and is
63    /// not checked for existence here. Returns the stored program, 201. Requires the `agents` write
64    /// permission and the `agents:write` scope.
65    ///
66    /// `POST /api/v1/programs`
67    ///
68    /// Required scopes: `agents:write`.
69    pub async fn create(&self, body: &models::CreateProgramRequest) -> Result<models::Program> {
70        self.client
71            .request_json(Request {
72                method: Method::POST,
73                path: "/api/v1/programs".to_string(),
74                query: NO_QUERY,
75                body: Some(body),
76                headers: Vec::new(),
77                idempotent: true,
78            })
79            .await
80    }
81
82    /// Get program
83    ///
84    /// Returns one program with its steps. 404 when the tenant has no such program. Requires the
85    /// `agents` read permission and the `agents:read` scope.
86    ///
87    /// `GET /api/v1/programs/{programId}`
88    ///
89    /// Required scopes: `agents:read`.
90    pub async fn get(&self, program_id: &str) -> Result<models::Program> {
91        self.client
92            .request_json(Request {
93                method: Method::GET,
94                path: format!("/api/v1/programs/{}", encode_path(program_id)),
95                query: NO_QUERY,
96                body: NO_BODY,
97                headers: Vec::new(),
98                idempotent: false,
99            })
100            .await
101    }
102
103    /// List programs
104    ///
105    /// Lists the tenant's programs (curricula) sorted by `updated_at` ascending. There is no paging
106    /// and no filter — the whole prefix is read in one call. Requires the `agents` read permission
107    /// and the `agents:read` scope.
108    ///
109    /// `GET /api/v1/programs`
110    ///
111    /// Required scopes: `agents:read`.
112    pub async fn list(&self) -> Result<models::ListProgramsResponse> {
113        self.client
114            .request_json(Request {
115                method: Method::GET,
116                path: "/api/v1/programs".to_string(),
117                query: NO_QUERY,
118                body: NO_BODY,
119                headers: Vec::new(),
120                idempotent: false,
121            })
122            .await
123    }
124}