Skip to content

Commit ea6a7c6

Browse files
authored
feat: admin command to change project owner (#2013)
1 parent 68b4b06 commit ea6a7c6

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

admin/src/args.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ pub struct Args {
1818
#[derive(Subcommand, Debug)]
1919
pub enum Command {
2020
ChangeProjectOwner {
21-
project_name: String,
21+
/// Project to update ownership of
22+
project_id: String,
23+
/// User id to switch ownership to
2224
new_user_id: String,
2325
},
2426

admin/src/client.rs

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

49+
pub async fn update_project_owner(
50+
&self,
51+
project_id: &str,
52+
user_id: String,
53+
) -> Result<ProjectResponse> {
54+
self.inner
55+
.put_json(
56+
format!("/projects/{project_id}"),
57+
Some(ProjectUpdateRequest {
58+
user_id: Some(user_id),
59+
..Default::default()
60+
}),
61+
)
62+
.await
63+
}
64+
4965
pub async fn feature_flag(&self, entity: &str, flag: &str, set: bool) -> Result<()> {
5066
let resp = if set {
5167
self.inner

admin/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ pub async fn run(args: Args) {
1717
let client = Client::new(args.api_url.clone(), api_key, args.client_timeout);
1818

1919
match args.command {
20-
Command::ChangeProjectOwner { .. } => {
21-
unimplemented!();
20+
Command::ChangeProjectOwner {
21+
project_id,
22+
new_user_id,
23+
} => {
24+
let res = client
25+
.update_project_owner(&project_id, new_user_id)
26+
.await
27+
.unwrap();
28+
println!("{res:?}");
2229
}
2330
Command::RenewCerts => {
2431
let certs = client.get_old_certificates().await.unwrap();

0 commit comments

Comments
 (0)