1
0

Credit subscriptions (#4575)

* Implement subscription crediting

* chore: query cache, clippy, fmt

* Improve code, improve query for next open charge

* chore: query cache, clippy, fmt

* Move server ID copy button up

* Node + region crediting

* Make it less ugly

* chore: query cache, clippy, fmt

* Bugfixes

* Fix lint

* Adjust migration

* Adjust migration

* Remove billing change

* Move DEFAULT_CREDIT_EMAIL_MESSAGE to utils.ts

* Lint

* Merge

* bump clickhouse, disable validation

* tombi fmt

* Update cargo lock
This commit is contained in:
François-Xavier Talbot
2025-10-20 18:35:44 +01:00
committed by GitHub
parent 79502a19d6
commit eeed4e572d
22 changed files with 1052 additions and 8 deletions

View File

@@ -72,4 +72,58 @@ impl ArchonClient {
Ok(response.json::<CreateServerResponse>().await?.uuid)
}
pub async fn get_servers_by_hostname(
&self,
hostname: &str,
) -> Result<Vec<String>, reqwest::Error> {
#[derive(Deserialize)]
struct NodeByHostnameResponse {
servers: Vec<NodeServerEntry>,
}
#[derive(Deserialize)]
struct NodeServerEntry {
id: String,
#[allow(dead_code)]
available: Option<bool>,
}
let res = self
.client
.get(format!(
"{}/_internal/nodes/by-hostname/{}",
self.base_url, hostname
))
.header(X_MASTER_KEY, &self.pyro_api_key)
.send()
.await?
.error_for_status()?;
let parsed: NodeByHostnameResponse = res.json().await?;
Ok(parsed.servers.into_iter().map(|s| s.id).collect())
}
pub async fn get_active_servers_by_region(
&self,
region: &str,
) -> Result<Vec<String>, reqwest::Error> {
#[derive(Deserialize)]
struct RegionResponse {
active_servers: Vec<String>,
}
let res = self
.client
.get(format!(
"{}/_internal/nodes/regions/{}",
self.base_url, region
))
.header(X_MASTER_KEY, &self.pyro_api_key)
.send()
.await?
.error_for_status()?;
let parsed: RegionResponse = res.json().await?;
Ok(parsed.active_servers)
}
}