Skip to content

Commit b3bd706

Browse files
authored
feat: admin commands to upgrade proj to lb, replica count (#2015)
1 parent ea6a7c6 commit b3bd706

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

admin/src/args.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,29 @@ pub enum Command {
3333
json: String,
3434
},
3535

36+
GetProjectConfig {
37+
/// Project to get config for
38+
#[arg(long, visible_alias = "id")]
39+
project_id: String,
40+
},
41+
42+
/// Upgrade project to use a dedicated load balancer.
43+
UpgradeProjectToLb {
44+
/// Project to upgrade to ALB
45+
#[arg(long, visible_alias = "id")]
46+
project_id: String,
47+
},
48+
49+
/// Update replica count for a project with a dedicated load balancer.
50+
UpdateLbProjectReplicas {
51+
/// Project to update
52+
#[arg(long, visible_alias = "id")]
53+
project_id: String,
54+
/// Replicas to set for the given project
55+
#[arg(long)]
56+
replicas: u8,
57+
},
58+
3659
/// Renew all old custom domain certificates
3760
RenewCerts,
3861

admin/src/client.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,31 @@ impl Client {
4646
.await
4747
}
4848

49+
pub async fn get_project_config(&self, project_id: &str) -> Result<Value> {
50+
self.inner
51+
.get_json(format!("/admin/projects/{project_id}"))
52+
.await
53+
}
54+
55+
pub async fn upgrade_project_to_lb(&self, project_id: &str) -> Result<Value> {
56+
self.inner
57+
.put_json(format!("/admin/projects/{project_id}"), Option::<()>::None)
58+
.await
59+
}
60+
61+
pub async fn update_lb_project_replicas(
62+
&self,
63+
project_id: &str,
64+
replicas: u8,
65+
) -> Result<Value> {
66+
self.inner
67+
.put_json(
68+
format!("/admin/projects/{project_id}/{replicas}"),
69+
Option::<()>::None,
70+
)
71+
.await
72+
}
73+
4974
pub async fn update_project_owner(
5075
&self,
5176
project_id: &str,

admin/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ pub async fn run(args: Args) {
4545
.unwrap();
4646
println!("{res:?}");
4747
}
48+
Command::UpgradeProjectToLb { project_id } => {
49+
let res = client.upgrade_project_to_lb(&project_id).await.unwrap();
50+
println!("{res:#?}");
51+
}
52+
Command::UpdateLbProjectReplicas {
53+
project_id,
54+
replicas,
55+
} => {
56+
let res = client
57+
.update_lb_project_replicas(&project_id, replicas)
58+
.await
59+
.unwrap();
60+
println!("{res:#?}");
61+
}
62+
Command::GetProjectConfig { project_id } => {
63+
let res = client.get_project_config(&project_id).await.unwrap();
64+
println!("{res:#?}");
65+
}
4866
Command::AddFeatureFlag { entity, flag } => {
4967
client.feature_flag(&entity, &flag, true).await.unwrap();
5068
println!("Added flag {flag} for {entity}");

0 commit comments

Comments
 (0)