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