1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AiWebFetchError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum AiWebSearchError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum CallAiSessionToolError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum CompleteAiError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ForgetOpenedAiSessionError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetAiArtifactShareStatusError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetAiSessionShareStatusError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum GetSharedAiArtifactError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GetSharedAiSessionError {
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum ListAiSessionBackupsError {
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum ListAiUsageError {
92 UnknownValue(serde_json::Value),
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum ListSharedAiArtifactsError {
99 UnknownValue(serde_json::Value),
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum ListSharedAiSessionsError {
106 UnknownValue(serde_json::Value),
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum PullAiSessionBackupsError {
113 UnknownValue(serde_json::Value),
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum PushAiSessionBackupsError {
120 UnknownValue(serde_json::Value),
121}
122
123#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum RecordAiUsageError {
127 UnknownValue(serde_json::Value),
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum SetAiSessionSharePublicError {
134 UnknownValue(serde_json::Value),
135}
136
137#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum ShareAiArtifactError {
141 UnknownValue(serde_json::Value),
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum ShareAiSessionError {
148 UnknownValue(serde_json::Value),
149}
150
151#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum UnshareAiArtifactError {
155 UnknownValue(serde_json::Value),
156}
157
158#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum UnshareAiSessionError {
162 UnknownValue(serde_json::Value),
163}
164
165
166pub async fn ai_web_fetch(configuration: &configuration::Configuration, workspace: &str, ai_web_fetch_request: models::AiWebFetchRequest) -> Result<models::AiWebFetch200Response, Error<AiWebFetchError>> {
168 let local_var_configuration = configuration;
169
170 let local_var_client = &local_var_configuration.client;
171
172 let local_var_uri_str = format!("{}/w/{workspace}/ai/web_fetch", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
173 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
174
175 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
176 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
177 }
178 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
179 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
180 };
181 local_var_req_builder = local_var_req_builder.json(&ai_web_fetch_request);
182
183 let local_var_req = local_var_req_builder.build()?;
184 let local_var_resp = local_var_client.execute(local_var_req).await?;
185
186 let local_var_status = local_var_resp.status();
187 let local_var_content = local_var_resp.text().await?;
188
189 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
190 crate::from_str_patched(&local_var_content).map_err(Error::from)
191 } else {
192 let local_var_entity: Option<AiWebFetchError> = crate::from_str_patched(&local_var_content).ok();
193 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
194 Err(Error::ResponseError(local_var_error))
195 }
196}
197
198pub async fn ai_web_search(configuration: &configuration::Configuration, workspace: &str, ai_web_search_request: models::AiWebSearchRequest) -> Result<models::AiWebSearch200Response, Error<AiWebSearchError>> {
200 let local_var_configuration = configuration;
201
202 let local_var_client = &local_var_configuration.client;
203
204 let local_var_uri_str = format!("{}/w/{workspace}/ai/web_search", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
205 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
206
207 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
208 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
209 }
210 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
211 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
212 };
213 local_var_req_builder = local_var_req_builder.json(&ai_web_search_request);
214
215 let local_var_req = local_var_req_builder.build()?;
216 let local_var_resp = local_var_client.execute(local_var_req).await?;
217
218 let local_var_status = local_var_resp.status();
219 let local_var_content = local_var_resp.text().await?;
220
221 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
222 crate::from_str_patched(&local_var_content).map_err(Error::from)
223 } else {
224 let local_var_entity: Option<AiWebSearchError> = crate::from_str_patched(&local_var_content).ok();
225 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
226 Err(Error::ResponseError(local_var_error))
227 }
228}
229
230pub async fn call_ai_session_tool(configuration: &configuration::Configuration, workspace: &str, name: &str, call_ai_session_tool_request: models::CallAiSessionToolRequest) -> Result<models::CallAiSessionTool200Response, Error<CallAiSessionToolError>> {
232 let local_var_configuration = configuration;
233
234 let local_var_client = &local_var_configuration.client;
235
236 let local_var_uri_str = format!("{}/w/{workspace}/ai_session_tools/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
237 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
238
239 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
240 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
241 }
242 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
243 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
244 };
245 local_var_req_builder = local_var_req_builder.json(&call_ai_session_tool_request);
246
247 let local_var_req = local_var_req_builder.build()?;
248 let local_var_resp = local_var_client.execute(local_var_req).await?;
249
250 let local_var_status = local_var_resp.status();
251 let local_var_content = local_var_resp.text().await?;
252
253 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
254 crate::from_str_patched(&local_var_content).map_err(Error::from)
255 } else {
256 let local_var_entity: Option<CallAiSessionToolError> = crate::from_str_patched(&local_var_content).ok();
257 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
258 Err(Error::ResponseError(local_var_error))
259 }
260}
261
262pub async fn complete_ai(configuration: &configuration::Configuration, workspace: &str, complete_ai_request: models::CompleteAiRequest) -> Result<models::CompleteAi200Response, Error<CompleteAiError>> {
264 let local_var_configuration = configuration;
265
266 let local_var_client = &local_var_configuration.client;
267
268 let local_var_uri_str = format!("{}/w/{workspace}/ai/complete", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
269 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
270
271 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
272 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
273 }
274 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
275 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
276 };
277 local_var_req_builder = local_var_req_builder.json(&complete_ai_request);
278
279 let local_var_req = local_var_req_builder.build()?;
280 let local_var_resp = local_var_client.execute(local_var_req).await?;
281
282 let local_var_status = local_var_resp.status();
283 let local_var_content = local_var_resp.text().await?;
284
285 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
286 crate::from_str_patched(&local_var_content).map_err(Error::from)
287 } else {
288 let local_var_entity: Option<CompleteAiError> = crate::from_str_patched(&local_var_content).ok();
289 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
290 Err(Error::ResponseError(local_var_error))
291 }
292}
293
294pub async fn forget_opened_ai_session(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<ForgetOpenedAiSessionError>> {
296 let local_var_configuration = configuration;
297
298 let local_var_client = &local_var_configuration.client;
299
300 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_sessions/opened/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
301 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
302
303 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
304 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
305 }
306 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
307 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
308 };
309
310 let local_var_req = local_var_req_builder.build()?;
311 let local_var_resp = local_var_client.execute(local_var_req).await?;
312
313 let local_var_status = local_var_resp.status();
314 let local_var_content = local_var_resp.text().await?;
315
316 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
317 crate::from_str_patched(&local_var_content).map_err(Error::from)
318 } else {
319 let local_var_entity: Option<ForgetOpenedAiSessionError> = crate::from_str_patched(&local_var_content).ok();
320 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
321 Err(Error::ResponseError(local_var_error))
322 }
323}
324
325pub async fn get_ai_artifact_share_status(configuration: &configuration::Configuration, workspace: &str, artifact_id: &str) -> Result<models::GetAiArtifactShareStatus200Response, Error<GetAiArtifactShareStatusError>> {
326 let local_var_configuration = configuration;
327
328 let local_var_client = &local_var_configuration.client;
329
330 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_artifacts/status", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
331 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
332
333 local_var_req_builder = local_var_req_builder.query(&[("artifact_id", &artifact_id.to_string())]);
334 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
335 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
336 }
337 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
338 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
339 };
340
341 let local_var_req = local_var_req_builder.build()?;
342 let local_var_resp = local_var_client.execute(local_var_req).await?;
343
344 let local_var_status = local_var_resp.status();
345 let local_var_content = local_var_resp.text().await?;
346
347 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
348 crate::from_str_patched(&local_var_content).map_err(Error::from)
349 } else {
350 let local_var_entity: Option<GetAiArtifactShareStatusError> = crate::from_str_patched(&local_var_content).ok();
351 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
352 Err(Error::ResponseError(local_var_error))
353 }
354}
355
356pub async fn get_ai_session_share_status(configuration: &configuration::Configuration, workspace: &str, session_id: &str) -> Result<models::GetAiSessionShareStatus200Response, Error<GetAiSessionShareStatusError>> {
357 let local_var_configuration = configuration;
358
359 let local_var_client = &local_var_configuration.client;
360
361 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_sessions/status", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
362 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
363
364 local_var_req_builder = local_var_req_builder.query(&[("session_id", &session_id.to_string())]);
365 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
366 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
367 }
368 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
369 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
370 };
371
372 let local_var_req = local_var_req_builder.build()?;
373 let local_var_resp = local_var_client.execute(local_var_req).await?;
374
375 let local_var_status = local_var_resp.status();
376 let local_var_content = local_var_resp.text().await?;
377
378 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
379 crate::from_str_patched(&local_var_content).map_err(Error::from)
380 } else {
381 let local_var_entity: Option<GetAiSessionShareStatusError> = crate::from_str_patched(&local_var_content).ok();
382 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
383 Err(Error::ResponseError(local_var_error))
384 }
385}
386
387pub async fn get_shared_ai_artifact(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::GetSharedAiArtifact200Response, Error<GetSharedAiArtifactError>> {
388 let local_var_configuration = configuration;
389
390 let local_var_client = &local_var_configuration.client;
391
392 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_artifacts/get/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
393 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
394
395 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
396 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
397 }
398 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
399 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
400 };
401
402 let local_var_req = local_var_req_builder.build()?;
403 let local_var_resp = local_var_client.execute(local_var_req).await?;
404
405 let local_var_status = local_var_resp.status();
406 let local_var_content = local_var_resp.text().await?;
407
408 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
409 crate::from_str_patched(&local_var_content).map_err(Error::from)
410 } else {
411 let local_var_entity: Option<GetSharedAiArtifactError> = crate::from_str_patched(&local_var_content).ok();
412 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
413 Err(Error::ResponseError(local_var_error))
414 }
415}
416
417pub async fn get_shared_ai_session(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::GetSharedAiSession200Response, Error<GetSharedAiSessionError>> {
419 let local_var_configuration = configuration;
420
421 let local_var_client = &local_var_configuration.client;
422
423 let local_var_uri_str = format!("{}/w/{workspace}/ai_u/shared_sessions/get/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
424 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
425
426 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
427 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
428 }
429 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
430 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
431 };
432
433 let local_var_req = local_var_req_builder.build()?;
434 let local_var_resp = local_var_client.execute(local_var_req).await?;
435
436 let local_var_status = local_var_resp.status();
437 let local_var_content = local_var_resp.text().await?;
438
439 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
440 crate::from_str_patched(&local_var_content).map_err(Error::from)
441 } else {
442 let local_var_entity: Option<GetSharedAiSessionError> = crate::from_str_patched(&local_var_content).ok();
443 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
444 Err(Error::ResponseError(local_var_error))
445 }
446}
447
448pub async fn list_ai_session_backups(configuration: &configuration::Configuration, workspace: &str) -> Result<models::ListAiSessionBackups200Response, Error<ListAiSessionBackupsError>> {
449 let local_var_configuration = configuration;
450
451 let local_var_client = &local_var_configuration.client;
452
453 let local_var_uri_str = format!("{}/w/{workspace}/ai/sessions/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
454 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
455
456 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
457 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
458 }
459 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
460 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
461 };
462
463 let local_var_req = local_var_req_builder.build()?;
464 let local_var_resp = local_var_client.execute(local_var_req).await?;
465
466 let local_var_status = local_var_resp.status();
467 let local_var_content = local_var_resp.text().await?;
468
469 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
470 crate::from_str_patched(&local_var_content).map_err(Error::from)
471 } else {
472 let local_var_entity: Option<ListAiSessionBackupsError> = crate::from_str_patched(&local_var_content).ok();
473 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
474 Err(Error::ResponseError(local_var_error))
475 }
476}
477
478pub async fn list_ai_usage(configuration: &configuration::Configuration, workspace: &str, days: Option<i32>, group_by: Option<&str>, scope: Option<&str>) -> Result<models::ListAiUsage200Response, Error<ListAiUsageError>> {
479 let local_var_configuration = configuration;
480
481 let local_var_client = &local_var_configuration.client;
482
483 let local_var_uri_str = format!("{}/w/{workspace}/ai/usage", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
484 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
485
486 if let Some(ref local_var_str) = days {
487 local_var_req_builder = local_var_req_builder.query(&[("days", &local_var_str.to_string())]);
488 }
489 if let Some(ref local_var_str) = group_by {
490 local_var_req_builder = local_var_req_builder.query(&[("group_by", &local_var_str.to_string())]);
491 }
492 if let Some(ref local_var_str) = scope {
493 local_var_req_builder = local_var_req_builder.query(&[("scope", &local_var_str.to_string())]);
494 }
495 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
496 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
497 }
498 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
499 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
500 };
501
502 let local_var_req = local_var_req_builder.build()?;
503 let local_var_resp = local_var_client.execute(local_var_req).await?;
504
505 let local_var_status = local_var_resp.status();
506 let local_var_content = local_var_resp.text().await?;
507
508 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
509 crate::from_str_patched(&local_var_content).map_err(Error::from)
510 } else {
511 let local_var_entity: Option<ListAiUsageError> = crate::from_str_patched(&local_var_content).ok();
512 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
513 Err(Error::ResponseError(local_var_error))
514 }
515}
516
517pub async fn list_shared_ai_artifacts(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::SharedAiArtifactInfo>, Error<ListSharedAiArtifactsError>> {
519 let local_var_configuration = configuration;
520
521 let local_var_client = &local_var_configuration.client;
522
523 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_artifacts/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
524 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
525
526 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
527 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
528 }
529 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
530 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
531 };
532
533 let local_var_req = local_var_req_builder.build()?;
534 let local_var_resp = local_var_client.execute(local_var_req).await?;
535
536 let local_var_status = local_var_resp.status();
537 let local_var_content = local_var_resp.text().await?;
538
539 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
540 crate::from_str_patched(&local_var_content).map_err(Error::from)
541 } else {
542 let local_var_entity: Option<ListSharedAiArtifactsError> = crate::from_str_patched(&local_var_content).ok();
543 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
544 Err(Error::ResponseError(local_var_error))
545 }
546}
547
548pub async fn list_shared_ai_sessions(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::ListSharedAiSessions200ResponseInner>, Error<ListSharedAiSessionsError>> {
550 let local_var_configuration = configuration;
551
552 let local_var_client = &local_var_configuration.client;
553
554 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_sessions/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
555 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
556
557 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
558 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
559 }
560 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
561 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
562 };
563
564 let local_var_req = local_var_req_builder.build()?;
565 let local_var_resp = local_var_client.execute(local_var_req).await?;
566
567 let local_var_status = local_var_resp.status();
568 let local_var_content = local_var_resp.text().await?;
569
570 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
571 crate::from_str_patched(&local_var_content).map_err(Error::from)
572 } else {
573 let local_var_entity: Option<ListSharedAiSessionsError> = crate::from_str_patched(&local_var_content).ok();
574 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
575 Err(Error::ResponseError(local_var_error))
576 }
577}
578
579pub async fn pull_ai_session_backups(configuration: &configuration::Configuration, workspace: &str, pull_ai_session_backups_request: models::PullAiSessionBackupsRequest) -> Result<models::PullAiSessionBackups200Response, Error<PullAiSessionBackupsError>> {
580 let local_var_configuration = configuration;
581
582 let local_var_client = &local_var_configuration.client;
583
584 let local_var_uri_str = format!("{}/w/{workspace}/ai/sessions/pull", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
585 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
586
587 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
588 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
589 }
590 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
591 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
592 };
593 local_var_req_builder = local_var_req_builder.json(&pull_ai_session_backups_request);
594
595 let local_var_req = local_var_req_builder.build()?;
596 let local_var_resp = local_var_client.execute(local_var_req).await?;
597
598 let local_var_status = local_var_resp.status();
599 let local_var_content = local_var_resp.text().await?;
600
601 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
602 crate::from_str_patched(&local_var_content).map_err(Error::from)
603 } else {
604 let local_var_entity: Option<PullAiSessionBackupsError> = crate::from_str_patched(&local_var_content).ok();
605 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
606 Err(Error::ResponseError(local_var_error))
607 }
608}
609
610pub async fn push_ai_session_backups(configuration: &configuration::Configuration, workspace: &str, push_ai_session_backups_request: models::PushAiSessionBackupsRequest) -> Result<models::PushAiSessionBackups200Response, Error<PushAiSessionBackupsError>> {
611 let local_var_configuration = configuration;
612
613 let local_var_client = &local_var_configuration.client;
614
615 let local_var_uri_str = format!("{}/w/{workspace}/ai/sessions/push", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
616 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
617
618 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
619 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
620 }
621 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
622 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
623 };
624 local_var_req_builder = local_var_req_builder.json(&push_ai_session_backups_request);
625
626 let local_var_req = local_var_req_builder.build()?;
627 let local_var_resp = local_var_client.execute(local_var_req).await?;
628
629 let local_var_status = local_var_resp.status();
630 let local_var_content = local_var_resp.text().await?;
631
632 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
633 crate::from_str_patched(&local_var_content).map_err(Error::from)
634 } else {
635 let local_var_entity: Option<PushAiSessionBackupsError> = crate::from_str_patched(&local_var_content).ok();
636 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
637 Err(Error::ResponseError(local_var_error))
638 }
639}
640
641pub async fn record_ai_usage(configuration: &configuration::Configuration, workspace: &str, record_ai_usage_request: models::RecordAiUsageRequest) -> Result<(), Error<RecordAiUsageError>> {
642 let local_var_configuration = configuration;
643
644 let local_var_client = &local_var_configuration.client;
645
646 let local_var_uri_str = format!("{}/w/{workspace}/ai/usage", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
647 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
648
649 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
650 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
651 }
652 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
653 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
654 };
655 local_var_req_builder = local_var_req_builder.json(&record_ai_usage_request);
656
657 let local_var_req = local_var_req_builder.build()?;
658 let local_var_resp = local_var_client.execute(local_var_req).await?;
659
660 let local_var_status = local_var_resp.status();
661 let local_var_content = local_var_resp.text().await?;
662
663 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
664 Ok(())
665 } else {
666 let local_var_entity: Option<RecordAiUsageError> = crate::from_str_patched(&local_var_content).ok();
667 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
668 Err(Error::ResponseError(local_var_error))
669 }
670}
671
672pub async fn set_ai_session_share_public(configuration: &configuration::Configuration, workspace: &str, id: &str, set_ai_session_share_public_request: models::SetAiSessionSharePublicRequest) -> Result<models::SharedAiSessionInfo, Error<SetAiSessionSharePublicError>> {
673 let local_var_configuration = configuration;
674
675 let local_var_client = &local_var_configuration.client;
676
677 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_sessions/set_public/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
678 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
679
680 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
681 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
682 }
683 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
684 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
685 };
686 local_var_req_builder = local_var_req_builder.json(&set_ai_session_share_public_request);
687
688 let local_var_req = local_var_req_builder.build()?;
689 let local_var_resp = local_var_client.execute(local_var_req).await?;
690
691 let local_var_status = local_var_resp.status();
692 let local_var_content = local_var_resp.text().await?;
693
694 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
695 crate::from_str_patched(&local_var_content).map_err(Error::from)
696 } else {
697 let local_var_entity: Option<SetAiSessionSharePublicError> = crate::from_str_patched(&local_var_content).ok();
698 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
699 Err(Error::ResponseError(local_var_error))
700 }
701}
702
703pub async fn share_ai_artifact(configuration: &configuration::Configuration, workspace: &str, share_ai_artifact_request: models::ShareAiArtifactRequest) -> Result<models::SharedAiArtifactInfo, Error<ShareAiArtifactError>> {
705 let local_var_configuration = configuration;
706
707 let local_var_client = &local_var_configuration.client;
708
709 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_artifacts/share", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
710 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
711
712 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
713 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
714 }
715 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
716 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
717 };
718 local_var_req_builder = local_var_req_builder.json(&share_ai_artifact_request);
719
720 let local_var_req = local_var_req_builder.build()?;
721 let local_var_resp = local_var_client.execute(local_var_req).await?;
722
723 let local_var_status = local_var_resp.status();
724 let local_var_content = local_var_resp.text().await?;
725
726 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
727 crate::from_str_patched(&local_var_content).map_err(Error::from)
728 } else {
729 let local_var_entity: Option<ShareAiArtifactError> = crate::from_str_patched(&local_var_content).ok();
730 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
731 Err(Error::ResponseError(local_var_error))
732 }
733}
734
735pub async fn share_ai_session(configuration: &configuration::Configuration, workspace: &str, share_ai_session_request: models::ShareAiSessionRequest) -> Result<models::SharedAiSessionInfo, Error<ShareAiSessionError>> {
737 let local_var_configuration = configuration;
738
739 let local_var_client = &local_var_configuration.client;
740
741 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_sessions/share", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
742 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
743
744 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
745 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
746 }
747 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
748 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
749 };
750 local_var_req_builder = local_var_req_builder.json(&share_ai_session_request);
751
752 let local_var_req = local_var_req_builder.build()?;
753 let local_var_resp = local_var_client.execute(local_var_req).await?;
754
755 let local_var_status = local_var_resp.status();
756 let local_var_content = local_var_resp.text().await?;
757
758 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
759 crate::from_str_patched(&local_var_content).map_err(Error::from)
760 } else {
761 let local_var_entity: Option<ShareAiSessionError> = crate::from_str_patched(&local_var_content).ok();
762 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
763 Err(Error::ResponseError(local_var_error))
764 }
765}
766
767pub async fn unshare_ai_artifact(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<UnshareAiArtifactError>> {
768 let local_var_configuration = configuration;
769
770 let local_var_client = &local_var_configuration.client;
771
772 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_artifacts/delete/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
773 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
774
775 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
776 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
777 }
778 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
779 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
780 };
781
782 let local_var_req = local_var_req_builder.build()?;
783 let local_var_resp = local_var_client.execute(local_var_req).await?;
784
785 let local_var_status = local_var_resp.status();
786 let local_var_content = local_var_resp.text().await?;
787
788 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
789 crate::from_str_patched(&local_var_content).map_err(Error::from)
790 } else {
791 let local_var_entity: Option<UnshareAiArtifactError> = crate::from_str_patched(&local_var_content).ok();
792 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
793 Err(Error::ResponseError(local_var_error))
794 }
795}
796
797pub async fn unshare_ai_session(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<UnshareAiSessionError>> {
798 let local_var_configuration = configuration;
799
800 let local_var_client = &local_var_configuration.client;
801
802 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_sessions/delete/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
803 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
804
805 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
806 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
807 }
808 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
809 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
810 };
811
812 let local_var_req = local_var_req_builder.build()?;
813 let local_var_resp = local_var_client.execute(local_var_req).await?;
814
815 let local_var_status = local_var_resp.status();
816 let local_var_content = local_var_resp.text().await?;
817
818 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
819 crate::from_str_patched(&local_var_content).map_err(Error::from)
820 } else {
821 let local_var_entity: Option<UnshareAiSessionError> = crate::from_str_patched(&local_var_content).ok();
822 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
823 Err(Error::ResponseError(local_var_error))
824 }
825}
826