bios_sdk_invoke/clients/
iam_client.rs1use std::collections::{HashMap, HashSet};
2
3use serde::{Deserialize, Serialize};
4use tardis::{basic::dto::TardisContext, web::poem_openapi, TardisFunsInst};
5
6use crate::impl_tardis_api_client;
7
8use super::SimpleInvokeClient;
9
10#[derive(Clone)]
11pub struct IamClient<'a> {
12 pub funs: &'a TardisFunsInst,
13 pub ctx: &'a TardisContext,
14 pub account: &'a str,
15 pub base_url: &'a str,
16}
17
18impl<'a> IamClient<'a> {
19 pub fn new(account: &'a str, funs: &'a TardisFunsInst, ctx: &'a TardisContext, url: &'a str) -> Self {
20 Self {
21 funs,
22 ctx,
23 account,
24 base_url: url,
25 }
26 }
27}
28impl<'a> SimpleInvokeClient for IamClient<'a> {
29 const DOMAIN_CODE: &'static str = "iam";
30 fn get_ctx(&self) -> &'a TardisContext {
31 self.ctx
32 }
33
34 fn get_base_url(&self) -> &str {
35 self.base_url
36 }
37
38 fn get_funs(&self) -> &tardis::TardisFunsInst {
39 self.funs
40 }
41}
42
43#[derive(poem_openapi::Object, Serialize, Deserialize, Debug)]
44pub struct IamAccountDetailAggResp {
45 pub owner_name: Option<String>,
46 pub roles: HashMap<String, String>,
47 pub certs: HashMap<String, String>,
48 pub orgs: Vec<String>,
49}
50
51#[derive(poem_openapi::Object, Serialize, Deserialize, Debug)]
52pub struct IamCertDecodeRequest {
53 pub codes: HashSet<String>,
54}
55
56impl_tardis_api_client! {
57 IamClient<'_>:
58 {get_account, get ["/ct/account", id] {tenant_id} IamAccountDetailAggResp}
59 {batch_decode_cert, post ["/ci/cert/decode"] IamCertDecodeRequest => HashMap<String, String>}
60}