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 CallAiSessionToolError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CompleteAiError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetAiArtifactShareStatusError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetAiSessionShareStatusError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetSharedAiArtifactError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetSharedAiSessionError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ListAiSessionBackupsError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ListAiUsageError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum PullAiSessionBackupsError {
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum PushAiSessionBackupsError {
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum RecordAiUsageError {
92 UnknownValue(serde_json::Value),
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum SetAiSessionSharePublicError {
99 UnknownValue(serde_json::Value),
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum ShareAiArtifactError {
106 UnknownValue(serde_json::Value),
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum ShareAiSessionError {
113 UnknownValue(serde_json::Value),
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum UnshareAiArtifactError {
120 UnknownValue(serde_json::Value),
121}
122
123#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum UnshareAiSessionError {
127 UnknownValue(serde_json::Value),
128}
129
130
131pub 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>> {
133 let local_var_configuration = configuration;
134
135 let local_var_client = &local_var_configuration.client;
136
137 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));
138 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
139
140 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
141 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
142 }
143 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
144 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
145 };
146 local_var_req_builder = local_var_req_builder.json(&call_ai_session_tool_request);
147
148 let local_var_req = local_var_req_builder.build()?;
149 let local_var_resp = local_var_client.execute(local_var_req).await?;
150
151 let local_var_status = local_var_resp.status();
152 let local_var_content = local_var_resp.text().await?;
153
154 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
155 crate::from_str_patched(&local_var_content).map_err(Error::from)
156 } else {
157 let local_var_entity: Option<CallAiSessionToolError> = crate::from_str_patched(&local_var_content).ok();
158 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
159 Err(Error::ResponseError(local_var_error))
160 }
161}
162
163pub async fn complete_ai(configuration: &configuration::Configuration, workspace: &str, complete_ai_request: models::CompleteAiRequest) -> Result<models::CompleteAi200Response, Error<CompleteAiError>> {
165 let local_var_configuration = configuration;
166
167 let local_var_client = &local_var_configuration.client;
168
169 let local_var_uri_str = format!("{}/w/{workspace}/ai/complete", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
170 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
171
172 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
173 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
174 }
175 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
176 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
177 };
178 local_var_req_builder = local_var_req_builder.json(&complete_ai_request);
179
180 let local_var_req = local_var_req_builder.build()?;
181 let local_var_resp = local_var_client.execute(local_var_req).await?;
182
183 let local_var_status = local_var_resp.status();
184 let local_var_content = local_var_resp.text().await?;
185
186 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
187 crate::from_str_patched(&local_var_content).map_err(Error::from)
188 } else {
189 let local_var_entity: Option<CompleteAiError> = crate::from_str_patched(&local_var_content).ok();
190 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
191 Err(Error::ResponseError(local_var_error))
192 }
193}
194
195pub async fn get_ai_artifact_share_status(configuration: &configuration::Configuration, workspace: &str, artifact_id: &str) -> Result<models::GetAiArtifactShareStatus200Response, Error<GetAiArtifactShareStatusError>> {
196 let local_var_configuration = configuration;
197
198 let local_var_client = &local_var_configuration.client;
199
200 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_artifacts/status", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
201 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
202
203 local_var_req_builder = local_var_req_builder.query(&[("artifact_id", &artifact_id.to_string())]);
204 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
205 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
206 }
207 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
208 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
209 };
210
211 let local_var_req = local_var_req_builder.build()?;
212 let local_var_resp = local_var_client.execute(local_var_req).await?;
213
214 let local_var_status = local_var_resp.status();
215 let local_var_content = local_var_resp.text().await?;
216
217 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
218 crate::from_str_patched(&local_var_content).map_err(Error::from)
219 } else {
220 let local_var_entity: Option<GetAiArtifactShareStatusError> = crate::from_str_patched(&local_var_content).ok();
221 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
222 Err(Error::ResponseError(local_var_error))
223 }
224}
225
226pub async fn get_ai_session_share_status(configuration: &configuration::Configuration, workspace: &str, session_id: &str) -> Result<models::GetAiSessionShareStatus200Response, Error<GetAiSessionShareStatusError>> {
227 let local_var_configuration = configuration;
228
229 let local_var_client = &local_var_configuration.client;
230
231 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_sessions/status", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
232 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
233
234 local_var_req_builder = local_var_req_builder.query(&[("session_id", &session_id.to_string())]);
235 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
236 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
237 }
238 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
239 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
240 };
241
242 let local_var_req = local_var_req_builder.build()?;
243 let local_var_resp = local_var_client.execute(local_var_req).await?;
244
245 let local_var_status = local_var_resp.status();
246 let local_var_content = local_var_resp.text().await?;
247
248 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
249 crate::from_str_patched(&local_var_content).map_err(Error::from)
250 } else {
251 let local_var_entity: Option<GetAiSessionShareStatusError> = crate::from_str_patched(&local_var_content).ok();
252 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
253 Err(Error::ResponseError(local_var_error))
254 }
255}
256
257pub async fn get_shared_ai_artifact(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::GetSharedAiArtifact200Response, Error<GetSharedAiArtifactError>> {
258 let local_var_configuration = configuration;
259
260 let local_var_client = &local_var_configuration.client;
261
262 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));
263 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
264
265 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
266 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
267 }
268 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
269 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
270 };
271
272 let local_var_req = local_var_req_builder.build()?;
273 let local_var_resp = local_var_client.execute(local_var_req).await?;
274
275 let local_var_status = local_var_resp.status();
276 let local_var_content = local_var_resp.text().await?;
277
278 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
279 crate::from_str_patched(&local_var_content).map_err(Error::from)
280 } else {
281 let local_var_entity: Option<GetSharedAiArtifactError> = crate::from_str_patched(&local_var_content).ok();
282 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
283 Err(Error::ResponseError(local_var_error))
284 }
285}
286
287pub async fn get_shared_ai_session(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::GetSharedAiSession200Response, Error<GetSharedAiSessionError>> {
289 let local_var_configuration = configuration;
290
291 let local_var_client = &local_var_configuration.client;
292
293 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));
294 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
295
296 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
297 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
298 }
299 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
300 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
301 };
302
303 let local_var_req = local_var_req_builder.build()?;
304 let local_var_resp = local_var_client.execute(local_var_req).await?;
305
306 let local_var_status = local_var_resp.status();
307 let local_var_content = local_var_resp.text().await?;
308
309 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
310 crate::from_str_patched(&local_var_content).map_err(Error::from)
311 } else {
312 let local_var_entity: Option<GetSharedAiSessionError> = crate::from_str_patched(&local_var_content).ok();
313 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
314 Err(Error::ResponseError(local_var_error))
315 }
316}
317
318pub async fn list_ai_session_backups(configuration: &configuration::Configuration, workspace: &str) -> Result<models::ListAiSessionBackups200Response, Error<ListAiSessionBackupsError>> {
319 let local_var_configuration = configuration;
320
321 let local_var_client = &local_var_configuration.client;
322
323 let local_var_uri_str = format!("{}/w/{workspace}/ai/sessions/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
324 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
325
326 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
327 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
328 }
329 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
330 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
331 };
332
333 let local_var_req = local_var_req_builder.build()?;
334 let local_var_resp = local_var_client.execute(local_var_req).await?;
335
336 let local_var_status = local_var_resp.status();
337 let local_var_content = local_var_resp.text().await?;
338
339 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
340 crate::from_str_patched(&local_var_content).map_err(Error::from)
341 } else {
342 let local_var_entity: Option<ListAiSessionBackupsError> = crate::from_str_patched(&local_var_content).ok();
343 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
344 Err(Error::ResponseError(local_var_error))
345 }
346}
347
348pub 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>> {
349 let local_var_configuration = configuration;
350
351 let local_var_client = &local_var_configuration.client;
352
353 let local_var_uri_str = format!("{}/w/{workspace}/ai/usage", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
354 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
355
356 if let Some(ref local_var_str) = days {
357 local_var_req_builder = local_var_req_builder.query(&[("days", &local_var_str.to_string())]);
358 }
359 if let Some(ref local_var_str) = group_by {
360 local_var_req_builder = local_var_req_builder.query(&[("group_by", &local_var_str.to_string())]);
361 }
362 if let Some(ref local_var_str) = scope {
363 local_var_req_builder = local_var_req_builder.query(&[("scope", &local_var_str.to_string())]);
364 }
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<ListAiUsageError> = 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 pull_ai_session_backups(configuration: &configuration::Configuration, workspace: &str, pull_ai_session_backups_request: models::PullAiSessionBackupsRequest) -> Result<models::PullAiSessionBackups200Response, Error<PullAiSessionBackupsError>> {
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/sessions/pull", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
393 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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 local_var_req_builder = local_var_req_builder.json(&pull_ai_session_backups_request);
402
403 let local_var_req = local_var_req_builder.build()?;
404 let local_var_resp = local_var_client.execute(local_var_req).await?;
405
406 let local_var_status = local_var_resp.status();
407 let local_var_content = local_var_resp.text().await?;
408
409 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
410 crate::from_str_patched(&local_var_content).map_err(Error::from)
411 } else {
412 let local_var_entity: Option<PullAiSessionBackupsError> = crate::from_str_patched(&local_var_content).ok();
413 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
414 Err(Error::ResponseError(local_var_error))
415 }
416}
417
418pub async fn push_ai_session_backups(configuration: &configuration::Configuration, workspace: &str, push_ai_session_backups_request: models::PushAiSessionBackupsRequest) -> Result<models::PushAiSessionBackups200Response, Error<PushAiSessionBackupsError>> {
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/sessions/push", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
424 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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 local_var_req_builder = local_var_req_builder.json(&push_ai_session_backups_request);
433
434 let local_var_req = local_var_req_builder.build()?;
435 let local_var_resp = local_var_client.execute(local_var_req).await?;
436
437 let local_var_status = local_var_resp.status();
438 let local_var_content = local_var_resp.text().await?;
439
440 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
441 crate::from_str_patched(&local_var_content).map_err(Error::from)
442 } else {
443 let local_var_entity: Option<PushAiSessionBackupsError> = crate::from_str_patched(&local_var_content).ok();
444 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
445 Err(Error::ResponseError(local_var_error))
446 }
447}
448
449pub async fn record_ai_usage(configuration: &configuration::Configuration, workspace: &str, record_ai_usage_request: models::RecordAiUsageRequest) -> Result<(), Error<RecordAiUsageError>> {
450 let local_var_configuration = configuration;
451
452 let local_var_client = &local_var_configuration.client;
453
454 let local_var_uri_str = format!("{}/w/{workspace}/ai/usage", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
455 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
456
457 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
458 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
459 }
460 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
461 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
462 };
463 local_var_req_builder = local_var_req_builder.json(&record_ai_usage_request);
464
465 let local_var_req = local_var_req_builder.build()?;
466 let local_var_resp = local_var_client.execute(local_var_req).await?;
467
468 let local_var_status = local_var_resp.status();
469 let local_var_content = local_var_resp.text().await?;
470
471 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
472 Ok(())
473 } else {
474 let local_var_entity: Option<RecordAiUsageError> = crate::from_str_patched(&local_var_content).ok();
475 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
476 Err(Error::ResponseError(local_var_error))
477 }
478}
479
480pub 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>> {
481 let local_var_configuration = configuration;
482
483 let local_var_client = &local_var_configuration.client;
484
485 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));
486 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
487
488 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
489 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
490 }
491 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
492 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
493 };
494 local_var_req_builder = local_var_req_builder.json(&set_ai_session_share_public_request);
495
496 let local_var_req = local_var_req_builder.build()?;
497 let local_var_resp = local_var_client.execute(local_var_req).await?;
498
499 let local_var_status = local_var_resp.status();
500 let local_var_content = local_var_resp.text().await?;
501
502 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
503 crate::from_str_patched(&local_var_content).map_err(Error::from)
504 } else {
505 let local_var_entity: Option<SetAiSessionSharePublicError> = crate::from_str_patched(&local_var_content).ok();
506 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
507 Err(Error::ResponseError(local_var_error))
508 }
509}
510
511pub async fn share_ai_artifact(configuration: &configuration::Configuration, workspace: &str, share_ai_artifact_request: models::ShareAiArtifactRequest) -> Result<models::SharedAiArtifactInfo, Error<ShareAiArtifactError>> {
513 let local_var_configuration = configuration;
514
515 let local_var_client = &local_var_configuration.client;
516
517 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_artifacts/share", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
518 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
519
520 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
521 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
522 }
523 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
524 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
525 };
526 local_var_req_builder = local_var_req_builder.json(&share_ai_artifact_request);
527
528 let local_var_req = local_var_req_builder.build()?;
529 let local_var_resp = local_var_client.execute(local_var_req).await?;
530
531 let local_var_status = local_var_resp.status();
532 let local_var_content = local_var_resp.text().await?;
533
534 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
535 crate::from_str_patched(&local_var_content).map_err(Error::from)
536 } else {
537 let local_var_entity: Option<ShareAiArtifactError> = crate::from_str_patched(&local_var_content).ok();
538 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
539 Err(Error::ResponseError(local_var_error))
540 }
541}
542
543pub async fn share_ai_session(configuration: &configuration::Configuration, workspace: &str, share_ai_session_request: models::ShareAiSessionRequest) -> Result<models::SharedAiSessionInfo, Error<ShareAiSessionError>> {
545 let local_var_configuration = configuration;
546
547 let local_var_client = &local_var_configuration.client;
548
549 let local_var_uri_str = format!("{}/w/{workspace}/ai/shared_sessions/share", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
550 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
551
552 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
553 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
554 }
555 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
556 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
557 };
558 local_var_req_builder = local_var_req_builder.json(&share_ai_session_request);
559
560 let local_var_req = local_var_req_builder.build()?;
561 let local_var_resp = local_var_client.execute(local_var_req).await?;
562
563 let local_var_status = local_var_resp.status();
564 let local_var_content = local_var_resp.text().await?;
565
566 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
567 crate::from_str_patched(&local_var_content).map_err(Error::from)
568 } else {
569 let local_var_entity: Option<ShareAiSessionError> = crate::from_str_patched(&local_var_content).ok();
570 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
571 Err(Error::ResponseError(local_var_error))
572 }
573}
574
575pub async fn unshare_ai_artifact(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<UnshareAiArtifactError>> {
576 let local_var_configuration = configuration;
577
578 let local_var_client = &local_var_configuration.client;
579
580 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));
581 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
582
583 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
584 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
585 }
586 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
587 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
588 };
589
590 let local_var_req = local_var_req_builder.build()?;
591 let local_var_resp = local_var_client.execute(local_var_req).await?;
592
593 let local_var_status = local_var_resp.status();
594 let local_var_content = local_var_resp.text().await?;
595
596 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
597 crate::from_str_patched(&local_var_content).map_err(Error::from)
598 } else {
599 let local_var_entity: Option<UnshareAiArtifactError> = crate::from_str_patched(&local_var_content).ok();
600 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
601 Err(Error::ResponseError(local_var_error))
602 }
603}
604
605pub async fn unshare_ai_session(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<UnshareAiSessionError>> {
606 let local_var_configuration = configuration;
607
608 let local_var_client = &local_var_configuration.client;
609
610 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));
611 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
612
613 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
614 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
615 }
616 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
617 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
618 };
619
620 let local_var_req = local_var_req_builder.build()?;
621 let local_var_resp = local_var_client.execute(local_var_req).await?;
622
623 let local_var_status = local_var_resp.status();
624 let local_var_content = local_var_resp.text().await?;
625
626 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
627 crate::from_str_patched(&local_var_content).map_err(Error::from)
628 } else {
629 let local_var_entity: Option<UnshareAiSessionError> = crate::from_str_patched(&local_var_content).ok();
630 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
631 Err(Error::ResponseError(local_var_error))
632 }
633}
634