Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Update server creation endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Oct 14, 2024
1 parent 0c17663 commit e0e5c19
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/models/v3/billing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ pub struct Product {
#[serde(tag = "type", rename_all = "kebab-case")]
pub enum ProductMetadata {
Midas,
Pyro { ram: u32 },
Pyro {
cpu: u32,
ram: u32,
swap: u32,
storage: u32,
},
}

#[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
Expand Down
12 changes: 9 additions & 3 deletions src/routes/internal/billing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,12 @@ pub async fn stripe_webhook(
.execute(&mut *transaction)
.await?;
}
ProductMetadata::Pyro { ram } => {
ProductMetadata::Pyro {
ram,
cpu,
swap,
storage,
} => {
if let Some(ref subscription) = metadata.user_subscription_item {
let client = reqwest::Client::new();

Expand Down Expand Up @@ -1327,8 +1332,9 @@ pub async fn stripe_webhook(
"name": server_name,
"specs": {
"memory_mb": ram,
"cpu": std::cmp::max(2, (ram / 1024) / 2),
"swap_mb": ram / 4,
"cpu": cpu,
"swap_mb": swap,
"storage_mb": storage,
},
"source": source,
}))
Expand Down

0 comments on commit e0e5c19

Please sign in to comment.