add creation date to admin api tokens

This commit is contained in:
Alex Auvolat
2025-03-12 09:52:39 +01:00
parent 325f79012c
commit 88b4623bf1
5 changed files with 37 additions and 8 deletions
+6
View File
@@ -41,6 +41,7 @@ impl RequestHandler for ListAdminTokensRequest {
0,
GetAdminTokenInfoResponse {
id: None,
created: None,
name: "admin_token (from daemon configuration)".into(),
expiration: None,
expired: false,
@@ -54,6 +55,7 @@ impl RequestHandler for ListAdminTokensRequest {
1,
GetAdminTokenInfoResponse {
id: None,
created: None,
name: "metrics_token (from daemon configuration)".into(),
expiration: None,
expired: false,
@@ -180,6 +182,10 @@ fn admin_token_info_results(token: &AdminApiToken, now: u64) -> GetAdminTokenInf
GetAdminTokenInfoResponse {
id: Some(token.prefix.clone()),
created: Some(
DateTime::from_timestamp_millis(params.created as i64)
.expect("invalid timestamp stored in db"),
),
name: params.name.get().to_string(),
expiration: params.expiration.get().map(|x| {
DateTime::from_timestamp_millis(x as i64).expect("invalid timestamp stored in db")
+2
View File
@@ -314,6 +314,8 @@ pub struct GetAdminTokenInfoRequest {
pub struct GetAdminTokenInfoResponse {
/// Identifier of the admin token (which is also a prefix of the full bearer token)
pub id: Option<String>,
/// Creation date
pub created: Option<chrono::DateTime<chrono::Utc>>,
/// Name of the admin API token
pub name: String,
/// Expiration time and date, formatted according to RFC 3339