pub trait ClientConfigExt {
// Required methods
fn from_env<'life0, 'async_trait>(
platform: Platform,
environment_variables: &'life0 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: Sized + 'async_trait,
'life0: 'async_trait;
fn from_std_env<'async_trait>(
platform: Platform,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: Sized + 'async_trait;
fn platform(&self) -> Platform;
fn impersonate<'life0, 'async_trait>(
&'life0 self,
config: ImpersonationConfig,
) -> Pin<Box<dyn Future<Output = Result<ClientConfig>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Extension trait for ClientConfig providing environment-based configuration and cloud-agnostic impersonation
Required Methods§
Sourcefn from_env<'life0, 'async_trait>(
platform: Platform,
environment_variables: &'life0 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
'life0: 'async_trait,
fn from_env<'life0, 'async_trait>(
platform: Platform,
environment_variables: &'life0 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
'life0: 'async_trait,
Create a platform configuration from environment variables based on the specified platform.
§Examples
use alien_client_config::{ClientConfigExt};
use alien_core::{ClientConfig, Platform};
use std::collections::HashMap;
let env_vars: HashMap<String, String> = std::env::vars().collect();
let aws_config = ClientConfig::from_env(Platform::Aws, &env_vars).await?;
let gcp_config = ClientConfig::from_env(Platform::Gcp, &env_vars).await?;
let azure_config = ClientConfig::from_env(Platform::Azure, &env_vars).await?;Sourcefn from_std_env<'async_trait>(
platform: Platform,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
fn from_std_env<'async_trait>(
platform: Platform,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
Create a platform configuration from standard environment variables based on the specified platform.
§Examples
use alien_client_config::{ClientConfigExt};
use alien_core::{ClientConfig, Platform};
let aws_config = ClientConfig::from_std_env(Platform::Aws).await?;
let gcp_config = ClientConfig::from_std_env(Platform::Gcp).await?;
let azure_config = ClientConfig::from_std_env(Platform::Azure).await?;Sourcefn impersonate<'life0, 'async_trait>(
&'life0 self,
config: ImpersonationConfig,
) -> Pin<Box<dyn Future<Output = Result<ClientConfig>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn impersonate<'life0, 'async_trait>(
&'life0 self,
config: ImpersonationConfig,
) -> Pin<Box<dyn Future<Output = Result<ClientConfig>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Cloud-agnostic impersonation method
§Examples
use alien_client_config::{ClientConfigExt};
use alien_core::{ClientConfig, ImpersonationConfig, AwsImpersonationConfig};
let impersonation = ImpersonationConfig::Aws(AwsImpersonationConfig {
role_arn: "arn:aws:iam::123456789012:role/MyRole".to_string(),
session_name: None,
duration_seconds: Some(3600),
external_id: None,
});
let impersonated_config = aws_config.impersonate(impersonation).await?;