Skip to main content

gitbundle_sdk/apis/
admin_api.rs

1/*
2 * GitBundle API
3 *
4 * GitBundle API documentation.
5 *
6 * The version of the OpenAPI document: 3.4.1
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12use serde::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`delete_runner`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum DeleteRunnerError {
21    Status400(models::JsonErrorResponseNull),
22    Status401(models::JsonErrorResponseNull),
23    Status403(models::JsonErrorResponseNull),
24    Status404(models::JsonErrorResponseNull),
25    Status409(models::JsonErrorResponseNull),
26    Status429(models::JsonErrorResponseNull),
27    Status500(models::JsonErrorResponseNull),
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`delete_variable`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum DeleteVariableError {
35    Status400(models::JsonErrorResponseNull),
36    Status401(models::JsonErrorResponseNull),
37    Status403(models::JsonErrorResponseNull),
38    Status404(models::JsonErrorResponseNull),
39    Status409(models::JsonErrorResponseNull),
40    Status429(models::JsonErrorResponseNull),
41    Status500(models::JsonErrorResponseNull),
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`get_reseted_runner_register_token`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum GetResetedRunnerRegisterTokenError {
49    Status400(models::JsonErrorResponseNull),
50    Status401(models::JsonErrorResponseNull),
51    Status403(models::JsonErrorResponseNull),
52    Status404(models::JsonErrorResponseNull),
53    Status409(models::JsonErrorResponseNull),
54    Status429(models::JsonErrorResponseNull),
55    Status500(models::JsonErrorResponseNull),
56    UnknownValue(serde_json::Value),
57}
58
59/// struct for typed errors of method [`get_runner`]
60#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum GetRunnerError {
63    Status400(models::JsonErrorResponseNull),
64    Status401(models::JsonErrorResponseNull),
65    Status403(models::JsonErrorResponseNull),
66    Status404(models::JsonErrorResponseNull),
67    Status409(models::JsonErrorResponseNull),
68    Status429(models::JsonErrorResponseNull),
69    Status500(models::JsonErrorResponseNull),
70    UnknownValue(serde_json::Value),
71}
72
73/// struct for typed errors of method [`get_runner_register_token`]
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(untagged)]
76pub enum GetRunnerRegisterTokenError {
77    Status400(models::JsonErrorResponseNull),
78    Status401(models::JsonErrorResponseNull),
79    Status403(models::JsonErrorResponseNull),
80    Status404(models::JsonErrorResponseNull),
81    Status409(models::JsonErrorResponseNull),
82    Status429(models::JsonErrorResponseNull),
83    Status500(models::JsonErrorResponseNull),
84    UnknownValue(serde_json::Value),
85}
86
87/// struct for typed errors of method [`get_runners`]
88#[derive(Debug, Clone, Serialize, Deserialize)]
89#[serde(untagged)]
90pub enum GetRunnersError {
91    Status400(models::JsonErrorResponseNull),
92    Status401(models::JsonErrorResponseNull),
93    Status403(models::JsonErrorResponseNull),
94    Status404(models::JsonErrorResponseNull),
95    Status409(models::JsonErrorResponseNull),
96    Status429(models::JsonErrorResponseNull),
97    Status500(models::JsonErrorResponseNull),
98    UnknownValue(serde_json::Value),
99}
100
101/// struct for typed errors of method [`get_user`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum GetUserError {
105    Status400(models::JsonErrorResponseNull),
106    Status401(models::JsonErrorResponseNull),
107    Status403(models::JsonErrorResponseNull),
108    Status404(models::JsonErrorResponseNull),
109    Status409(models::JsonErrorResponseNull),
110    Status429(models::JsonErrorResponseNull),
111    Status500(models::JsonErrorResponseNull),
112    UnknownValue(serde_json::Value),
113}
114
115/// struct for typed errors of method [`get_variable`]
116#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum GetVariableError {
119    Status400(models::JsonErrorResponseNull),
120    Status401(models::JsonErrorResponseNull),
121    Status403(models::JsonErrorResponseNull),
122    Status404(models::JsonErrorResponseNull),
123    Status409(models::JsonErrorResponseNull),
124    Status429(models::JsonErrorResponseNull),
125    Status500(models::JsonErrorResponseNull),
126    UnknownValue(serde_json::Value),
127}
128
129/// struct for typed errors of method [`get_variables`]
130#[derive(Debug, Clone, Serialize, Deserialize)]
131#[serde(untagged)]
132pub enum GetVariablesError {
133    Status400(models::JsonErrorResponseNull),
134    Status401(models::JsonErrorResponseNull),
135    Status403(models::JsonErrorResponseNull),
136    Status404(models::JsonErrorResponseNull),
137    Status409(models::JsonErrorResponseNull),
138    Status429(models::JsonErrorResponseNull),
139    Status500(models::JsonErrorResponseNull),
140    UnknownValue(serde_json::Value),
141}
142
143/// struct for typed errors of method [`patch_runner`]
144#[derive(Debug, Clone, Serialize, Deserialize)]
145#[serde(untagged)]
146pub enum PatchRunnerError {
147    Status400(models::JsonErrorResponseNull),
148    Status401(models::JsonErrorResponseNull),
149    Status403(models::JsonErrorResponseNull),
150    Status404(models::JsonErrorResponseNull),
151    Status409(models::JsonErrorResponseNull),
152    Status429(models::JsonErrorResponseNull),
153    Status500(models::JsonErrorResponseNull),
154    UnknownValue(serde_json::Value),
155}
156
157/// struct for typed errors of method [`patch_variable`]
158#[derive(Debug, Clone, Serialize, Deserialize)]
159#[serde(untagged)]
160pub enum PatchVariableError {
161    Status400(models::JsonErrorResponseNull),
162    Status401(models::JsonErrorResponseNull),
163    Status403(models::JsonErrorResponseNull),
164    Status404(models::JsonErrorResponseNull),
165    Status409(models::JsonErrorResponseNull),
166    Status429(models::JsonErrorResponseNull),
167    Status500(models::JsonErrorResponseNull),
168    UnknownValue(serde_json::Value),
169}
170
171/// struct for typed errors of method [`post_user`]
172#[derive(Debug, Clone, Serialize, Deserialize)]
173#[serde(untagged)]
174pub enum PostUserError {
175    Status400(models::JsonErrorResponseNull),
176    Status401(models::JsonErrorResponseNull),
177    Status403(models::JsonErrorResponseNull),
178    Status404(models::JsonErrorResponseNull),
179    Status409(models::JsonErrorResponseNull),
180    Status429(models::JsonErrorResponseNull),
181    Status500(models::JsonErrorResponseNull),
182    UnknownValue(serde_json::Value),
183}
184
185/// struct for typed errors of method [`post_variable`]
186#[derive(Debug, Clone, Serialize, Deserialize)]
187#[serde(untagged)]
188pub enum PostVariableError {
189    Status400(models::JsonErrorResponseNull),
190    Status401(models::JsonErrorResponseNull),
191    Status403(models::JsonErrorResponseNull),
192    Status404(models::JsonErrorResponseNull),
193    Status409(models::JsonErrorResponseNull),
194    Status429(models::JsonErrorResponseNull),
195    Status500(models::JsonErrorResponseNull),
196    UnknownValue(serde_json::Value),
197}
198
199pub async fn delete_runner(
200    configuration: &configuration::Configuration,
201    runner_uuid: &str,
202) -> Result<(), Error<DeleteRunnerError>> {
203    // add a prefix to parameters to efficiently prevent name collisions
204    let p_path_runner_uuid = runner_uuid;
205
206    let uri_str = format!(
207        "{}/admin/runners/{runner_uuid}",
208        configuration.base_path,
209        runner_uuid = crate::apis::urlencode(p_path_runner_uuid)
210    );
211    let mut req_builder = configuration
212        .client
213        .request(reqwest::Method::DELETE, &uri_str);
214
215    if let Some(ref apikey) = configuration.api_key {
216        let key = apikey.key.clone();
217        let value = match apikey.prefix {
218            Some(ref prefix) => format!("{} {}", prefix, key),
219            None => key,
220        };
221        req_builder = req_builder.query(&[("access_token", value)]);
222    }
223    if let Some(ref user_agent) = configuration.user_agent {
224        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
225    }
226    if let Some(ref auth_conf) = configuration.basic_auth {
227        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
228    };
229    if let Some(ref token) = configuration.bearer_access_token {
230        req_builder = req_builder.bearer_auth(token.to_owned());
231    };
232
233    let req = req_builder.build()?;
234    let resp = configuration.client.execute(req).await?;
235
236    let status = resp.status();
237
238    if !status.is_client_error() && !status.is_server_error() {
239        Ok(())
240    } else {
241        let content = resp.text().await?;
242        let entity: Option<DeleteRunnerError> = serde_json::from_str(&content).ok();
243        Err(Error::ResponseError(ResponseContent {
244            status,
245            content,
246            entity,
247        }))
248    }
249}
250
251pub async fn delete_variable(
252    configuration: &configuration::Configuration,
253    variable_identifier: &str,
254) -> Result<(), Error<DeleteVariableError>> {
255    // add a prefix to parameters to efficiently prevent name collisions
256    let p_path_variable_identifier = variable_identifier;
257
258    let uri_str = format!(
259        "{}/admin/variables/{variable_identifier}",
260        configuration.base_path,
261        variable_identifier = crate::apis::urlencode(p_path_variable_identifier)
262    );
263    let mut req_builder = configuration
264        .client
265        .request(reqwest::Method::DELETE, &uri_str);
266
267    if let Some(ref apikey) = configuration.api_key {
268        let key = apikey.key.clone();
269        let value = match apikey.prefix {
270            Some(ref prefix) => format!("{} {}", prefix, key),
271            None => key,
272        };
273        req_builder = req_builder.query(&[("access_token", value)]);
274    }
275    if let Some(ref user_agent) = configuration.user_agent {
276        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
277    }
278    if let Some(ref auth_conf) = configuration.basic_auth {
279        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
280    };
281    if let Some(ref token) = configuration.bearer_access_token {
282        req_builder = req_builder.bearer_auth(token.to_owned());
283    };
284
285    let req = req_builder.build()?;
286    let resp = configuration.client.execute(req).await?;
287
288    let status = resp.status();
289
290    if !status.is_client_error() && !status.is_server_error() {
291        Ok(())
292    } else {
293        let content = resp.text().await?;
294        let entity: Option<DeleteVariableError> = serde_json::from_str(&content).ok();
295        Err(Error::ResponseError(ResponseContent {
296            status,
297            content,
298            entity,
299        }))
300    }
301}
302
303pub async fn get_reseted_runner_register_token(
304    configuration: &configuration::Configuration,
305) -> Result<models::RegisterTokenModel, Error<GetResetedRunnerRegisterTokenError>> {
306    let uri_str = format!(
307        "{}/admin/runners/register_token/reseted",
308        configuration.base_path
309    );
310    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
311
312    if let Some(ref apikey) = configuration.api_key {
313        let key = apikey.key.clone();
314        let value = match apikey.prefix {
315            Some(ref prefix) => format!("{} {}", prefix, key),
316            None => key,
317        };
318        req_builder = req_builder.query(&[("access_token", value)]);
319    }
320    if let Some(ref user_agent) = configuration.user_agent {
321        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
322    }
323    if let Some(ref auth_conf) = configuration.basic_auth {
324        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
325    };
326    if let Some(ref token) = configuration.bearer_access_token {
327        req_builder = req_builder.bearer_auth(token.to_owned());
328    };
329
330    let req = req_builder.build()?;
331    let resp = configuration.client.execute(req).await?;
332
333    let status = resp.status();
334    let content_type = resp
335        .headers()
336        .get("content-type")
337        .and_then(|v| v.to_str().ok())
338        .unwrap_or("application/octet-stream");
339    let content_type = super::ContentType::from(content_type);
340
341    if !status.is_client_error() && !status.is_server_error() {
342        let content = resp.text().await?;
343        match content_type {
344            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
345            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegisterTokenModel`"))),
346            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegisterTokenModel`")))),
347        }
348    } else {
349        let content = resp.text().await?;
350        let entity: Option<GetResetedRunnerRegisterTokenError> =
351            serde_json::from_str(&content).ok();
352        Err(Error::ResponseError(ResponseContent {
353            status,
354            content,
355            entity,
356        }))
357    }
358}
359
360pub async fn get_runner(
361    configuration: &configuration::Configuration,
362    runner_uuid: &str,
363) -> Result<models::RunnerModel, Error<GetRunnerError>> {
364    // add a prefix to parameters to efficiently prevent name collisions
365    let p_path_runner_uuid = runner_uuid;
366
367    let uri_str = format!(
368        "{}/admin/runners/{runner_uuid}",
369        configuration.base_path,
370        runner_uuid = crate::apis::urlencode(p_path_runner_uuid)
371    );
372    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
373
374    if let Some(ref apikey) = configuration.api_key {
375        let key = apikey.key.clone();
376        let value = match apikey.prefix {
377            Some(ref prefix) => format!("{} {}", prefix, key),
378            None => key,
379        };
380        req_builder = req_builder.query(&[("access_token", value)]);
381    }
382    if let Some(ref user_agent) = configuration.user_agent {
383        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
384    }
385    if let Some(ref auth_conf) = configuration.basic_auth {
386        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
387    };
388    if let Some(ref token) = configuration.bearer_access_token {
389        req_builder = req_builder.bearer_auth(token.to_owned());
390    };
391
392    let req = req_builder.build()?;
393    let resp = configuration.client.execute(req).await?;
394
395    let status = resp.status();
396    let content_type = resp
397        .headers()
398        .get("content-type")
399        .and_then(|v| v.to_str().ok())
400        .unwrap_or("application/octet-stream");
401    let content_type = super::ContentType::from(content_type);
402
403    if !status.is_client_error() && !status.is_server_error() {
404        let content = resp.text().await?;
405        match content_type {
406            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
407            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RunnerModel`"))),
408            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RunnerModel`")))),
409        }
410    } else {
411        let content = resp.text().await?;
412        let entity: Option<GetRunnerError> = serde_json::from_str(&content).ok();
413        Err(Error::ResponseError(ResponseContent {
414            status,
415            content,
416            entity,
417        }))
418    }
419}
420
421pub async fn get_runner_register_token(
422    configuration: &configuration::Configuration,
423) -> Result<models::RegisterTokenModel, Error<GetRunnerRegisterTokenError>> {
424    let uri_str = format!("{}/admin/runners/register_token", configuration.base_path);
425    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
426
427    if let Some(ref apikey) = configuration.api_key {
428        let key = apikey.key.clone();
429        let value = match apikey.prefix {
430            Some(ref prefix) => format!("{} {}", prefix, key),
431            None => key,
432        };
433        req_builder = req_builder.query(&[("access_token", value)]);
434    }
435    if let Some(ref user_agent) = configuration.user_agent {
436        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
437    }
438    if let Some(ref auth_conf) = configuration.basic_auth {
439        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
440    };
441    if let Some(ref token) = configuration.bearer_access_token {
442        req_builder = req_builder.bearer_auth(token.to_owned());
443    };
444
445    let req = req_builder.build()?;
446    let resp = configuration.client.execute(req).await?;
447
448    let status = resp.status();
449    let content_type = resp
450        .headers()
451        .get("content-type")
452        .and_then(|v| v.to_str().ok())
453        .unwrap_or("application/octet-stream");
454    let content_type = super::ContentType::from(content_type);
455
456    if !status.is_client_error() && !status.is_server_error() {
457        let content = resp.text().await?;
458        match content_type {
459            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
460            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegisterTokenModel`"))),
461            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegisterTokenModel`")))),
462        }
463    } else {
464        let content = resp.text().await?;
465        let entity: Option<GetRunnerRegisterTokenError> = serde_json::from_str(&content).ok();
466        Err(Error::ResponseError(ResponseContent {
467            status,
468            content,
469            entity,
470        }))
471    }
472}
473
474pub async fn get_runners(
475    configuration: &configuration::Configuration,
476    page: Option<i64>,
477    size: Option<i64>,
478    query: Option<&str>,
479) -> Result<Vec<models::RunnerCreator>, Error<GetRunnersError>> {
480    // add a prefix to parameters to efficiently prevent name collisions
481    let p_query_page = page;
482    let p_query_size = size;
483    let p_query_query = query;
484
485    let uri_str = format!("{}/admin/runners", configuration.base_path);
486    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
487
488    if let Some(ref param_value) = p_query_page {
489        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
490    }
491    if let Some(ref param_value) = p_query_size {
492        req_builder = req_builder.query(&[("size", &param_value.to_string())]);
493    }
494    if let Some(ref param_value) = p_query_query {
495        req_builder = req_builder.query(&[("query", &param_value.to_string())]);
496    }
497    if let Some(ref apikey) = configuration.api_key {
498        let key = apikey.key.clone();
499        let value = match apikey.prefix {
500            Some(ref prefix) => format!("{} {}", prefix, key),
501            None => key,
502        };
503        req_builder = req_builder.query(&[("access_token", value)]);
504    }
505    if let Some(ref user_agent) = configuration.user_agent {
506        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
507    }
508    if let Some(ref auth_conf) = configuration.basic_auth {
509        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
510    };
511    if let Some(ref token) = configuration.bearer_access_token {
512        req_builder = req_builder.bearer_auth(token.to_owned());
513    };
514
515    let req = req_builder.build()?;
516    let resp = configuration.client.execute(req).await?;
517
518    let status = resp.status();
519    let content_type = resp
520        .headers()
521        .get("content-type")
522        .and_then(|v| v.to_str().ok())
523        .unwrap_or("application/octet-stream");
524    let content_type = super::ContentType::from(content_type);
525
526    if !status.is_client_error() && !status.is_server_error() {
527        let content = resp.text().await?;
528        match content_type {
529            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
530            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::RunnerCreator&gt;`"))),
531            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::RunnerCreator&gt;`")))),
532        }
533    } else {
534        let content = resp.text().await?;
535        let entity: Option<GetRunnersError> = serde_json::from_str(&content).ok();
536        Err(Error::ResponseError(ResponseContent {
537            status,
538            content,
539            entity,
540        }))
541    }
542}
543
544pub async fn get_user(
545    configuration: &configuration::Configuration,
546    user_identifier: &str,
547) -> Result<models::UserModel, Error<GetUserError>> {
548    // add a prefix to parameters to efficiently prevent name collisions
549    let p_path_user_identifier = user_identifier;
550
551    let uri_str = format!(
552        "{}/admin/users/{user_identifier}",
553        configuration.base_path,
554        user_identifier = crate::apis::urlencode(p_path_user_identifier)
555    );
556    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
557
558    if let Some(ref apikey) = configuration.api_key {
559        let key = apikey.key.clone();
560        let value = match apikey.prefix {
561            Some(ref prefix) => format!("{} {}", prefix, key),
562            None => key,
563        };
564        req_builder = req_builder.query(&[("access_token", value)]);
565    }
566    if let Some(ref user_agent) = configuration.user_agent {
567        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
568    }
569    if let Some(ref auth_conf) = configuration.basic_auth {
570        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
571    };
572    if let Some(ref token) = configuration.bearer_access_token {
573        req_builder = req_builder.bearer_auth(token.to_owned());
574    };
575
576    let req = req_builder.build()?;
577    let resp = configuration.client.execute(req).await?;
578
579    let status = resp.status();
580    let content_type = resp
581        .headers()
582        .get("content-type")
583        .and_then(|v| v.to_str().ok())
584        .unwrap_or("application/octet-stream");
585    let content_type = super::ContentType::from(content_type);
586
587    if !status.is_client_error() && !status.is_server_error() {
588        let content = resp.text().await?;
589        match content_type {
590            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
591            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UserModel`"))),
592            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserModel`")))),
593        }
594    } else {
595        let content = resp.text().await?;
596        let entity: Option<GetUserError> = serde_json::from_str(&content).ok();
597        Err(Error::ResponseError(ResponseContent {
598            status,
599            content,
600            entity,
601        }))
602    }
603}
604
605pub async fn get_variable(
606    configuration: &configuration::Configuration,
607    variable_identifier: &str,
608) -> Result<models::VariableModel, Error<GetVariableError>> {
609    // add a prefix to parameters to efficiently prevent name collisions
610    let p_path_variable_identifier = variable_identifier;
611
612    let uri_str = format!(
613        "{}/admin/variables/{variable_identifier}",
614        configuration.base_path,
615        variable_identifier = crate::apis::urlencode(p_path_variable_identifier)
616    );
617    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
618
619    if let Some(ref apikey) = configuration.api_key {
620        let key = apikey.key.clone();
621        let value = match apikey.prefix {
622            Some(ref prefix) => format!("{} {}", prefix, key),
623            None => key,
624        };
625        req_builder = req_builder.query(&[("access_token", value)]);
626    }
627    if let Some(ref user_agent) = configuration.user_agent {
628        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
629    }
630    if let Some(ref auth_conf) = configuration.basic_auth {
631        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
632    };
633    if let Some(ref token) = configuration.bearer_access_token {
634        req_builder = req_builder.bearer_auth(token.to_owned());
635    };
636
637    let req = req_builder.build()?;
638    let resp = configuration.client.execute(req).await?;
639
640    let status = resp.status();
641    let content_type = resp
642        .headers()
643        .get("content-type")
644        .and_then(|v| v.to_str().ok())
645        .unwrap_or("application/octet-stream");
646    let content_type = super::ContentType::from(content_type);
647
648    if !status.is_client_error() && !status.is_server_error() {
649        let content = resp.text().await?;
650        match content_type {
651            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
652            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VariableModel`"))),
653            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VariableModel`")))),
654        }
655    } else {
656        let content = resp.text().await?;
657        let entity: Option<GetVariableError> = serde_json::from_str(&content).ok();
658        Err(Error::ResponseError(ResponseContent {
659            status,
660            content,
661            entity,
662        }))
663    }
664}
665
666pub async fn get_variables(
667    configuration: &configuration::Configuration,
668    page: Option<i64>,
669    size: Option<i64>,
670    query: Option<&str>,
671    types: Option<Vec<models::VariableType>>,
672    sort: Option<models::VariableSort>,
673    order: Option<models::OrderOption>,
674) -> Result<Vec<models::VariableGroup>, Error<GetVariablesError>> {
675    // add a prefix to parameters to efficiently prevent name collisions
676    let p_query_page = page;
677    let p_query_size = size;
678    let p_query_query = query;
679    let p_query_types = types;
680    let p_query_sort = sort;
681    let p_query_order = order;
682
683    let uri_str = format!("{}/admin/variables", configuration.base_path);
684    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
685
686    if let Some(ref param_value) = p_query_page {
687        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
688    }
689    if let Some(ref param_value) = p_query_size {
690        req_builder = req_builder.query(&[("size", &param_value.to_string())]);
691    }
692    if let Some(ref param_value) = p_query_query {
693        req_builder = req_builder.query(&[("query", &param_value.to_string())]);
694    }
695    if let Some(ref param_value) = p_query_types {
696        req_builder = match "multi" {
697            "multi" => req_builder.query(
698                &param_value
699                    .iter()
700                    .map(|p| ("types".to_owned(), p.to_string()))
701                    .collect::<Vec<(std::string::String, std::string::String)>>(),
702            ),
703            _ => req_builder.query(&[(
704                "types",
705                &param_value
706                    .iter()
707                    .map(|p| p.to_string())
708                    .collect::<Vec<String>>()
709                    .join(",")
710                    .to_string(),
711            )]),
712        };
713    }
714    if let Some(ref param_value) = p_query_sort {
715        req_builder = req_builder.query(&[("sort", &param_value.to_string())]);
716    }
717    if let Some(ref param_value) = p_query_order {
718        req_builder = req_builder.query(&[("order", &param_value.to_string())]);
719    }
720    if let Some(ref apikey) = configuration.api_key {
721        let key = apikey.key.clone();
722        let value = match apikey.prefix {
723            Some(ref prefix) => format!("{} {}", prefix, key),
724            None => key,
725        };
726        req_builder = req_builder.query(&[("access_token", value)]);
727    }
728    if let Some(ref user_agent) = configuration.user_agent {
729        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
730    }
731    if let Some(ref auth_conf) = configuration.basic_auth {
732        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
733    };
734    if let Some(ref token) = configuration.bearer_access_token {
735        req_builder = req_builder.bearer_auth(token.to_owned());
736    };
737
738    let req = req_builder.build()?;
739    let resp = configuration.client.execute(req).await?;
740
741    let status = resp.status();
742    let content_type = resp
743        .headers()
744        .get("content-type")
745        .and_then(|v| v.to_str().ok())
746        .unwrap_or("application/octet-stream");
747    let content_type = super::ContentType::from(content_type);
748
749    if !status.is_client_error() && !status.is_server_error() {
750        let content = resp.text().await?;
751        match content_type {
752            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
753            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::VariableGroup&gt;`"))),
754            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::VariableGroup&gt;`")))),
755        }
756    } else {
757        let content = resp.text().await?;
758        let entity: Option<GetVariablesError> = serde_json::from_str(&content).ok();
759        Err(Error::ResponseError(ResponseContent {
760            status,
761            content,
762            entity,
763        }))
764    }
765}
766
767pub async fn patch_runner(
768    configuration: &configuration::Configuration,
769    runner_uuid: &str,
770    runner_patch_input: models::RunnerPatchInput,
771) -> Result<models::RunnerModel, Error<PatchRunnerError>> {
772    // add a prefix to parameters to efficiently prevent name collisions
773    let p_path_runner_uuid = runner_uuid;
774    let p_body_runner_patch_input = runner_patch_input;
775
776    let uri_str = format!(
777        "{}/admin/runners/{runner_uuid}",
778        configuration.base_path,
779        runner_uuid = crate::apis::urlencode(p_path_runner_uuid)
780    );
781    let mut req_builder = configuration
782        .client
783        .request(reqwest::Method::PATCH, &uri_str);
784
785    if let Some(ref apikey) = configuration.api_key {
786        let key = apikey.key.clone();
787        let value = match apikey.prefix {
788            Some(ref prefix) => format!("{} {}", prefix, key),
789            None => key,
790        };
791        req_builder = req_builder.query(&[("access_token", value)]);
792    }
793    if let Some(ref user_agent) = configuration.user_agent {
794        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
795    }
796    if let Some(ref auth_conf) = configuration.basic_auth {
797        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
798    };
799    if let Some(ref token) = configuration.bearer_access_token {
800        req_builder = req_builder.bearer_auth(token.to_owned());
801    };
802    req_builder = req_builder.json(&p_body_runner_patch_input);
803
804    let req = req_builder.build()?;
805    let resp = configuration.client.execute(req).await?;
806
807    let status = resp.status();
808    let content_type = resp
809        .headers()
810        .get("content-type")
811        .and_then(|v| v.to_str().ok())
812        .unwrap_or("application/octet-stream");
813    let content_type = super::ContentType::from(content_type);
814
815    if !status.is_client_error() && !status.is_server_error() {
816        let content = resp.text().await?;
817        match content_type {
818            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
819            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RunnerModel`"))),
820            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RunnerModel`")))),
821        }
822    } else {
823        let content = resp.text().await?;
824        let entity: Option<PatchRunnerError> = serde_json::from_str(&content).ok();
825        Err(Error::ResponseError(ResponseContent {
826            status,
827            content,
828            entity,
829        }))
830    }
831}
832
833pub async fn patch_variable(
834    configuration: &configuration::Configuration,
835    variable_identifier: &str,
836    variable_patch_input: models::VariablePatchInput,
837) -> Result<models::VariableModel, Error<PatchVariableError>> {
838    // add a prefix to parameters to efficiently prevent name collisions
839    let p_path_variable_identifier = variable_identifier;
840    let p_body_variable_patch_input = variable_patch_input;
841
842    let uri_str = format!(
843        "{}/admin/variables/{variable_identifier}",
844        configuration.base_path,
845        variable_identifier = crate::apis::urlencode(p_path_variable_identifier)
846    );
847    let mut req_builder = configuration
848        .client
849        .request(reqwest::Method::PATCH, &uri_str);
850
851    if let Some(ref apikey) = configuration.api_key {
852        let key = apikey.key.clone();
853        let value = match apikey.prefix {
854            Some(ref prefix) => format!("{} {}", prefix, key),
855            None => key,
856        };
857        req_builder = req_builder.query(&[("access_token", value)]);
858    }
859    if let Some(ref user_agent) = configuration.user_agent {
860        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
861    }
862    if let Some(ref auth_conf) = configuration.basic_auth {
863        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
864    };
865    if let Some(ref token) = configuration.bearer_access_token {
866        req_builder = req_builder.bearer_auth(token.to_owned());
867    };
868    req_builder = req_builder.json(&p_body_variable_patch_input);
869
870    let req = req_builder.build()?;
871    let resp = configuration.client.execute(req).await?;
872
873    let status = resp.status();
874    let content_type = resp
875        .headers()
876        .get("content-type")
877        .and_then(|v| v.to_str().ok())
878        .unwrap_or("application/octet-stream");
879    let content_type = super::ContentType::from(content_type);
880
881    if !status.is_client_error() && !status.is_server_error() {
882        let content = resp.text().await?;
883        match content_type {
884            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
885            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VariableModel`"))),
886            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VariableModel`")))),
887        }
888    } else {
889        let content = resp.text().await?;
890        let entity: Option<PatchVariableError> = serde_json::from_str(&content).ok();
891        Err(Error::ResponseError(ResponseContent {
892            status,
893            content,
894            entity,
895        }))
896    }
897}
898
899pub async fn post_user(
900    configuration: &configuration::Configuration,
901    user_create_input: models::UserCreateInput,
902) -> Result<models::UserModel, Error<PostUserError>> {
903    // add a prefix to parameters to efficiently prevent name collisions
904    let p_body_user_create_input = user_create_input;
905
906    let uri_str = format!("{}/admin/users", configuration.base_path);
907    let mut req_builder = configuration
908        .client
909        .request(reqwest::Method::POST, &uri_str);
910
911    if let Some(ref apikey) = configuration.api_key {
912        let key = apikey.key.clone();
913        let value = match apikey.prefix {
914            Some(ref prefix) => format!("{} {}", prefix, key),
915            None => key,
916        };
917        req_builder = req_builder.query(&[("access_token", value)]);
918    }
919    if let Some(ref user_agent) = configuration.user_agent {
920        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
921    }
922    if let Some(ref auth_conf) = configuration.basic_auth {
923        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
924    };
925    if let Some(ref token) = configuration.bearer_access_token {
926        req_builder = req_builder.bearer_auth(token.to_owned());
927    };
928    req_builder = req_builder.json(&p_body_user_create_input);
929
930    let req = req_builder.build()?;
931    let resp = configuration.client.execute(req).await?;
932
933    let status = resp.status();
934    let content_type = resp
935        .headers()
936        .get("content-type")
937        .and_then(|v| v.to_str().ok())
938        .unwrap_or("application/octet-stream");
939    let content_type = super::ContentType::from(content_type);
940
941    if !status.is_client_error() && !status.is_server_error() {
942        let content = resp.text().await?;
943        match content_type {
944            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
945            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UserModel`"))),
946            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserModel`")))),
947        }
948    } else {
949        let content = resp.text().await?;
950        let entity: Option<PostUserError> = serde_json::from_str(&content).ok();
951        Err(Error::ResponseError(ResponseContent {
952            status,
953            content,
954            entity,
955        }))
956    }
957}
958
959pub async fn post_variable(
960    configuration: &configuration::Configuration,
961    variable_create_input: models::VariableCreateInput,
962) -> Result<models::VariableModel, Error<PostVariableError>> {
963    // add a prefix to parameters to efficiently prevent name collisions
964    let p_body_variable_create_input = variable_create_input;
965
966    let uri_str = format!("{}/admin/variables", configuration.base_path);
967    let mut req_builder = configuration
968        .client
969        .request(reqwest::Method::POST, &uri_str);
970
971    if let Some(ref apikey) = configuration.api_key {
972        let key = apikey.key.clone();
973        let value = match apikey.prefix {
974            Some(ref prefix) => format!("{} {}", prefix, key),
975            None => key,
976        };
977        req_builder = req_builder.query(&[("access_token", value)]);
978    }
979    if let Some(ref user_agent) = configuration.user_agent {
980        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
981    }
982    if let Some(ref auth_conf) = configuration.basic_auth {
983        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
984    };
985    if let Some(ref token) = configuration.bearer_access_token {
986        req_builder = req_builder.bearer_auth(token.to_owned());
987    };
988    req_builder = req_builder.json(&p_body_variable_create_input);
989
990    let req = req_builder.build()?;
991    let resp = configuration.client.execute(req).await?;
992
993    let status = resp.status();
994    let content_type = resp
995        .headers()
996        .get("content-type")
997        .and_then(|v| v.to_str().ok())
998        .unwrap_or("application/octet-stream");
999    let content_type = super::ContentType::from(content_type);
1000
1001    if !status.is_client_error() && !status.is_server_error() {
1002        let content = resp.text().await?;
1003        match content_type {
1004            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1005            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VariableModel`"))),
1006            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VariableModel`")))),
1007        }
1008    } else {
1009        let content = resp.text().await?;
1010        let entity: Option<PostVariableError> = serde_json::from_str(&content).ok();
1011        Err(Error::ResponseError(ResponseContent {
1012            status,
1013            content,
1014            entity,
1015        }))
1016    }
1017}