Skip to content
Clone
538d47b
46 lines 1.7 KB Rust
use crate::AuthSvc;
use crate::internal::context::RequestMeta;
use tonic::{Request, Response, Status};
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::internal());
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::internal());
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::internal());
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::internal());
self.api.revoke_ssh_key(request).await
}
}