forked from ideal-world/bios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
874 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
use tardis::{ | ||
basic::{dto::TardisContext, result::TardisResult}, | ||
TardisFuns, | ||
}; | ||
|
||
use crate::invoke_constants::TARDIS_CONTEXT; | ||
|
||
#[cfg(feature = "spi-base")] | ||
mod base_spi_client; | ||
#[cfg(feature = "iam")] | ||
pub mod iam_client; | ||
#[cfg(feature = "spi-kv")] | ||
pub mod spi_kv_client; | ||
#[cfg(feature = "spi-log")] | ||
pub mod spi_log_client; | ||
|
||
pub trait TardisCtxTrait { | ||
fn get_ctx(&self) -> &TardisContext; | ||
fn get_tardis_context(&self) -> TardisResult<(String, String)> { | ||
let ctx = self.get_ctx(); | ||
Ok((TARDIS_CONTEXT.to_string(), TardisFuns::crypto.base64.encode(&TardisFuns::json.obj_to_string(ctx)?))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
pub use bios_iam::basic::dto::iam_account_dto::*; | ||
use tardis::{ | ||
basic::{dto::TardisContext, result::TardisResult}, | ||
TardisFunsInst, | ||
}; | ||
|
||
use super::TardisCtxTrait; | ||
|
||
#[derive(Clone)] | ||
pub struct IamClient<'a> { | ||
pub funs: &'a TardisFunsInst, | ||
pub ctx: &'a TardisContext, | ||
pub account: &'a str, | ||
pub base_url: &'a str, | ||
} | ||
|
||
impl<'a> IamClient<'a> { | ||
pub fn new(account: &'a str, funs: &'a TardisFunsInst, ctx: &'a TardisContext, url: &'a str) -> Self { | ||
Self { | ||
funs, | ||
ctx, | ||
account, | ||
base_url: url, | ||
} | ||
} | ||
} | ||
impl<'a> TardisCtxTrait for IamClient<'a> { | ||
fn get_ctx(&self) -> &'a TardisContext { | ||
self.ctx | ||
} | ||
} | ||
|
||
impl IamClient<'_> { | ||
pub async fn get_account(&self, id: &str, tenant_id: &str) -> TardisResult<IamAccountSummaryAggResp> { | ||
let ctx = self.get_tardis_context()?; | ||
let url = format!( | ||
"{base_url}/{account}/{id}?tenant_id={tenant_id}", | ||
base_url = self.base_url, | ||
account = self.account, | ||
id = id, | ||
tenant_id = tenant_id | ||
); | ||
let resp = self.funs.web_client().get::<IamAccountSummaryAggResp>(&url, Some(vec![ctx])).await?; | ||
let resp_body = resp.body.ok_or_else(|| self.funs.err().internal_error("iam-client", "get_account", "response", "500-iam_client-request_fail"))?; | ||
Ok(resp_body) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
mod clients; | ||
pub mod clients; | ||
pub mod invoke_config; | ||
pub mod invoke_constants; | ||
pub mod invoke_enumeration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.