Skip to content

Commit cb7ddbe

Browse files
authored
feat: admin command to update scaling config (#2019)
1 parent f038c5d commit cb7ddbe

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

admin/src/args.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use clap::{Parser, Subcommand};
2-
use shuttle_common::{constants::SHUTTLE_API_URL, models::user::AccountTier};
2+
use shuttle_common::{
3+
constants::SHUTTLE_API_URL,
4+
models::{project::ComputeTier, user::AccountTier},
5+
};
36

47
#[derive(Parser, Debug)]
58
pub struct Args {
@@ -46,14 +49,17 @@ pub enum Command {
4649
project_id: String,
4750
},
4851

49-
/// Update replica count for a project with a dedicated load balancer.
50-
UpdateLbProjectReplicas {
52+
/// Update compute tier for a given project.
53+
UpdateProjectScale {
5154
/// Project to update
5255
#[arg(long, visible_alias = "id")]
5356
project_id: String,
54-
/// Replicas to set for the given project
57+
/// Compute tier to set for the given project
58+
#[arg(long, visible_alias = "tier")]
59+
compute_tier: Option<ComputeTier>,
60+
/// Replica count to set for the given project
5561
#[arg(long)]
56-
replicas: u8,
62+
replicas: Option<u8>,
5763
},
5864

5965
/// Renew all old custom domain certificates

admin/src/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ impl Client {
5858
.await
5959
}
6060

61-
pub async fn update_lb_project_replicas(
61+
pub async fn update_project_scale(
6262
&self,
6363
project_id: &str,
64-
replicas: u8,
64+
update_config: &Value,
6565
) -> Result<Value> {
6666
self.inner
6767
.put_json(
68-
format!("/admin/projects/{project_id}/{replicas}"),
69-
Option::<()>::None,
68+
format!("/admin/projects/{project_id}/scale"),
69+
Some(update_config),
7070
)
7171
.await
7272
}

admin/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,15 @@ pub async fn run(args: Args) {
5252
let res = client.upgrade_project_to_lb(&project_id).await.unwrap();
5353
println!("{res:#?}");
5454
}
55-
Command::UpdateLbProjectReplicas {
55+
Command::UpdateProjectScale {
5656
project_id,
57+
compute_tier,
5758
replicas,
5859
} => {
60+
let update_config =
61+
serde_json::json!({"compute_tier": compute_tier, "replicas": replicas});
5962
let res = client
60-
.update_lb_project_replicas(&project_id, replicas)
63+
.update_project_scale(&project_id, &update_config)
6164
.await
6265
.unwrap();
6366
println!("{res:#?}");

0 commit comments

Comments
 (0)