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 CreateResourceError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CreateResourceTypeError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DeleteResourceError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum DeleteResourceTypeError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ExistsResourceError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ExistsResourceTypeError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum FileResourceTypeToFileExtMapError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum GetResourceError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GetResourceTypeError {
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum GetResourceValueError {
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum GetResourceValueInterpolatedError {
92 UnknownValue(serde_json::Value),
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum ListResourceError {
99 UnknownValue(serde_json::Value),
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum ListResourceNamesError {
106 UnknownValue(serde_json::Value),
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum ListResourceTypeError {
113 UnknownValue(serde_json::Value),
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum ListResourceTypeNamesError {
120 UnknownValue(serde_json::Value),
121}
122
123#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum ListSearchResourceError {
127 UnknownValue(serde_json::Value),
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum QueryResourceTypesError {
134 UnknownValue(serde_json::Value),
135}
136
137#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum UpdateResourceError {
141 UnknownValue(serde_json::Value),
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum UpdateResourceTypeError {
148 UnknownValue(serde_json::Value),
149}
150
151#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum UpdateResourceValueError {
155 UnknownValue(serde_json::Value),
156}
157
158
159pub async fn create_resource(configuration: &configuration::Configuration, workspace: &str, create_resource: models::CreateResource, update_if_exists: Option<bool>) -> Result<String, Error<CreateResourceError>> {
160 let local_var_configuration = configuration;
161
162 let local_var_client = &local_var_configuration.client;
163
164 let local_var_uri_str = format!("{}/w/{workspace}/resources/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
165 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
166
167 if let Some(ref local_var_str) = update_if_exists {
168 local_var_req_builder = local_var_req_builder.query(&[("update_if_exists", &local_var_str.to_string())]);
169 }
170 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
171 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
172 }
173 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
174 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
175 };
176 local_var_req_builder = local_var_req_builder.json(&create_resource);
177
178 let local_var_req = local_var_req_builder.build()?;
179 let local_var_resp = local_var_client.execute(local_var_req).await?;
180
181 let local_var_status = local_var_resp.status();
182 let local_var_content = local_var_resp.text().await?;
183
184 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
185 crate::from_str_patched(&local_var_content).map_err(Error::from)
186 } else {
187 let local_var_entity: Option<CreateResourceError> = crate::from_str_patched(&local_var_content).ok();
188 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
189 Err(Error::ResponseError(local_var_error))
190 }
191}
192
193pub async fn create_resource_type(configuration: &configuration::Configuration, workspace: &str, resource_type: models::ResourceType) -> Result<String, Error<CreateResourceTypeError>> {
194 let local_var_configuration = configuration;
195
196 let local_var_client = &local_var_configuration.client;
197
198 let local_var_uri_str = format!("{}/w/{workspace}/resources/type/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
199 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
200
201 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
202 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
203 }
204 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
205 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
206 };
207 local_var_req_builder = local_var_req_builder.json(&resource_type);
208
209 let local_var_req = local_var_req_builder.build()?;
210 let local_var_resp = local_var_client.execute(local_var_req).await?;
211
212 let local_var_status = local_var_resp.status();
213 let local_var_content = local_var_resp.text().await?;
214
215 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
216 crate::from_str_patched(&local_var_content).map_err(Error::from)
217 } else {
218 let local_var_entity: Option<CreateResourceTypeError> = crate::from_str_patched(&local_var_content).ok();
219 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
220 Err(Error::ResponseError(local_var_error))
221 }
222}
223
224pub async fn delete_resource(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteResourceError>> {
225 let local_var_configuration = configuration;
226
227 let local_var_client = &local_var_configuration.client;
228
229 let local_var_uri_str = format!("{}/w/{workspace}/resources/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
230 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
231
232 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
233 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
234 }
235 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
236 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
237 };
238
239 let local_var_req = local_var_req_builder.build()?;
240 let local_var_resp = local_var_client.execute(local_var_req).await?;
241
242 let local_var_status = local_var_resp.status();
243 let local_var_content = local_var_resp.text().await?;
244
245 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
246 crate::from_str_patched(&local_var_content).map_err(Error::from)
247 } else {
248 let local_var_entity: Option<DeleteResourceError> = crate::from_str_patched(&local_var_content).ok();
249 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
250 Err(Error::ResponseError(local_var_error))
251 }
252}
253
254pub async fn delete_resource_type(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteResourceTypeError>> {
255 let local_var_configuration = configuration;
256
257 let local_var_client = &local_var_configuration.client;
258
259 let local_var_uri_str = format!("{}/w/{workspace}/resources/type/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
260 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
261
262 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
263 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
264 }
265 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
266 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
267 };
268
269 let local_var_req = local_var_req_builder.build()?;
270 let local_var_resp = local_var_client.execute(local_var_req).await?;
271
272 let local_var_status = local_var_resp.status();
273 let local_var_content = local_var_resp.text().await?;
274
275 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
276 crate::from_str_patched(&local_var_content).map_err(Error::from)
277 } else {
278 let local_var_entity: Option<DeleteResourceTypeError> = crate::from_str_patched(&local_var_content).ok();
279 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
280 Err(Error::ResponseError(local_var_error))
281 }
282}
283
284pub async fn exists_resource(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsResourceError>> {
285 let local_var_configuration = configuration;
286
287 let local_var_client = &local_var_configuration.client;
288
289 let local_var_uri_str = format!("{}/w/{workspace}/resources/exists/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
290 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
291
292 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
293 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
294 }
295 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
296 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
297 };
298
299 let local_var_req = local_var_req_builder.build()?;
300 let local_var_resp = local_var_client.execute(local_var_req).await?;
301
302 let local_var_status = local_var_resp.status();
303 let local_var_content = local_var_resp.text().await?;
304
305 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
306 crate::from_str_patched(&local_var_content).map_err(Error::from)
307 } else {
308 let local_var_entity: Option<ExistsResourceError> = crate::from_str_patched(&local_var_content).ok();
309 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
310 Err(Error::ResponseError(local_var_error))
311 }
312}
313
314pub async fn exists_resource_type(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsResourceTypeError>> {
315 let local_var_configuration = configuration;
316
317 let local_var_client = &local_var_configuration.client;
318
319 let local_var_uri_str = format!("{}/w/{workspace}/resources/type/exists/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
320 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
321
322 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
323 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
324 }
325 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
326 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
327 };
328
329 let local_var_req = local_var_req_builder.build()?;
330 let local_var_resp = local_var_client.execute(local_var_req).await?;
331
332 let local_var_status = local_var_resp.status();
333 let local_var_content = local_var_resp.text().await?;
334
335 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
336 crate::from_str_patched(&local_var_content).map_err(Error::from)
337 } else {
338 let local_var_entity: Option<ExistsResourceTypeError> = crate::from_str_patched(&local_var_content).ok();
339 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
340 Err(Error::ResponseError(local_var_error))
341 }
342}
343
344pub async fn file_resource_type_to_file_ext_map(configuration: &configuration::Configuration, workspace: &str) -> Result<serde_json::Value, Error<FileResourceTypeToFileExtMapError>> {
345 let local_var_configuration = configuration;
346
347 let local_var_client = &local_var_configuration.client;
348
349 let local_var_uri_str = format!("{}/w/{workspace}/resources/file_resource_type_to_file_ext_map", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
350 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
351
352 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
353 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
354 }
355 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
356 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
357 };
358
359 let local_var_req = local_var_req_builder.build()?;
360 let local_var_resp = local_var_client.execute(local_var_req).await?;
361
362 let local_var_status = local_var_resp.status();
363 let local_var_content = local_var_resp.text().await?;
364
365 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
366 crate::from_str_patched(&local_var_content).map_err(Error::from)
367 } else {
368 let local_var_entity: Option<FileResourceTypeToFileExtMapError> = crate::from_str_patched(&local_var_content).ok();
369 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
370 Err(Error::ResponseError(local_var_error))
371 }
372}
373
374pub async fn get_resource(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::Resource, Error<GetResourceError>> {
375 let local_var_configuration = configuration;
376
377 let local_var_client = &local_var_configuration.client;
378
379 let local_var_uri_str = format!("{}/w/{workspace}/resources/get/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
380 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
381
382 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
383 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
384 }
385 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
386 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
387 };
388
389 let local_var_req = local_var_req_builder.build()?;
390 let local_var_resp = local_var_client.execute(local_var_req).await?;
391
392 let local_var_status = local_var_resp.status();
393 let local_var_content = local_var_resp.text().await?;
394
395 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
396 crate::from_str_patched(&local_var_content).map_err(Error::from)
397 } else {
398 let local_var_entity: Option<GetResourceError> = crate::from_str_patched(&local_var_content).ok();
399 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
400 Err(Error::ResponseError(local_var_error))
401 }
402}
403
404pub async fn get_resource_type(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::ResourceType, Error<GetResourceTypeError>> {
405 let local_var_configuration = configuration;
406
407 let local_var_client = &local_var_configuration.client;
408
409 let local_var_uri_str = format!("{}/w/{workspace}/resources/type/get/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
410 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
411
412 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
413 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
414 }
415 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
416 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
417 };
418
419 let local_var_req = local_var_req_builder.build()?;
420 let local_var_resp = local_var_client.execute(local_var_req).await?;
421
422 let local_var_status = local_var_resp.status();
423 let local_var_content = local_var_resp.text().await?;
424
425 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
426 crate::from_str_patched(&local_var_content).map_err(Error::from)
427 } else {
428 let local_var_entity: Option<GetResourceTypeError> = crate::from_str_patched(&local_var_content).ok();
429 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
430 Err(Error::ResponseError(local_var_error))
431 }
432}
433
434pub async fn get_resource_value(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<serde_json::Value, Error<GetResourceValueError>> {
435 let local_var_configuration = configuration;
436
437 let local_var_client = &local_var_configuration.client;
438
439 let local_var_uri_str = format!("{}/w/{workspace}/resources/get_value/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
440 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
441
442 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
443 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
444 }
445 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
446 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
447 };
448
449 let local_var_req = local_var_req_builder.build()?;
450 let local_var_resp = local_var_client.execute(local_var_req).await?;
451
452 let local_var_status = local_var_resp.status();
453 let local_var_content = local_var_resp.text().await?;
454
455 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
456 crate::from_str_patched(&local_var_content).map_err(Error::from)
457 } else {
458 let local_var_entity: Option<GetResourceValueError> = crate::from_str_patched(&local_var_content).ok();
459 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
460 Err(Error::ResponseError(local_var_error))
461 }
462}
463
464pub async fn get_resource_value_interpolated(configuration: &configuration::Configuration, workspace: &str, path: &str, job_id: Option<&str>) -> Result<serde_json::Value, Error<GetResourceValueInterpolatedError>> {
465 let local_var_configuration = configuration;
466
467 let local_var_client = &local_var_configuration.client;
468
469 let local_var_uri_str = format!("{}/w/{workspace}/resources/get_value_interpolated/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
470 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
471
472 if let Some(ref local_var_str) = job_id {
473 local_var_req_builder = local_var_req_builder.query(&[("job_id", &local_var_str.to_string())]);
474 }
475 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
476 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
477 }
478 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
479 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
480 };
481
482 let local_var_req = local_var_req_builder.build()?;
483 let local_var_resp = local_var_client.execute(local_var_req).await?;
484
485 let local_var_status = local_var_resp.status();
486 let local_var_content = local_var_resp.text().await?;
487
488 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
489 crate::from_str_patched(&local_var_content).map_err(Error::from)
490 } else {
491 let local_var_entity: Option<GetResourceValueInterpolatedError> = crate::from_str_patched(&local_var_content).ok();
492 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
493 Err(Error::ResponseError(local_var_error))
494 }
495}
496
497pub async fn list_resource(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>, resource_type: Option<&str>, resource_type_exclude: Option<&str>, path_start: Option<&str>) -> Result<Vec<models::ListableResource>, Error<ListResourceError>> {
498 let local_var_configuration = configuration;
499
500 let local_var_client = &local_var_configuration.client;
501
502 let local_var_uri_str = format!("{}/w/{workspace}/resources/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
503 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
504
505 if let Some(ref local_var_str) = page {
506 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
507 }
508 if let Some(ref local_var_str) = per_page {
509 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
510 }
511 if let Some(ref local_var_str) = resource_type {
512 local_var_req_builder = local_var_req_builder.query(&[("resource_type", &local_var_str.to_string())]);
513 }
514 if let Some(ref local_var_str) = resource_type_exclude {
515 local_var_req_builder = local_var_req_builder.query(&[("resource_type_exclude", &local_var_str.to_string())]);
516 }
517 if let Some(ref local_var_str) = path_start {
518 local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
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
527 let local_var_req = local_var_req_builder.build()?;
528 let local_var_resp = local_var_client.execute(local_var_req).await?;
529
530 let local_var_status = local_var_resp.status();
531 let local_var_content = local_var_resp.text().await?;
532
533 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
534 crate::from_str_patched(&local_var_content).map_err(Error::from)
535 } else {
536 let local_var_entity: Option<ListResourceError> = crate::from_str_patched(&local_var_content).ok();
537 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
538 Err(Error::ResponseError(local_var_error))
539 }
540}
541
542pub async fn list_resource_names(configuration: &configuration::Configuration, workspace: &str, name: &str) -> Result<Vec<models::ListResourceNames200ResponseInner>, Error<ListResourceNamesError>> {
543 let local_var_configuration = configuration;
544
545 let local_var_client = &local_var_configuration.client;
546
547 let local_var_uri_str = format!("{}/w/{workspace}/resources/list_names/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
548 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
549
550 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
551 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
552 }
553 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
554 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
555 };
556
557 let local_var_req = local_var_req_builder.build()?;
558 let local_var_resp = local_var_client.execute(local_var_req).await?;
559
560 let local_var_status = local_var_resp.status();
561 let local_var_content = local_var_resp.text().await?;
562
563 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
564 crate::from_str_patched(&local_var_content).map_err(Error::from)
565 } else {
566 let local_var_entity: Option<ListResourceNamesError> = crate::from_str_patched(&local_var_content).ok();
567 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
568 Err(Error::ResponseError(local_var_error))
569 }
570}
571
572pub async fn list_resource_type(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::ResourceType>, Error<ListResourceTypeError>> {
573 let local_var_configuration = configuration;
574
575 let local_var_client = &local_var_configuration.client;
576
577 let local_var_uri_str = format!("{}/w/{workspace}/resources/type/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
578 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
579
580 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
581 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
582 }
583 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
584 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
585 };
586
587 let local_var_req = local_var_req_builder.build()?;
588 let local_var_resp = local_var_client.execute(local_var_req).await?;
589
590 let local_var_status = local_var_resp.status();
591 let local_var_content = local_var_resp.text().await?;
592
593 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
594 crate::from_str_patched(&local_var_content).map_err(Error::from)
595 } else {
596 let local_var_entity: Option<ListResourceTypeError> = crate::from_str_patched(&local_var_content).ok();
597 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
598 Err(Error::ResponseError(local_var_error))
599 }
600}
601
602pub async fn list_resource_type_names(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<String>, Error<ListResourceTypeNamesError>> {
603 let local_var_configuration = configuration;
604
605 let local_var_client = &local_var_configuration.client;
606
607 let local_var_uri_str = format!("{}/w/{workspace}/resources/type/listnames", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
608 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
609
610 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
611 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
612 }
613 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
614 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
615 };
616
617 let local_var_req = local_var_req_builder.build()?;
618 let local_var_resp = local_var_client.execute(local_var_req).await?;
619
620 let local_var_status = local_var_resp.status();
621 let local_var_content = local_var_resp.text().await?;
622
623 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
624 crate::from_str_patched(&local_var_content).map_err(Error::from)
625 } else {
626 let local_var_entity: Option<ListResourceTypeNamesError> = crate::from_str_patched(&local_var_content).ok();
627 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
628 Err(Error::ResponseError(local_var_error))
629 }
630}
631
632pub async fn list_search_resource(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::ListSearchResource200ResponseInner>, Error<ListSearchResourceError>> {
633 let local_var_configuration = configuration;
634
635 let local_var_client = &local_var_configuration.client;
636
637 let local_var_uri_str = format!("{}/w/{workspace}/resources/list_search", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
638 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
639
640 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
641 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
642 }
643 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
644 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
645 };
646
647 let local_var_req = local_var_req_builder.build()?;
648 let local_var_resp = local_var_client.execute(local_var_req).await?;
649
650 let local_var_status = local_var_resp.status();
651 let local_var_content = local_var_resp.text().await?;
652
653 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
654 crate::from_str_patched(&local_var_content).map_err(Error::from)
655 } else {
656 let local_var_entity: Option<ListSearchResourceError> = crate::from_str_patched(&local_var_content).ok();
657 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
658 Err(Error::ResponseError(local_var_error))
659 }
660}
661
662pub async fn query_resource_types(configuration: &configuration::Configuration, workspace: &str, text: &str, limit: Option<f64>) -> Result<Vec<models::QueryResourceTypes200ResponseInner>, Error<QueryResourceTypesError>> {
663 let local_var_configuration = configuration;
664
665 let local_var_client = &local_var_configuration.client;
666
667 let local_var_uri_str = format!("{}/w/{workspace}/embeddings/query_resource_types", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
668 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
669
670 local_var_req_builder = local_var_req_builder.query(&[("text", &text.to_string())]);
671 if let Some(ref local_var_str) = limit {
672 local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
673 }
674 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
675 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
676 }
677 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
678 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
679 };
680
681 let local_var_req = local_var_req_builder.build()?;
682 let local_var_resp = local_var_client.execute(local_var_req).await?;
683
684 let local_var_status = local_var_resp.status();
685 let local_var_content = local_var_resp.text().await?;
686
687 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
688 crate::from_str_patched(&local_var_content).map_err(Error::from)
689 } else {
690 let local_var_entity: Option<QueryResourceTypesError> = crate::from_str_patched(&local_var_content).ok();
691 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
692 Err(Error::ResponseError(local_var_error))
693 }
694}
695
696pub async fn update_resource(configuration: &configuration::Configuration, workspace: &str, path: &str, edit_resource: models::EditResource) -> Result<String, Error<UpdateResourceError>> {
697 let local_var_configuration = configuration;
698
699 let local_var_client = &local_var_configuration.client;
700
701 let local_var_uri_str = format!("{}/w/{workspace}/resources/update/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
702 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
703
704 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
705 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
706 }
707 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
708 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
709 };
710 local_var_req_builder = local_var_req_builder.json(&edit_resource);
711
712 let local_var_req = local_var_req_builder.build()?;
713 let local_var_resp = local_var_client.execute(local_var_req).await?;
714
715 let local_var_status = local_var_resp.status();
716 let local_var_content = local_var_resp.text().await?;
717
718 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
719 crate::from_str_patched(&local_var_content).map_err(Error::from)
720 } else {
721 let local_var_entity: Option<UpdateResourceError> = crate::from_str_patched(&local_var_content).ok();
722 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
723 Err(Error::ResponseError(local_var_error))
724 }
725}
726
727pub async fn update_resource_type(configuration: &configuration::Configuration, workspace: &str, path: &str, edit_resource_type: models::EditResourceType) -> Result<String, Error<UpdateResourceTypeError>> {
728 let local_var_configuration = configuration;
729
730 let local_var_client = &local_var_configuration.client;
731
732 let local_var_uri_str = format!("{}/w/{workspace}/resources/type/update/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
733 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
734
735 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
736 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
737 }
738 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
739 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
740 };
741 local_var_req_builder = local_var_req_builder.json(&edit_resource_type);
742
743 let local_var_req = local_var_req_builder.build()?;
744 let local_var_resp = local_var_client.execute(local_var_req).await?;
745
746 let local_var_status = local_var_resp.status();
747 let local_var_content = local_var_resp.text().await?;
748
749 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
750 crate::from_str_patched(&local_var_content).map_err(Error::from)
751 } else {
752 let local_var_entity: Option<UpdateResourceTypeError> = crate::from_str_patched(&local_var_content).ok();
753 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
754 Err(Error::ResponseError(local_var_error))
755 }
756}
757
758pub async fn update_resource_value(configuration: &configuration::Configuration, workspace: &str, path: &str, set_global_request: models::SetGlobalRequest) -> Result<String, Error<UpdateResourceValueError>> {
759 let local_var_configuration = configuration;
760
761 let local_var_client = &local_var_configuration.client;
762
763 let local_var_uri_str = format!("{}/w/{workspace}/resources/update_value/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
764 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
765
766 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
767 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
768 }
769 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
770 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
771 };
772 local_var_req_builder = local_var_req_builder.json(&set_global_request);
773
774 let local_var_req = local_var_req_builder.build()?;
775 let local_var_resp = local_var_client.execute(local_var_req).await?;
776
777 let local_var_status = local_var_resp.status();
778 let local_var_content = local_var_resp.text().await?;
779
780 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
781 crate::from_str_patched(&local_var_content).map_err(Error::from)
782 } else {
783 let local_var_entity: Option<UpdateResourceValueError> = crate::from_str_patched(&local_var_content).ok();
784 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
785 Err(Error::ResponseError(local_var_error))
786 }
787}
788