1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetGitignoreTemplateInfoError {
22 Status404(),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum GetLabelTemplateInfoError {
30 Status404(),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum GetLicenseTemplateInfoError {
38 Status404(),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum GetNodeInfoError {
46 UnknownValue(serde_json::Value),
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(untagged)]
52pub enum GetSigningKeyError {
53 UnknownValue(serde_json::Value),
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum GetSigningKeySshError {
60 UnknownValue(serde_json::Value),
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum GetVersionError {
67 UnknownValue(serde_json::Value),
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum ListGitignoresTemplatesError {
74 UnknownValue(serde_json::Value),
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum ListLabelTemplatesError {
81 UnknownValue(serde_json::Value),
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum ListLicenseTemplatesError {
88 UnknownValue(serde_json::Value),
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum RenderMarkdownError {
95 Status422(),
96 UnknownValue(serde_json::Value),
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum RenderMarkdownRawError {
103 Status422(),
104 UnknownValue(serde_json::Value),
105}
106
107#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum RenderMarkupError {
111 Status422(),
112 UnknownValue(serde_json::Value),
113}
114
115
116pub async fn get_gitignore_template_info(configuration: &configuration::Configuration, name: &str) -> Result<models::GitignoreTemplateInfo, Error<GetGitignoreTemplateInfoError>> {
117 let p_path_name = name;
119
120 let uri_str = format!("{}/gitignore/templates/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
121 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
122
123 if let Some(ref apikey) = configuration.api_key {
124 let key = apikey.key.clone();
125 let value = match apikey.prefix {
126 Some(ref prefix) => format!("{} {}", prefix, key),
127 None => key,
128 };
129 req_builder = req_builder.query(&[("access_token", value)]);
130 }
131 if let Some(ref apikey) = configuration.api_key {
132 let key = apikey.key.clone();
133 let value = match apikey.prefix {
134 Some(ref prefix) => format!("{} {}", prefix, key),
135 None => key,
136 };
137 req_builder = req_builder.query(&[("sudo", value)]);
138 }
139 if let Some(ref apikey) = configuration.api_key {
140 let key = apikey.key.clone();
141 let value = match apikey.prefix {
142 Some(ref prefix) => format!("{} {}", prefix, key),
143 None => key,
144 };
145 req_builder = req_builder.query(&[("token", value)]);
146 }
147 if let Some(ref user_agent) = configuration.user_agent {
148 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
149 }
150 if let Some(ref apikey) = configuration.api_key {
151 let key = apikey.key.clone();
152 let value = match apikey.prefix {
153 Some(ref prefix) => format!("{} {}", prefix, key),
154 None => key,
155 };
156 req_builder = req_builder.header("X-GITEA-OTP", value);
157 };
158 if let Some(ref apikey) = configuration.api_key {
159 let key = apikey.key.clone();
160 let value = match apikey.prefix {
161 Some(ref prefix) => format!("{} {}", prefix, key),
162 None => key,
163 };
164 req_builder = req_builder.header("Authorization", value);
165 };
166 if let Some(ref apikey) = configuration.api_key {
167 let key = apikey.key.clone();
168 let value = match apikey.prefix {
169 Some(ref prefix) => format!("{} {}", prefix, key),
170 None => key,
171 };
172 req_builder = req_builder.header("Sudo", value);
173 };
174 if let Some(ref auth_conf) = configuration.basic_auth {
175 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
176 };
177
178 let req = req_builder.build()?;
179 let resp = configuration.client.execute(req).await?;
180
181 let status = resp.status();
182 let content_type = resp
183 .headers()
184 .get("content-type")
185 .and_then(|v| v.to_str().ok())
186 .unwrap_or("application/octet-stream");
187 let content_type = super::ContentType::from(content_type);
188
189 if !status.is_client_error() && !status.is_server_error() {
190 let content = resp.text().await?;
191 match content_type {
192 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
193 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GitignoreTemplateInfo`"))),
194 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GitignoreTemplateInfo`")))),
195 }
196 } else {
197 let content = resp.text().await?;
198 let entity: Option<GetGitignoreTemplateInfoError> = serde_json::from_str(&content).ok();
199 Err(Error::ResponseError(ResponseContent { status, content, entity }))
200 }
201}
202
203pub async fn get_label_template_info(configuration: &configuration::Configuration, name: &str) -> Result<Vec<models::LabelTemplate>, Error<GetLabelTemplateInfoError>> {
204 let p_path_name = name;
206
207 let uri_str = format!("{}/label/templates/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
208 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
209
210 if let Some(ref apikey) = configuration.api_key {
211 let key = apikey.key.clone();
212 let value = match apikey.prefix {
213 Some(ref prefix) => format!("{} {}", prefix, key),
214 None => key,
215 };
216 req_builder = req_builder.query(&[("access_token", value)]);
217 }
218 if let Some(ref apikey) = configuration.api_key {
219 let key = apikey.key.clone();
220 let value = match apikey.prefix {
221 Some(ref prefix) => format!("{} {}", prefix, key),
222 None => key,
223 };
224 req_builder = req_builder.query(&[("sudo", value)]);
225 }
226 if let Some(ref apikey) = configuration.api_key {
227 let key = apikey.key.clone();
228 let value = match apikey.prefix {
229 Some(ref prefix) => format!("{} {}", prefix, key),
230 None => key,
231 };
232 req_builder = req_builder.query(&[("token", value)]);
233 }
234 if let Some(ref user_agent) = configuration.user_agent {
235 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
236 }
237 if let Some(ref apikey) = configuration.api_key {
238 let key = apikey.key.clone();
239 let value = match apikey.prefix {
240 Some(ref prefix) => format!("{} {}", prefix, key),
241 None => key,
242 };
243 req_builder = req_builder.header("X-GITEA-OTP", value);
244 };
245 if let Some(ref apikey) = configuration.api_key {
246 let key = apikey.key.clone();
247 let value = match apikey.prefix {
248 Some(ref prefix) => format!("{} {}", prefix, key),
249 None => key,
250 };
251 req_builder = req_builder.header("Authorization", value);
252 };
253 if let Some(ref apikey) = configuration.api_key {
254 let key = apikey.key.clone();
255 let value = match apikey.prefix {
256 Some(ref prefix) => format!("{} {}", prefix, key),
257 None => key,
258 };
259 req_builder = req_builder.header("Sudo", value);
260 };
261 if let Some(ref auth_conf) = configuration.basic_auth {
262 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
263 };
264
265 let req = req_builder.build()?;
266 let resp = configuration.client.execute(req).await?;
267
268 let status = resp.status();
269 let content_type = resp
270 .headers()
271 .get("content-type")
272 .and_then(|v| v.to_str().ok())
273 .unwrap_or("application/octet-stream");
274 let content_type = super::ContentType::from(content_type);
275
276 if !status.is_client_error() && !status.is_server_error() {
277 let content = resp.text().await?;
278 match content_type {
279 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
280 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::LabelTemplate>`"))),
281 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::LabelTemplate>`")))),
282 }
283 } else {
284 let content = resp.text().await?;
285 let entity: Option<GetLabelTemplateInfoError> = serde_json::from_str(&content).ok();
286 Err(Error::ResponseError(ResponseContent { status, content, entity }))
287 }
288}
289
290pub async fn get_license_template_info(configuration: &configuration::Configuration, name: &str) -> Result<models::LicenseTemplateInfo, Error<GetLicenseTemplateInfoError>> {
291 let p_path_name = name;
293
294 let uri_str = format!("{}/licenses/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
295 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
296
297 if let Some(ref apikey) = configuration.api_key {
298 let key = apikey.key.clone();
299 let value = match apikey.prefix {
300 Some(ref prefix) => format!("{} {}", prefix, key),
301 None => key,
302 };
303 req_builder = req_builder.query(&[("access_token", value)]);
304 }
305 if let Some(ref apikey) = configuration.api_key {
306 let key = apikey.key.clone();
307 let value = match apikey.prefix {
308 Some(ref prefix) => format!("{} {}", prefix, key),
309 None => key,
310 };
311 req_builder = req_builder.query(&[("sudo", value)]);
312 }
313 if let Some(ref apikey) = configuration.api_key {
314 let key = apikey.key.clone();
315 let value = match apikey.prefix {
316 Some(ref prefix) => format!("{} {}", prefix, key),
317 None => key,
318 };
319 req_builder = req_builder.query(&[("token", value)]);
320 }
321 if let Some(ref user_agent) = configuration.user_agent {
322 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
323 }
324 if let Some(ref apikey) = configuration.api_key {
325 let key = apikey.key.clone();
326 let value = match apikey.prefix {
327 Some(ref prefix) => format!("{} {}", prefix, key),
328 None => key,
329 };
330 req_builder = req_builder.header("X-GITEA-OTP", value);
331 };
332 if let Some(ref apikey) = configuration.api_key {
333 let key = apikey.key.clone();
334 let value = match apikey.prefix {
335 Some(ref prefix) => format!("{} {}", prefix, key),
336 None => key,
337 };
338 req_builder = req_builder.header("Authorization", value);
339 };
340 if let Some(ref apikey) = configuration.api_key {
341 let key = apikey.key.clone();
342 let value = match apikey.prefix {
343 Some(ref prefix) => format!("{} {}", prefix, key),
344 None => key,
345 };
346 req_builder = req_builder.header("Sudo", value);
347 };
348 if let Some(ref auth_conf) = configuration.basic_auth {
349 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
350 };
351
352 let req = req_builder.build()?;
353 let resp = configuration.client.execute(req).await?;
354
355 let status = resp.status();
356 let content_type = resp
357 .headers()
358 .get("content-type")
359 .and_then(|v| v.to_str().ok())
360 .unwrap_or("application/octet-stream");
361 let content_type = super::ContentType::from(content_type);
362
363 if !status.is_client_error() && !status.is_server_error() {
364 let content = resp.text().await?;
365 match content_type {
366 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
367 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LicenseTemplateInfo`"))),
368 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LicenseTemplateInfo`")))),
369 }
370 } else {
371 let content = resp.text().await?;
372 let entity: Option<GetLicenseTemplateInfoError> = serde_json::from_str(&content).ok();
373 Err(Error::ResponseError(ResponseContent { status, content, entity }))
374 }
375}
376
377pub async fn get_node_info(configuration: &configuration::Configuration, ) -> Result<models::NodeInfo, Error<GetNodeInfoError>> {
378
379 let uri_str = format!("{}/nodeinfo", configuration.base_path);
380 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
381
382 if let Some(ref apikey) = configuration.api_key {
383 let key = apikey.key.clone();
384 let value = match apikey.prefix {
385 Some(ref prefix) => format!("{} {}", prefix, key),
386 None => key,
387 };
388 req_builder = req_builder.query(&[("access_token", value)]);
389 }
390 if let Some(ref apikey) = configuration.api_key {
391 let key = apikey.key.clone();
392 let value = match apikey.prefix {
393 Some(ref prefix) => format!("{} {}", prefix, key),
394 None => key,
395 };
396 req_builder = req_builder.query(&[("sudo", value)]);
397 }
398 if let Some(ref apikey) = configuration.api_key {
399 let key = apikey.key.clone();
400 let value = match apikey.prefix {
401 Some(ref prefix) => format!("{} {}", prefix, key),
402 None => key,
403 };
404 req_builder = req_builder.query(&[("token", value)]);
405 }
406 if let Some(ref user_agent) = configuration.user_agent {
407 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
408 }
409 if let Some(ref apikey) = configuration.api_key {
410 let key = apikey.key.clone();
411 let value = match apikey.prefix {
412 Some(ref prefix) => format!("{} {}", prefix, key),
413 None => key,
414 };
415 req_builder = req_builder.header("X-GITEA-OTP", value);
416 };
417 if let Some(ref apikey) = configuration.api_key {
418 let key = apikey.key.clone();
419 let value = match apikey.prefix {
420 Some(ref prefix) => format!("{} {}", prefix, key),
421 None => key,
422 };
423 req_builder = req_builder.header("Authorization", value);
424 };
425 if let Some(ref apikey) = configuration.api_key {
426 let key = apikey.key.clone();
427 let value = match apikey.prefix {
428 Some(ref prefix) => format!("{} {}", prefix, key),
429 None => key,
430 };
431 req_builder = req_builder.header("Sudo", value);
432 };
433 if let Some(ref auth_conf) = configuration.basic_auth {
434 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
435 };
436
437 let req = req_builder.build()?;
438 let resp = configuration.client.execute(req).await?;
439
440 let status = resp.status();
441 let content_type = resp
442 .headers()
443 .get("content-type")
444 .and_then(|v| v.to_str().ok())
445 .unwrap_or("application/octet-stream");
446 let content_type = super::ContentType::from(content_type);
447
448 if !status.is_client_error() && !status.is_server_error() {
449 let content = resp.text().await?;
450 match content_type {
451 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
452 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodeInfo`"))),
453 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodeInfo`")))),
454 }
455 } else {
456 let content = resp.text().await?;
457 let entity: Option<GetNodeInfoError> = serde_json::from_str(&content).ok();
458 Err(Error::ResponseError(ResponseContent { status, content, entity }))
459 }
460}
461
462pub async fn get_signing_key(configuration: &configuration::Configuration, ) -> Result<String, Error<GetSigningKeyError>> {
463
464 let uri_str = format!("{}/signing-key.gpg", configuration.base_path);
465 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
466
467 if let Some(ref apikey) = configuration.api_key {
468 let key = apikey.key.clone();
469 let value = match apikey.prefix {
470 Some(ref prefix) => format!("{} {}", prefix, key),
471 None => key,
472 };
473 req_builder = req_builder.query(&[("access_token", value)]);
474 }
475 if let Some(ref apikey) = configuration.api_key {
476 let key = apikey.key.clone();
477 let value = match apikey.prefix {
478 Some(ref prefix) => format!("{} {}", prefix, key),
479 None => key,
480 };
481 req_builder = req_builder.query(&[("sudo", value)]);
482 }
483 if let Some(ref apikey) = configuration.api_key {
484 let key = apikey.key.clone();
485 let value = match apikey.prefix {
486 Some(ref prefix) => format!("{} {}", prefix, key),
487 None => key,
488 };
489 req_builder = req_builder.query(&[("token", value)]);
490 }
491 if let Some(ref user_agent) = configuration.user_agent {
492 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
493 }
494 if let Some(ref apikey) = configuration.api_key {
495 let key = apikey.key.clone();
496 let value = match apikey.prefix {
497 Some(ref prefix) => format!("{} {}", prefix, key),
498 None => key,
499 };
500 req_builder = req_builder.header("X-GITEA-OTP", value);
501 };
502 if let Some(ref apikey) = configuration.api_key {
503 let key = apikey.key.clone();
504 let value = match apikey.prefix {
505 Some(ref prefix) => format!("{} {}", prefix, key),
506 None => key,
507 };
508 req_builder = req_builder.header("Authorization", value);
509 };
510 if let Some(ref apikey) = configuration.api_key {
511 let key = apikey.key.clone();
512 let value = match apikey.prefix {
513 Some(ref prefix) => format!("{} {}", prefix, key),
514 None => key,
515 };
516 req_builder = req_builder.header("Sudo", value);
517 };
518 if let Some(ref auth_conf) = configuration.basic_auth {
519 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
520 };
521
522 let req = req_builder.build()?;
523 let resp = configuration.client.execute(req).await?;
524
525 let status = resp.status();
526 let content_type = resp
527 .headers()
528 .get("content-type")
529 .and_then(|v| v.to_str().ok())
530 .unwrap_or("application/octet-stream");
531 let content_type = super::ContentType::from(content_type);
532
533 if !status.is_client_error() && !status.is_server_error() {
534 let content = resp.text().await?;
535 match content_type {
536 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
537 ContentType::Text => return Ok(content),
538 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
539 }
540 } else {
541 let content = resp.text().await?;
542 let entity: Option<GetSigningKeyError> = serde_json::from_str(&content).ok();
543 Err(Error::ResponseError(ResponseContent { status, content, entity }))
544 }
545}
546
547pub async fn get_signing_key_ssh(configuration: &configuration::Configuration, ) -> Result<String, Error<GetSigningKeySshError>> {
548
549 let uri_str = format!("{}/signing-key.pub", configuration.base_path);
550 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
551
552 if let Some(ref apikey) = configuration.api_key {
553 let key = apikey.key.clone();
554 let value = match apikey.prefix {
555 Some(ref prefix) => format!("{} {}", prefix, key),
556 None => key,
557 };
558 req_builder = req_builder.query(&[("access_token", value)]);
559 }
560 if let Some(ref apikey) = configuration.api_key {
561 let key = apikey.key.clone();
562 let value = match apikey.prefix {
563 Some(ref prefix) => format!("{} {}", prefix, key),
564 None => key,
565 };
566 req_builder = req_builder.query(&[("sudo", value)]);
567 }
568 if let Some(ref apikey) = configuration.api_key {
569 let key = apikey.key.clone();
570 let value = match apikey.prefix {
571 Some(ref prefix) => format!("{} {}", prefix, key),
572 None => key,
573 };
574 req_builder = req_builder.query(&[("token", value)]);
575 }
576 if let Some(ref user_agent) = configuration.user_agent {
577 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
578 }
579 if let Some(ref apikey) = configuration.api_key {
580 let key = apikey.key.clone();
581 let value = match apikey.prefix {
582 Some(ref prefix) => format!("{} {}", prefix, key),
583 None => key,
584 };
585 req_builder = req_builder.header("X-GITEA-OTP", value);
586 };
587 if let Some(ref apikey) = configuration.api_key {
588 let key = apikey.key.clone();
589 let value = match apikey.prefix {
590 Some(ref prefix) => format!("{} {}", prefix, key),
591 None => key,
592 };
593 req_builder = req_builder.header("Authorization", value);
594 };
595 if let Some(ref apikey) = configuration.api_key {
596 let key = apikey.key.clone();
597 let value = match apikey.prefix {
598 Some(ref prefix) => format!("{} {}", prefix, key),
599 None => key,
600 };
601 req_builder = req_builder.header("Sudo", value);
602 };
603 if let Some(ref auth_conf) = configuration.basic_auth {
604 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
605 };
606
607 let req = req_builder.build()?;
608 let resp = configuration.client.execute(req).await?;
609
610 let status = resp.status();
611 let content_type = resp
612 .headers()
613 .get("content-type")
614 .and_then(|v| v.to_str().ok())
615 .unwrap_or("application/octet-stream");
616 let content_type = super::ContentType::from(content_type);
617
618 if !status.is_client_error() && !status.is_server_error() {
619 let content = resp.text().await?;
620 match content_type {
621 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
622 ContentType::Text => return Ok(content),
623 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
624 }
625 } else {
626 let content = resp.text().await?;
627 let entity: Option<GetSigningKeySshError> = serde_json::from_str(&content).ok();
628 Err(Error::ResponseError(ResponseContent { status, content, entity }))
629 }
630}
631
632pub async fn get_version(configuration: &configuration::Configuration, ) -> Result<models::ServerVersion, Error<GetVersionError>> {
633
634 let uri_str = format!("{}/version", configuration.base_path);
635 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
636
637 if let Some(ref apikey) = configuration.api_key {
638 let key = apikey.key.clone();
639 let value = match apikey.prefix {
640 Some(ref prefix) => format!("{} {}", prefix, key),
641 None => key,
642 };
643 req_builder = req_builder.query(&[("access_token", value)]);
644 }
645 if let Some(ref apikey) = configuration.api_key {
646 let key = apikey.key.clone();
647 let value = match apikey.prefix {
648 Some(ref prefix) => format!("{} {}", prefix, key),
649 None => key,
650 };
651 req_builder = req_builder.query(&[("sudo", value)]);
652 }
653 if let Some(ref apikey) = configuration.api_key {
654 let key = apikey.key.clone();
655 let value = match apikey.prefix {
656 Some(ref prefix) => format!("{} {}", prefix, key),
657 None => key,
658 };
659 req_builder = req_builder.query(&[("token", value)]);
660 }
661 if let Some(ref user_agent) = configuration.user_agent {
662 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
663 }
664 if let Some(ref apikey) = configuration.api_key {
665 let key = apikey.key.clone();
666 let value = match apikey.prefix {
667 Some(ref prefix) => format!("{} {}", prefix, key),
668 None => key,
669 };
670 req_builder = req_builder.header("X-GITEA-OTP", value);
671 };
672 if let Some(ref apikey) = configuration.api_key {
673 let key = apikey.key.clone();
674 let value = match apikey.prefix {
675 Some(ref prefix) => format!("{} {}", prefix, key),
676 None => key,
677 };
678 req_builder = req_builder.header("Authorization", value);
679 };
680 if let Some(ref apikey) = configuration.api_key {
681 let key = apikey.key.clone();
682 let value = match apikey.prefix {
683 Some(ref prefix) => format!("{} {}", prefix, key),
684 None => key,
685 };
686 req_builder = req_builder.header("Sudo", value);
687 };
688 if let Some(ref auth_conf) = configuration.basic_auth {
689 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
690 };
691
692 let req = req_builder.build()?;
693 let resp = configuration.client.execute(req).await?;
694
695 let status = resp.status();
696 let content_type = resp
697 .headers()
698 .get("content-type")
699 .and_then(|v| v.to_str().ok())
700 .unwrap_or("application/octet-stream");
701 let content_type = super::ContentType::from(content_type);
702
703 if !status.is_client_error() && !status.is_server_error() {
704 let content = resp.text().await?;
705 match content_type {
706 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
707 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServerVersion`"))),
708 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServerVersion`")))),
709 }
710 } else {
711 let content = resp.text().await?;
712 let entity: Option<GetVersionError> = serde_json::from_str(&content).ok();
713 Err(Error::ResponseError(ResponseContent { status, content, entity }))
714 }
715}
716
717pub async fn list_gitignores_templates(configuration: &configuration::Configuration, ) -> Result<Vec<String>, Error<ListGitignoresTemplatesError>> {
718
719 let uri_str = format!("{}/gitignore/templates", configuration.base_path);
720 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
721
722 if let Some(ref apikey) = configuration.api_key {
723 let key = apikey.key.clone();
724 let value = match apikey.prefix {
725 Some(ref prefix) => format!("{} {}", prefix, key),
726 None => key,
727 };
728 req_builder = req_builder.query(&[("access_token", value)]);
729 }
730 if let Some(ref apikey) = configuration.api_key {
731 let key = apikey.key.clone();
732 let value = match apikey.prefix {
733 Some(ref prefix) => format!("{} {}", prefix, key),
734 None => key,
735 };
736 req_builder = req_builder.query(&[("sudo", value)]);
737 }
738 if let Some(ref apikey) = configuration.api_key {
739 let key = apikey.key.clone();
740 let value = match apikey.prefix {
741 Some(ref prefix) => format!("{} {}", prefix, key),
742 None => key,
743 };
744 req_builder = req_builder.query(&[("token", value)]);
745 }
746 if let Some(ref user_agent) = configuration.user_agent {
747 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
748 }
749 if let Some(ref apikey) = configuration.api_key {
750 let key = apikey.key.clone();
751 let value = match apikey.prefix {
752 Some(ref prefix) => format!("{} {}", prefix, key),
753 None => key,
754 };
755 req_builder = req_builder.header("X-GITEA-OTP", value);
756 };
757 if let Some(ref apikey) = configuration.api_key {
758 let key = apikey.key.clone();
759 let value = match apikey.prefix {
760 Some(ref prefix) => format!("{} {}", prefix, key),
761 None => key,
762 };
763 req_builder = req_builder.header("Authorization", value);
764 };
765 if let Some(ref apikey) = configuration.api_key {
766 let key = apikey.key.clone();
767 let value = match apikey.prefix {
768 Some(ref prefix) => format!("{} {}", prefix, key),
769 None => key,
770 };
771 req_builder = req_builder.header("Sudo", value);
772 };
773 if let Some(ref auth_conf) = configuration.basic_auth {
774 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
775 };
776
777 let req = req_builder.build()?;
778 let resp = configuration.client.execute(req).await?;
779
780 let status = resp.status();
781 let content_type = resp
782 .headers()
783 .get("content-type")
784 .and_then(|v| v.to_str().ok())
785 .unwrap_or("application/octet-stream");
786 let content_type = super::ContentType::from(content_type);
787
788 if !status.is_client_error() && !status.is_server_error() {
789 let content = resp.text().await?;
790 match content_type {
791 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
792 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<String>`"))),
793 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<String>`")))),
794 }
795 } else {
796 let content = resp.text().await?;
797 let entity: Option<ListGitignoresTemplatesError> = serde_json::from_str(&content).ok();
798 Err(Error::ResponseError(ResponseContent { status, content, entity }))
799 }
800}
801
802pub async fn list_label_templates(configuration: &configuration::Configuration, ) -> Result<Vec<String>, Error<ListLabelTemplatesError>> {
803
804 let uri_str = format!("{}/label/templates", configuration.base_path);
805 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
806
807 if let Some(ref apikey) = configuration.api_key {
808 let key = apikey.key.clone();
809 let value = match apikey.prefix {
810 Some(ref prefix) => format!("{} {}", prefix, key),
811 None => key,
812 };
813 req_builder = req_builder.query(&[("access_token", value)]);
814 }
815 if let Some(ref apikey) = configuration.api_key {
816 let key = apikey.key.clone();
817 let value = match apikey.prefix {
818 Some(ref prefix) => format!("{} {}", prefix, key),
819 None => key,
820 };
821 req_builder = req_builder.query(&[("sudo", value)]);
822 }
823 if let Some(ref apikey) = configuration.api_key {
824 let key = apikey.key.clone();
825 let value = match apikey.prefix {
826 Some(ref prefix) => format!("{} {}", prefix, key),
827 None => key,
828 };
829 req_builder = req_builder.query(&[("token", value)]);
830 }
831 if let Some(ref user_agent) = configuration.user_agent {
832 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
833 }
834 if let Some(ref apikey) = configuration.api_key {
835 let key = apikey.key.clone();
836 let value = match apikey.prefix {
837 Some(ref prefix) => format!("{} {}", prefix, key),
838 None => key,
839 };
840 req_builder = req_builder.header("X-GITEA-OTP", value);
841 };
842 if let Some(ref apikey) = configuration.api_key {
843 let key = apikey.key.clone();
844 let value = match apikey.prefix {
845 Some(ref prefix) => format!("{} {}", prefix, key),
846 None => key,
847 };
848 req_builder = req_builder.header("Authorization", value);
849 };
850 if let Some(ref apikey) = configuration.api_key {
851 let key = apikey.key.clone();
852 let value = match apikey.prefix {
853 Some(ref prefix) => format!("{} {}", prefix, key),
854 None => key,
855 };
856 req_builder = req_builder.header("Sudo", value);
857 };
858 if let Some(ref auth_conf) = configuration.basic_auth {
859 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
860 };
861
862 let req = req_builder.build()?;
863 let resp = configuration.client.execute(req).await?;
864
865 let status = resp.status();
866 let content_type = resp
867 .headers()
868 .get("content-type")
869 .and_then(|v| v.to_str().ok())
870 .unwrap_or("application/octet-stream");
871 let content_type = super::ContentType::from(content_type);
872
873 if !status.is_client_error() && !status.is_server_error() {
874 let content = resp.text().await?;
875 match content_type {
876 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
877 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<String>`"))),
878 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<String>`")))),
879 }
880 } else {
881 let content = resp.text().await?;
882 let entity: Option<ListLabelTemplatesError> = serde_json::from_str(&content).ok();
883 Err(Error::ResponseError(ResponseContent { status, content, entity }))
884 }
885}
886
887pub async fn list_license_templates(configuration: &configuration::Configuration, ) -> Result<Vec<models::LicensesTemplateListEntry>, Error<ListLicenseTemplatesError>> {
888
889 let uri_str = format!("{}/licenses", configuration.base_path);
890 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
891
892 if let Some(ref apikey) = configuration.api_key {
893 let key = apikey.key.clone();
894 let value = match apikey.prefix {
895 Some(ref prefix) => format!("{} {}", prefix, key),
896 None => key,
897 };
898 req_builder = req_builder.query(&[("access_token", value)]);
899 }
900 if let Some(ref apikey) = configuration.api_key {
901 let key = apikey.key.clone();
902 let value = match apikey.prefix {
903 Some(ref prefix) => format!("{} {}", prefix, key),
904 None => key,
905 };
906 req_builder = req_builder.query(&[("sudo", value)]);
907 }
908 if let Some(ref apikey) = configuration.api_key {
909 let key = apikey.key.clone();
910 let value = match apikey.prefix {
911 Some(ref prefix) => format!("{} {}", prefix, key),
912 None => key,
913 };
914 req_builder = req_builder.query(&[("token", value)]);
915 }
916 if let Some(ref user_agent) = configuration.user_agent {
917 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
918 }
919 if let Some(ref apikey) = configuration.api_key {
920 let key = apikey.key.clone();
921 let value = match apikey.prefix {
922 Some(ref prefix) => format!("{} {}", prefix, key),
923 None => key,
924 };
925 req_builder = req_builder.header("X-GITEA-OTP", value);
926 };
927 if let Some(ref apikey) = configuration.api_key {
928 let key = apikey.key.clone();
929 let value = match apikey.prefix {
930 Some(ref prefix) => format!("{} {}", prefix, key),
931 None => key,
932 };
933 req_builder = req_builder.header("Authorization", value);
934 };
935 if let Some(ref apikey) = configuration.api_key {
936 let key = apikey.key.clone();
937 let value = match apikey.prefix {
938 Some(ref prefix) => format!("{} {}", prefix, key),
939 None => key,
940 };
941 req_builder = req_builder.header("Sudo", value);
942 };
943 if let Some(ref auth_conf) = configuration.basic_auth {
944 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
945 };
946
947 let req = req_builder.build()?;
948 let resp = configuration.client.execute(req).await?;
949
950 let status = resp.status();
951 let content_type = resp
952 .headers()
953 .get("content-type")
954 .and_then(|v| v.to_str().ok())
955 .unwrap_or("application/octet-stream");
956 let content_type = super::ContentType::from(content_type);
957
958 if !status.is_client_error() && !status.is_server_error() {
959 let content = resp.text().await?;
960 match content_type {
961 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
962 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::LicensesTemplateListEntry>`"))),
963 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::LicensesTemplateListEntry>`")))),
964 }
965 } else {
966 let content = resp.text().await?;
967 let entity: Option<ListLicenseTemplatesError> = serde_json::from_str(&content).ok();
968 Err(Error::ResponseError(ResponseContent { status, content, entity }))
969 }
970}
971
972pub async fn render_markdown(configuration: &configuration::Configuration, body: Option<models::MarkdownOption>) -> Result<String, Error<RenderMarkdownError>> {
973 let p_body_body = body;
975
976 let uri_str = format!("{}/markdown", configuration.base_path);
977 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
978
979 if let Some(ref apikey) = configuration.api_key {
980 let key = apikey.key.clone();
981 let value = match apikey.prefix {
982 Some(ref prefix) => format!("{} {}", prefix, key),
983 None => key,
984 };
985 req_builder = req_builder.query(&[("access_token", value)]);
986 }
987 if let Some(ref apikey) = configuration.api_key {
988 let key = apikey.key.clone();
989 let value = match apikey.prefix {
990 Some(ref prefix) => format!("{} {}", prefix, key),
991 None => key,
992 };
993 req_builder = req_builder.query(&[("sudo", value)]);
994 }
995 if let Some(ref apikey) = configuration.api_key {
996 let key = apikey.key.clone();
997 let value = match apikey.prefix {
998 Some(ref prefix) => format!("{} {}", prefix, key),
999 None => key,
1000 };
1001 req_builder = req_builder.query(&[("token", value)]);
1002 }
1003 if let Some(ref user_agent) = configuration.user_agent {
1004 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1005 }
1006 if let Some(ref apikey) = configuration.api_key {
1007 let key = apikey.key.clone();
1008 let value = match apikey.prefix {
1009 Some(ref prefix) => format!("{} {}", prefix, key),
1010 None => key,
1011 };
1012 req_builder = req_builder.header("X-GITEA-OTP", value);
1013 };
1014 if let Some(ref apikey) = configuration.api_key {
1015 let key = apikey.key.clone();
1016 let value = match apikey.prefix {
1017 Some(ref prefix) => format!("{} {}", prefix, key),
1018 None => key,
1019 };
1020 req_builder = req_builder.header("Authorization", value);
1021 };
1022 if let Some(ref apikey) = configuration.api_key {
1023 let key = apikey.key.clone();
1024 let value = match apikey.prefix {
1025 Some(ref prefix) => format!("{} {}", prefix, key),
1026 None => key,
1027 };
1028 req_builder = req_builder.header("Sudo", value);
1029 };
1030 if let Some(ref auth_conf) = configuration.basic_auth {
1031 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
1032 };
1033 req_builder = req_builder.json(&p_body_body);
1034
1035 let req = req_builder.build()?;
1036 let resp = configuration.client.execute(req).await?;
1037
1038 let status = resp.status();
1039 let content_type = resp
1040 .headers()
1041 .get("content-type")
1042 .and_then(|v| v.to_str().ok())
1043 .unwrap_or("application/octet-stream");
1044 let content_type = super::ContentType::from(content_type);
1045
1046 if !status.is_client_error() && !status.is_server_error() {
1047 let content = resp.text().await?;
1048 match content_type {
1049 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1050 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
1051 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
1052 }
1053 } else {
1054 let content = resp.text().await?;
1055 let entity: Option<RenderMarkdownError> = serde_json::from_str(&content).ok();
1056 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1057 }
1058}
1059
1060pub async fn render_markdown_raw(configuration: &configuration::Configuration, body: &str) -> Result<String, Error<RenderMarkdownRawError>> {
1061 let p_body_body = body;
1063
1064 let uri_str = format!("{}/markdown/raw", configuration.base_path);
1065 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1066
1067 if let Some(ref apikey) = configuration.api_key {
1068 let key = apikey.key.clone();
1069 let value = match apikey.prefix {
1070 Some(ref prefix) => format!("{} {}", prefix, key),
1071 None => key,
1072 };
1073 req_builder = req_builder.query(&[("access_token", value)]);
1074 }
1075 if let Some(ref apikey) = configuration.api_key {
1076 let key = apikey.key.clone();
1077 let value = match apikey.prefix {
1078 Some(ref prefix) => format!("{} {}", prefix, key),
1079 None => key,
1080 };
1081 req_builder = req_builder.query(&[("sudo", value)]);
1082 }
1083 if let Some(ref apikey) = configuration.api_key {
1084 let key = apikey.key.clone();
1085 let value = match apikey.prefix {
1086 Some(ref prefix) => format!("{} {}", prefix, key),
1087 None => key,
1088 };
1089 req_builder = req_builder.query(&[("token", value)]);
1090 }
1091 if let Some(ref user_agent) = configuration.user_agent {
1092 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1093 }
1094 if let Some(ref apikey) = configuration.api_key {
1095 let key = apikey.key.clone();
1096 let value = match apikey.prefix {
1097 Some(ref prefix) => format!("{} {}", prefix, key),
1098 None => key,
1099 };
1100 req_builder = req_builder.header("X-GITEA-OTP", value);
1101 };
1102 if let Some(ref apikey) = configuration.api_key {
1103 let key = apikey.key.clone();
1104 let value = match apikey.prefix {
1105 Some(ref prefix) => format!("{} {}", prefix, key),
1106 None => key,
1107 };
1108 req_builder = req_builder.header("Authorization", value);
1109 };
1110 if let Some(ref apikey) = configuration.api_key {
1111 let key = apikey.key.clone();
1112 let value = match apikey.prefix {
1113 Some(ref prefix) => format!("{} {}", prefix, key),
1114 None => key,
1115 };
1116 req_builder = req_builder.header("Sudo", value);
1117 };
1118 if let Some(ref auth_conf) = configuration.basic_auth {
1119 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
1120 };
1121 req_builder = req_builder.json(&p_body_body);
1122
1123 let req = req_builder.build()?;
1124 let resp = configuration.client.execute(req).await?;
1125
1126 let status = resp.status();
1127 let content_type = resp
1128 .headers()
1129 .get("content-type")
1130 .and_then(|v| v.to_str().ok())
1131 .unwrap_or("application/octet-stream");
1132 let content_type = super::ContentType::from(content_type);
1133
1134 if !status.is_client_error() && !status.is_server_error() {
1135 let content = resp.text().await?;
1136 match content_type {
1137 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1138 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
1139 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
1140 }
1141 } else {
1142 let content = resp.text().await?;
1143 let entity: Option<RenderMarkdownRawError> = serde_json::from_str(&content).ok();
1144 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1145 }
1146}
1147
1148pub async fn render_markup(configuration: &configuration::Configuration, body: Option<models::MarkupOption>) -> Result<String, Error<RenderMarkupError>> {
1149 let p_body_body = body;
1151
1152 let uri_str = format!("{}/markup", configuration.base_path);
1153 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1154
1155 if let Some(ref apikey) = configuration.api_key {
1156 let key = apikey.key.clone();
1157 let value = match apikey.prefix {
1158 Some(ref prefix) => format!("{} {}", prefix, key),
1159 None => key,
1160 };
1161 req_builder = req_builder.query(&[("access_token", value)]);
1162 }
1163 if let Some(ref apikey) = configuration.api_key {
1164 let key = apikey.key.clone();
1165 let value = match apikey.prefix {
1166 Some(ref prefix) => format!("{} {}", prefix, key),
1167 None => key,
1168 };
1169 req_builder = req_builder.query(&[("sudo", value)]);
1170 }
1171 if let Some(ref apikey) = configuration.api_key {
1172 let key = apikey.key.clone();
1173 let value = match apikey.prefix {
1174 Some(ref prefix) => format!("{} {}", prefix, key),
1175 None => key,
1176 };
1177 req_builder = req_builder.query(&[("token", value)]);
1178 }
1179 if let Some(ref user_agent) = configuration.user_agent {
1180 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1181 }
1182 if let Some(ref apikey) = configuration.api_key {
1183 let key = apikey.key.clone();
1184 let value = match apikey.prefix {
1185 Some(ref prefix) => format!("{} {}", prefix, key),
1186 None => key,
1187 };
1188 req_builder = req_builder.header("X-GITEA-OTP", value);
1189 };
1190 if let Some(ref apikey) = configuration.api_key {
1191 let key = apikey.key.clone();
1192 let value = match apikey.prefix {
1193 Some(ref prefix) => format!("{} {}", prefix, key),
1194 None => key,
1195 };
1196 req_builder = req_builder.header("Authorization", value);
1197 };
1198 if let Some(ref apikey) = configuration.api_key {
1199 let key = apikey.key.clone();
1200 let value = match apikey.prefix {
1201 Some(ref prefix) => format!("{} {}", prefix, key),
1202 None => key,
1203 };
1204 req_builder = req_builder.header("Sudo", value);
1205 };
1206 if let Some(ref auth_conf) = configuration.basic_auth {
1207 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
1208 };
1209 req_builder = req_builder.json(&p_body_body);
1210
1211 let req = req_builder.build()?;
1212 let resp = configuration.client.execute(req).await?;
1213
1214 let status = resp.status();
1215 let content_type = resp
1216 .headers()
1217 .get("content-type")
1218 .and_then(|v| v.to_str().ok())
1219 .unwrap_or("application/octet-stream");
1220 let content_type = super::ContentType::from(content_type);
1221
1222 if !status.is_client_error() && !status.is_server_error() {
1223 let content = resp.text().await?;
1224 match content_type {
1225 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1226 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
1227 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
1228 }
1229 } else {
1230 let content = resp.text().await?;
1231 let entity: Option<RenderMarkupError> = serde_json::from_str(&content).ok();
1232 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1233 }
1234}
1235