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