1#[allow(unused_imports)]
2use progenitor_client::{encode_path, RequestBuilderExt};
3#[allow(unused_imports)]
4pub use progenitor_client::{ByteStream, Error, ResponseValue};
5#[allow(unused_imports)]
6use reqwest::header::{HeaderMap, HeaderValue};
7#[allow(clippy::all)]
9pub mod types {
10 use serde::{Deserialize, Serialize};
11 #[allow(unused_imports)]
12 use std::convert::TryFrom;
13 pub mod error {
15 pub struct ConversionError(std::borrow::Cow<'static, str>);
17 impl std::error::Error for ConversionError {}
18 impl std::fmt::Display for ConversionError {
19 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
20 std::fmt::Display::fmt(&self.0, f)
21 }
22 }
23
24 impl std::fmt::Debug for ConversionError {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
26 std::fmt::Debug::fmt(&self.0, f)
27 }
28 }
29
30 impl From<&'static str> for ConversionError {
31 fn from(value: &'static str) -> Self {
32 Self(value.into())
33 }
34 }
35
36 impl From<String> for ConversionError {
37 fn from(value: String) -> Self {
38 Self(value.into())
39 }
40 }
41 }
42
43 #[derive(Clone, Debug, Deserialize, Serialize)]
69 pub struct CreateListenerInput {
70 pub deployment_id: String,
71 pub mappings: Vec<Mapping>,
72 }
73
74 impl From<&CreateListenerInput> for CreateListenerInput {
75 fn from(value: &CreateListenerInput) -> Self {
76 value.clone()
77 }
78 }
79
80 #[derive(Clone, Debug, Deserialize, Serialize)]
91 pub struct CreateListenerOutput(pub serde_json::Map<String, serde_json::Value>);
92 impl std::ops::Deref for CreateListenerOutput {
93 type Target = serde_json::Map<String, serde_json::Value>;
94 fn deref(&self) -> &serde_json::Map<String, serde_json::Value> {
95 &self.0
96 }
97 }
98
99 impl From<CreateListenerOutput> for serde_json::Map<String, serde_json::Value> {
100 fn from(value: CreateListenerOutput) -> Self {
101 value.0
102 }
103 }
104
105 impl From<&CreateListenerOutput> for CreateListenerOutput {
106 fn from(value: &CreateListenerOutput) -> Self {
107 value.clone()
108 }
109 }
110
111 impl From<serde_json::Map<String, serde_json::Value>> for CreateListenerOutput {
112 fn from(value: serde_json::Map<String, serde_json::Value>) -> Self {
113 Self(value)
114 }
115 }
116
117 #[derive(Clone, Debug, Deserialize, Serialize)]
184 pub struct DeployAwsInput {
185 pub deployment_slug: String,
186 #[serde(default, skip_serializing_if = "Option::is_none")]
187 pub files: Option<Vec<File>>,
188 pub flake_url: String,
189 pub instance_type: String,
190 #[serde(default, skip_serializing_if = "Option::is_none")]
191 pub max_size: Option<i64>,
192 #[serde(default, skip_serializing_if = "Option::is_none")]
193 pub min_size: Option<i64>,
194 pub subdomain_prefix: String,
195 #[serde(default, skip_serializing_if = "Option::is_none")]
196 pub targets: Option<Vec<Target>>,
197 pub template_id: String,
198 }
199
200 impl From<&DeployAwsInput> for DeployAwsInput {
201 fn from(value: &DeployAwsInput) -> Self {
202 value.clone()
203 }
204 }
205
206 #[derive(Clone, Debug, Deserialize, Serialize)]
235 pub struct DeployAwsOutput {
236 pub id: String,
237 pub input: DeployAwsInput,
238 #[serde(default, skip_serializing_if = "Option::is_none")]
239 pub lb_arn: Option<String>,
240 }
241
242 impl From<&DeployAwsOutput> for DeployAwsOutput {
243 fn from(value: &DeployAwsOutput) -> Self {
244 value.clone()
245 }
246 }
247
248 #[derive(Clone, Debug, Deserialize, Serialize)]
271 pub struct File {
272 pub content: String,
273 pub path: String,
274 }
275
276 impl From<&File> for File {
277 fn from(value: &File) -> Self {
278 value.clone()
279 }
280 }
281
282 #[derive(Clone, Debug, Deserialize, Serialize)]
301 pub struct LogInput {
302 pub log: String,
303 }
304
305 impl From<&LogInput> for LogInput {
306 fn from(value: &LogInput) -> Self {
307 value.clone()
308 }
309 }
310
311 #[derive(Clone, Debug, Deserialize, Serialize)]
322 pub struct LogOutput(pub serde_json::Map<String, serde_json::Value>);
323 impl std::ops::Deref for LogOutput {
324 type Target = serde_json::Map<String, serde_json::Value>;
325 fn deref(&self) -> &serde_json::Map<String, serde_json::Value> {
326 &self.0
327 }
328 }
329
330 impl From<LogOutput> for serde_json::Map<String, serde_json::Value> {
331 fn from(value: LogOutput) -> Self {
332 value.0
333 }
334 }
335
336 impl From<&LogOutput> for LogOutput {
337 fn from(value: &LogOutput) -> Self {
338 value.clone()
339 }
340 }
341
342 impl From<serde_json::Map<String, serde_json::Value>> for LogOutput {
343 fn from(value: serde_json::Map<String, serde_json::Value>) -> Self {
344 Self(value)
345 }
346 }
347
348 #[derive(Clone, Debug, Deserialize, Serialize)]
373 pub struct Mapping {
374 pub listener_port: i64,
375 pub target_port: i64,
376 }
377
378 impl From<&Mapping> for Mapping {
379 fn from(value: &Mapping) -> Self {
380 value.clone()
381 }
382 }
383
384 #[derive(Clone, Debug, Deserialize, Serialize)]
416 pub struct Target {
417 #[serde(default, skip_serializing_if = "Option::is_none")]
418 pub health_check_enabled: Option<bool>,
419 #[serde(default, skip_serializing_if = "Option::is_none")]
420 pub health_check_path: Option<String>,
421 pub port: i64,
422 }
423
424 impl From<&Target> for Target {
425 fn from(value: &Target) -> Self {
426 value.clone()
427 }
428 }
429}
430
431#[derive(Clone, Debug)]
432pub struct Client {
436 pub(crate) baseurl: String,
437 pub(crate) client: reqwest::Client,
438}
439
440impl Client {
441 pub fn new(baseurl: &str) -> Self {
447 #[cfg(not(target_arch = "wasm32"))]
448 let client = {
449 let dur = std::time::Duration::from_secs(15);
450 reqwest::ClientBuilder::new()
451 .connect_timeout(dur)
452 .timeout(dur)
453 };
454 #[cfg(target_arch = "wasm32")]
455 let client = reqwest::ClientBuilder::new();
456 Self::new_with_client(baseurl, client.build().unwrap())
457 }
458
459 pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self {
466 Self {
467 baseurl: baseurl.to_string(),
468 client,
469 }
470 }
471
472 pub fn baseurl(&self) -> &String {
474 &self.baseurl
475 }
476
477 pub fn client(&self) -> &reqwest::Client {
479 &self.client
480 }
481
482 pub fn api_version(&self) -> &'static str {
487 "0.1.0"
488 }
489}
490
491#[allow(clippy::all)]
492impl Client {
493 pub async fn handlers_deploy_deploy_aws_create<'a>(
499 &'a self,
500 body: &'a types::DeployAwsInput,
501 ) -> Result<ResponseValue<types::DeployAwsOutput>, Error<()>> {
502 let url = format!("{}/deploy/aws/create", self.baseurl,);
503 #[allow(unused_mut)]
504 let mut request = self
505 .client
506 .post(url)
507 .header(
508 reqwest::header::ACCEPT,
509 reqwest::header::HeaderValue::from_static("application/json"),
510 )
511 .json(&body)
512 .build()?;
513 let result = self.client.execute(request).await;
514 let response = result?;
515 match response.status().as_u16() {
516 200u16 => ResponseValue::from_response(response).await,
517 400u16 => Err(Error::ErrorResponse(ResponseValue::empty(response))),
518 404u16 => Err(Error::ErrorResponse(ResponseValue::empty(response))),
519 422u16 => Err(Error::ErrorResponse(ResponseValue::empty(response))),
520 500u16 => Err(Error::ErrorResponse(ResponseValue::empty(response))),
521 _ => Err(Error::UnexpectedResponse(response)),
522 }
523 }
524
525 pub async fn handlers_log_log<'a>(
531 &'a self,
532 body: &'a types::LogInput,
533 ) -> Result<ResponseValue<types::LogOutput>, Error<()>> {
534 let url = format!("{}/log", self.baseurl,);
535 #[allow(unused_mut)]
536 let mut request = self
537 .client
538 .post(url)
539 .header(
540 reqwest::header::ACCEPT,
541 reqwest::header::HeaderValue::from_static("application/json"),
542 )
543 .json(&body)
544 .build()?;
545 let result = self.client.execute(request).await;
546 let response = result?;
547 match response.status().as_u16() {
548 200u16 => ResponseValue::from_response(response).await,
549 400u16 => Err(Error::ErrorResponse(ResponseValue::empty(response))),
550 404u16 => Err(Error::ErrorResponse(ResponseValue::empty(response))),
551 422u16 => Err(Error::ErrorResponse(ResponseValue::empty(response))),
552 500u16 => Err(Error::ErrorResponse(ResponseValue::empty(response))),
553 _ => Err(Error::UnexpectedResponse(response)),
554 }
555 }
556
557 pub async fn handlers_create_listener_create_listener<'a>(
559 &'a self,
560 body: &'a types::CreateListenerInput,
561 ) -> Result<ResponseValue<types::CreateListenerOutput>, Error<()>> {
562 let url = format!("{}/create-listener", self.baseurl,);
563 #[allow(unused_mut)]
564 let mut request = self
565 .client
566 .post(url)
567 .header(
568 reqwest::header::ACCEPT,
569 reqwest::header::HeaderValue::from_static("application/json"),
570 )
571 .json(&body)
572 .build()?;
573 let result = self.client.execute(request).await;
574 let response = result?;
575 match response.status().as_u16() {
576 200u16 => ResponseValue::from_response(response).await,
577 400u16 => Err(Error::ErrorResponse(ResponseValue::empty(response))),
578 404u16 => Err(Error::ErrorResponse(ResponseValue::empty(response))),
579 422u16 => Err(Error::ErrorResponse(ResponseValue::empty(response))),
580 500u16 => Err(Error::ErrorResponse(ResponseValue::empty(response))),
581 _ => Err(Error::UnexpectedResponse(response)),
582 }
583 }
584}
585
586pub mod prelude {
588 #[allow(unused_imports)]
589 pub use super::Client;
590}