Skip to main content

uarp_sdk/generated/api/
integrations.rs

1// Code generated by @uarp/codegen from spec/openapi.json. DO NOT EDIT.
2//!
3//! OAuth integrations and connector 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/// Query and header parameters for `oauthCallback`.
17#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
18pub struct OauthCallbackParams {
19    pub code: String,
20    pub state: String,
21}
22
23/// OAuth integrations and connector management
24#[derive(Debug, Clone)]
25pub struct IntegrationsApi {
26    pub(crate) client: Client,
27}
28
29impl Client {
30    /// OAuth integrations and connector management
31    pub fn integrations(&self) -> IntegrationsApi {
32        IntegrationsApi { client: self.clone() }
33    }
34}
35
36impl IntegrationsApi {
37    /// Complete OAuth after callback (exchange code for tokens, create connection)
38    ///
39    /// `POST /api/v1/integrations/{provider}/oauth/complete`
40    ///
41    /// Required scopes: `agents:write`.
42    pub async fn complete_o_auth(&self, provider: &models::StartOAuthProvider, body: &models::OAuthCompleteRequest) -> Result<models::AgentIntegration> {
43        self.client
44            .request_json(Request {
45                method: Method::POST,
46                path: format!("/api/v1/integrations/{}/oauth/complete", encode_path(&provider.to_string())),
47                query: NO_QUERY,
48                body: Some(body),
49                headers: Vec::new(),
50                idempotent: true,
51            })
52            .await
53    }
54
55    /// Create integration
56    ///
57    /// `POST /api/v1/integrations`
58    ///
59    /// Required scopes: `agents:write`.
60    pub async fn create(&self, body: &models::CreateIntegrationRequest) -> Result<models::Integration> {
61        self.client
62            .request_json(Request {
63                method: Method::POST,
64                path: "/api/v1/integrations".to_string(),
65                query: NO_QUERY,
66                body: Some(body),
67                headers: Vec::new(),
68                idempotent: true,
69            })
70            .await
71    }
72
73    /// Delete integration
74    ///
75    /// `DELETE /api/v1/integrations/{id}`
76    ///
77    /// Required scopes: `agents:write`.
78    pub async fn delete(&self, id: &str) -> Result<models::DeleteIntegrationResponse> {
79        self.client
80            .request_json(Request {
81                method: Method::DELETE,
82                path: format!("/api/v1/integrations/{}", encode_path(id)),
83                query: NO_QUERY,
84                body: NO_BODY,
85                headers: Vec::new(),
86                idempotent: true,
87            })
88            .await
89    }
90
91    /// Remove an integration from an agent
92    ///
93    /// `DELETE /api/v1/agents/{agentId}/integrations/{integrationId}`
94    ///
95    /// Required scopes: `agents:write`.
96    pub async fn delete_agent_integration(&self, agent_id: &str, integration_id: &str) -> Result<serde_json::Value> {
97        self.client
98            .request_json(Request {
99                method: Method::DELETE,
100                path: format!("/api/v1/agents/{}/integrations/{}", encode_path(agent_id), encode_path(integration_id)),
101                query: NO_QUERY,
102                body: NO_BODY,
103                headers: Vec::new(),
104                idempotent: true,
105            })
106            .await
107    }
108
109    /// List tenant integrations
110    ///
111    /// `GET /api/v1/integrations`
112    ///
113    /// Required scopes: `agents:read`.
114    pub async fn list(&self) -> Result<models::ListIntegrationsResponse> {
115        self.client
116            .request_json(Request {
117                method: Method::GET,
118                path: "/api/v1/integrations".to_string(),
119                query: NO_QUERY,
120                body: NO_BODY,
121                headers: Vec::new(),
122                idempotent: false,
123            })
124            .await
125    }
126
127    /// List integrations for an agent
128    ///
129    /// `GET /api/v1/agents/{agentId}/integrations`
130    ///
131    /// Required scopes: `agents:read`.
132    pub async fn list_agent_integrations(&self, agent_id: &str) -> Result<models::ListAgentIntegrationsResponse> {
133        self.client
134            .request_json(Request {
135                method: Method::GET,
136                path: format!("/api/v1/agents/{}/integrations", encode_path(agent_id)),
137                query: NO_QUERY,
138                body: NO_BODY,
139                headers: Vec::new(),
140                idempotent: false,
141            })
142            .await
143    }
144
145    /// List available integration types (connectors)
146    ///
147    /// `GET /api/v1/integrations/catalog`
148    ///
149    /// Required scopes: `agents:read`.
150    pub async fn list_integrations_catalog(&self) -> Result<models::ListIntegrationsCatalogResponse> {
151        self.client
152            .request_json(Request {
153                method: Method::GET,
154                path: "/api/v1/integrations/catalog".to_string(),
155                query: NO_QUERY,
156                body: NO_BODY,
157                headers: Vec::new(),
158                idempotent: false,
159            })
160            .await
161    }
162
163    /// OAuth callback (redirect from provider); returns HTML that posts to complete
164    ///
165    /// `GET /api/v1/integrations/{provider}/oauth/callback`
166    ///
167    /// Required scopes: `agents:read`.
168    pub async fn oauth_callback(&self, provider: &models::StartOAuthProvider, params: &OauthCallbackParams) -> Result<serde_json::Value> {
169        self.client
170            .request_json(Request {
171                method: Method::GET,
172                path: format!("/api/v1/integrations/{}/oauth/callback", encode_path(&provider.to_string())),
173                query: Some(params),
174                body: NO_BODY,
175                headers: Vec::new(),
176                idempotent: false,
177            })
178            .await
179    }
180
181    /// Replace the set of integrations assigned to an agent
182    ///
183    /// The write operation this path actually has. Integrations are CREATED tenant-wide (`POST
184    /// /api/v1/integrations`) and then ASSIGNED here; the assignment is a replace, so ids omitted
185    /// from the array are unassigned.
186    ///
187    /// This document declared `POST` on this path until 2026-08-30, and the route answers that with
188    /// **405** — it was removed in the assignment refactor and its handler exists only to name the
189    /// replacement. A declared operation the server refuses is worse than an undeclared one: a
190    /// generated client has the method, calls it, and reads the failure as a fault in its own
191    /// request.
192    ///
193    /// Owner/admin only: assignment is a tenant-policy decision, not a developer-level config
194    /// change. Each assigned and unassigned id is audit-logged.
195    ///
196    /// `PUT /api/v1/agents/{agentId}/integrations`
197    ///
198    /// Required scopes: `agents:write`.
199    pub async fn set_agent_integrations(&self, agent_id: &str, body: &models::SetAgentIntegrationsRequest) -> Result<models::SetAgentIntegrationsResponse> {
200        self.client
201            .request_json(Request {
202                method: Method::PUT,
203                path: format!("/api/v1/agents/{}/integrations", encode_path(agent_id)),
204                query: NO_QUERY,
205                body: Some(body),
206                headers: Vec::new(),
207                idempotent: true,
208            })
209            .await
210    }
211
212    /// Start OAuth flow for an integration provider
213    ///
214    /// `POST /api/v1/integrations/{provider}/oauth/start`
215    ///
216    /// Required scopes: `agents:write`.
217    pub async fn start_o_auth(&self, provider: &models::StartOAuthProvider, body: &models::StartOAuthRequest) -> Result<models::OAuthStartResponse> {
218        self.client
219            .request_json(Request {
220                method: Method::POST,
221                path: format!("/api/v1/integrations/{}/oauth/start", encode_path(&provider.to_string())),
222                query: NO_QUERY,
223                body: Some(body),
224                headers: Vec::new(),
225                idempotent: true,
226            })
227            .await
228    }
229
230    /// Test connectivity for an agent integration
231    ///
232    /// `POST /api/v1/agents/{agentId}/integrations/{integrationId}/test`
233    ///
234    /// Required scopes: `agents:write`.
235    pub async fn test_agent_integration(&self, agent_id: &str, integration_id: &str) -> Result<models::TestAgentIntegrationResponse> {
236        self.client
237            .request_json(Request {
238                method: Method::POST,
239                path: format!("/api/v1/agents/{}/integrations/{}/test", encode_path(agent_id), encode_path(integration_id)),
240                query: NO_QUERY,
241                body: NO_BODY,
242                headers: Vec::new(),
243                idempotent: true,
244            })
245            .await
246    }
247
248    /// Test integration
249    ///
250    /// `POST /api/v1/integrations/{id}/test`
251    ///
252    /// Required scopes: `agents:write`.
253    pub async fn test_integration(&self, id: &str) -> Result<models::TestIntegrationResponse> {
254        self.client
255            .request_json(Request {
256                method: Method::POST,
257                path: format!("/api/v1/integrations/{}/test", encode_path(id)),
258                query: NO_QUERY,
259                body: NO_BODY,
260                headers: Vec::new(),
261                idempotent: true,
262            })
263            .await
264    }
265
266    /// Update integration
267    ///
268    /// `PATCH /api/v1/integrations/{id}`
269    ///
270    /// Required scopes: `agents:write`.
271    pub async fn update(&self, id: &str, body: &models::UpdateIntegrationRequest) -> Result<models::Integration> {
272        self.client
273            .request_json(Request {
274                method: Method::PATCH,
275                path: format!("/api/v1/integrations/{}", encode_path(id)),
276                query: NO_QUERY,
277                body: Some(body),
278                headers: Vec::new(),
279                idempotent: true,
280            })
281            .await
282    }
283
284    /// Update an agent integration (e.g. name, config)
285    ///
286    /// `PATCH /api/v1/agents/{agentId}/integrations/{integrationId}`
287    ///
288    /// Required scopes: `agents:write`.
289    pub async fn update_agent_integration(&self, agent_id: &str, integration_id: &str, body: &models::UpdateAgentIntegrationRequest) -> Result<models::AgentIntegration> {
290        self.client
291            .request_json(Request {
292                method: Method::PATCH,
293                path: format!("/api/v1/agents/{}/integrations/{}", encode_path(agent_id), encode_path(integration_id)),
294                query: NO_QUERY,
295                body: Some(body),
296                headers: Vec::new(),
297                idempotent: true,
298            })
299            .await
300    }
301}