Skip to content

Commit

Permalink
iam-ci: add api get_cert_by_id (#648)
Browse files Browse the repository at this point in the history
* iam: api update

* iam-ci: add api get_cert_by_id
  • Loading branch information
ZzIsGod1019 authored Mar 20, 2024
1 parent bece80f commit 542f9c9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion support/iam/src/console_interface/api/iam_ci_cert_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use crate::console_interface::serv::iam_ci_oauth2_token_serv::IamCiOauth2AkSkSer
use crate::iam_constants;
use crate::iam_enumeration::Oauth2GrantType;
use bios_basic::helper::request_helper::add_remote_ip;
use bios_basic::rbum::dto::rbum_cert_dto::RbumCertSummaryWithSkResp;
use bios_basic::rbum::dto::rbum_cert_dto::{RbumCertSummaryResp, RbumCertSummaryWithSkResp};
use bios_basic::rbum::dto::rbum_filer_dto::RbumCertFilterReq;
use tardis::basic::dto::TardisContext;
use tardis::basic::error::TardisError;
use tardis::web::context_extractor::TardisContextExtractor;
Expand Down Expand Up @@ -72,6 +73,26 @@ impl IamCiCertManageApi {

#[poem_openapi::OpenApi(prefix_path = "/ci/cert", tag = "bios_basic::ApiTag::Interface")]
impl IamCiCertApi {
#[oai(path = "/get/:id", method = "get")]
async fn get_cert_by_id(&self, id: Path<String>, ctx: TardisContextExtractor, request: &Request) -> TardisApiResult<RbumCertSummaryResp> {
add_remote_ip(request, &ctx.0).await?;
let funs = iam_constants::get_tardis_inst();
let result = IamCertServ::find_certs(
&RbumCertFilterReq {
id: Some(id.0),
..Default::default()
},
None,
None,
&funs,
&ctx.0,
)
.await?
.pop()
.ok_or_else(|| funs.err().internal_error("iam_ci_cert", "get_cert_by_id", "cert is not found", "401-iam-cert-code-not-exist"))?;
ctx.0.execute_task().await?;
TardisResp::ok(result)
}
/// Find Cert By Kind And Supplier
///
/// if kind is none,query default kind(UserPwd)
Expand Down
2 changes: 1 addition & 1 deletion support/iam/src/console_interface/api/iam_ci_role_api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use itertools::Itertools;
use crate::basic::dto::iam_role_dto::IamRoleRelAccountCertResp;
use itertools::Itertools;

use crate::basic::serv::iam_app_serv::IamAppServ;
use crate::basic::serv::iam_cert_serv::IamCertServ;
Expand Down

0 comments on commit 542f9c9

Please sign in to comment.