163952e
use crate::AuthSvc;
use crate::internal::context::RequestMeta;
use tonic::{Request, Response, Status};
use uuid::Uuid;
use crate::internal::ssh_key::SshKeyApi;
use crate::protos::auth::v1::ssh_key_service_server::SshKeyService;
pub struct SshKeyClient {
api: SshKeyApi,
}
impl SshKeyClient {
pub fn new(service: AuthSvc) -> Self {
Self {
api: SshKeyApi::new(service),
}
}
pub async fn lookup_ssh_key(
&mut self,
mut request: Request<crate::protos::auth::v1::LookupSshKeyRequest>,
) -> Result<Response<crate::protos::auth::v1::LookupSshKeyResponse>, Status> {
request.extensions_mut().insert(RequestMeta {
request_id: Uuid::now_v7().to_string(),
caller_service: "kenapi".to_owned(),
});
self.api.lookup_ssh_key(request).await
}
pub async fn add_ssh_key(
&mut self,
mut request: Request<crate::protos::auth::v1::AddSshKeyRequest>,
) -> Result<Response<crate::protos::auth::v1::AddSshKeyResponse>, Status> {
request.extensions_mut().insert(RequestMeta {
request_id: Uuid::now_v7().to_string(),
caller_service: "kenapi".to_owned(),
});
self.api.add_ssh_key(request).await
}
pub async fn list_user_ssh_keys(
&mut self,
mut request: Request<crate::protos::auth::v1::ListUserSshKeysRequest>,
) -> Result<Response<crate::protos::auth::v1::ListUserSshKeysResponse>, Status> {
request.extensions_mut().insert(RequestMeta {
request_id: Uuid::now_v7().to_string(),
caller_service: "kenapi".to_owned(),
});
self.api.list_user_ssh_keys(request).await
}
pub async fn revoke_ssh_key(
&mut self,
mut request: Request<crate::protos::auth::v1::RevokeSshKeyRequest>,
) -> Result<Response<crate::protos::auth::v1::RevokeSshKeyResponse>, Status> {
request.extensions_mut().insert(RequestMeta {
request_id: Uuid::now_v7().to_string(),
caller_service: "kenapi".to_owned(),
});
self.api.revoke_ssh_key(request).await
}
}