Skip to content

Commit 9718ce7

Browse files
committed
Add get_user_signing_keys
1 parent 56ed512 commit 9718ce7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/gitlab.rs

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::{SshPublicKey, USER_AGENT};
22
use reqwest::{Client, Result, Url};
33
use serde::Deserialize;
44

5+
const API_URL: &str = "https://gitlab.com";
56
const API_ACCEPT_HEADER: &str = "application/json";
67

78
#[derive(Debug, Deserialize, PartialEq, Eq)]
@@ -39,6 +40,14 @@ impl From<ApiSshKey> for SshPublicKey {
3940
}
4041
}
4142

43+
/// Get the signing keys of a user by their username.
44+
pub async fn get_user_signing_keys(user: &str, client: Client) -> Result<Vec<SshPublicKey>> {
45+
let url = format!("{API_URL}api/v4/users/{user}/keys")
46+
.parse()
47+
.unwrap();
48+
get_signing_keys(url, client).await
49+
}
50+
4251
/// Make a GET request to the GitLab API at the given URL and return the signing keys contained in the response.
4352
///
4453
/// # GitLab API documentation

0 commit comments

Comments
 (0)