Skip to main content

uarp_sdk/generated/api/
playground.rs

1// Code generated by @uarp/codegen from spec/openapi.json. DO NOT EDIT.
2//!
3//! Visual builder and agent playground
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/// Visual builder and agent playground
17#[derive(Debug, Clone)]
18pub struct PlaygroundApi {
19    pub(crate) client: Client,
20}
21
22impl Client {
23    /// Visual builder and agent playground
24    pub fn playground(&self) -> PlaygroundApi {
25        PlaygroundApi { client: self.clone() }
26    }
27}
28
29impl PlaygroundApi {
30    /// Load agent canvas state for visual builder
31    ///
32    /// `GET /api/v1/playground/agents/{agentId}`
33    pub async fn get_playground_canvas(&self, agent_id: &str) -> Result<models::PlaygroundAgentState> {
34        self.client
35            .request_json(Request {
36                method: Method::GET,
37                path: format!("/api/v1/playground/agents/{}", encode_path(agent_id)),
38                query: NO_QUERY,
39                body: NO_BODY,
40                headers: Vec::new(),
41                idempotent: false,
42            })
43            .await
44    }
45
46    /// List starter templates for visual builder
47    ///
48    /// `GET /api/v1/playground/templates`
49    pub async fn list_playground_templates(&self) -> Result<models::ListPlaygroundTemplatesResponse> {
50        self.client
51            .request_json(Request {
52                method: Method::GET,
53                path: "/api/v1/playground/templates".to_string(),
54                query: NO_QUERY,
55                body: NO_BODY,
56                headers: Vec::new(),
57                idempotent: false,
58            })
59            .await
60    }
61
62    /// Execute agent in playground
63    ///
64    /// `POST /api/v1/playground/agents/{agentId}/run`
65    ///
66    /// Required scopes: `runs:create`.
67    pub async fn run(&self, agent_id: &str, body: &serde_json::Map<String, serde_json::Value>) -> Result<models::Run> {
68        self.client
69            .request_json(Request {
70                method: Method::POST,
71                path: format!("/api/v1/playground/agents/{}/run", encode_path(agent_id)),
72                query: NO_QUERY,
73                body: Some(body),
74                headers: Vec::new(),
75                idempotent: true,
76            })
77            .await
78    }
79
80    /// Save agent canvas state
81    ///
82    /// `PUT /api/v1/playground/agents/{agentId}`
83    pub async fn save_playground_canvas(&self, agent_id: &str, body: &serde_json::Map<String, serde_json::Value>) -> Result<models::PlaygroundAgentState> {
84        self.client
85            .request_json(Request {
86                method: Method::PUT,
87                path: format!("/api/v1/playground/agents/{}", encode_path(agent_id)),
88                query: NO_QUERY,
89                body: Some(body),
90                headers: Vec::new(),
91                idempotent: true,
92            })
93            .await
94    }
95}