pub struct DshApiTenant { /* private fields */ }Implementations§
Source§impl DshApiTenant
impl DshApiTenant
Sourcepub fn new<T>(name: T, platform: DshPlatform) -> Self
pub fn new<T>(name: T, platform: DshPlatform) -> Self
Create new DSH API tenant.
§Parameters
name- Client tenant’s name.platform- Target platform for the API.
§Examples
let name = "my-tenant";
let platform = DshPlatform::try_from("nplz")?;
let dsh_api_tenant = DshApiTenant::new(name, platform);
assert_eq!(
dsh_api_tenant.platform().internal_domain("my-tenant"),
"my-tenant.marathon.mesos".to_string()
);Sourcepub fn from_tenant<T>(tenant_name: T) -> DshApiResult<Self>
pub fn from_tenant<T>(tenant_name: T) -> DshApiResult<Self>
Create new DSH API tenant from tenant’s name.
This factory function will attempt to create a DshapiTenant instance from the provided
tenant’s name.
The platform will be read from the
environment variable DSH_API_PLATFORM.
The function will return an Error<String> if the environment variables are not set
or contains illegal values.
§Parameters
tenant_name- Tenant’s name.
§Returns
Ok(tenant)- Tenant struct.Err(error)- Configuration error.
§Examples
let tenant_name = "my-tenant";
let dsh_api_tenant = DshApiTenant::from_tenant(tenant_name)?;
println!("target platform: {}", dsh_api_tenant.platform());Sourcepub fn from_tenant_and_platform<T>(
tenant_name: T,
platform: DshPlatform,
) -> DshApiResult<Self>
pub fn from_tenant_and_platform<T>( tenant_name: T, platform: DshPlatform, ) -> DshApiResult<Self>
Create new DSH API tenant from tenant’s name and platform.
This factory function will attempt to create a DshapiTenant instance from the provided
tenant’s name.
The function will return an Error<String> if the environment variable is not set.
§Parameters
tenant_name- Tenant’s name.platform- Target platform for the API.
§Returns
Ok(tenant)- Tenant struct.Err(error)- Configuration error.
§Examples
let tenant_name = String::from("my-tenant");
let platform = DshPlatform::try_from("nplz")?;
let dsh_api_tenant = DshApiTenant::from_tenant_and_platform(tenant_name, platform)?;
println!("{}@{}", dsh_api_tenant.name(), dsh_api_tenant.platform());Sourcepub fn from_platform(platform: DshPlatform) -> DshApiResult<Self>
pub fn from_platform(platform: DshPlatform) -> DshApiResult<Self>
Create new DSH API tenant from platform.
This factory function will attempt to create a DshapiTenant instance from the provided
platform. The tenant’s name will be read from the environment variable.
The function will return an Error<String> if the environment variables are not set.
§Parameters
platform- Target platform for the API
§Returns
Ok(tenant)- Tenant struct.Err(error)- Configuration error.
§Examples
let platform = DshPlatform::try_from("nplz")?;
let dsh_api_tenant = DshApiTenant::from_platform(platform)?;
println!("{}@{}", dsh_api_tenant.name(), dsh_api_tenant.platform());Sourcepub fn try_default() -> DshApiResult<Self>
pub fn try_default() -> DshApiResult<Self>
Returns the default tenant
This method will read the tenant name and platform form the respective
environment variables and will create aDshApiTenant if possible. It will return an
Error<String> when one or more of these the environment variables is not set or
contains an undefined value.
§Returns
Ok<tenant>- When the environment variables are provided and contain valid values.Error<String>- when one or more of the environment variables is not set or contains an undefined value
§Examples
let default_tenant = DshApiTenant::try_default()?;
println!("{}@{}", default_tenant.name(), default_tenant.platform());Sourcepub fn platform(&self) -> &DshPlatform
pub fn platform(&self) -> &DshPlatform
Returns the client’s platform
Trait Implementations§
Source§impl Clone for DshApiTenant
impl Clone for DshApiTenant
Source§fn clone(&self) -> DshApiTenant
fn clone(&self) -> DshApiTenant
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DshApiTenant
impl Debug for DshApiTenant
Source§impl Default for DshApiTenant
impl Default for DshApiTenant
Source§fn default() -> Self
fn default() -> Self
Returns the default tenant
This method will read the tenant name and platform form the respective
environment variables and will create aDshApiTenant if possible.
§Panics
This method will panic if the environment variable is not set or if it contains an invalid platform name.
Source§impl Display for DshApiTenant
impl Display for DshApiTenant
Source§impl PartialEq for DshApiTenant
impl PartialEq for DshApiTenant
Source§fn eq(&self, other: &DshApiTenant) -> bool
fn eq(&self, other: &DshApiTenant) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for DshApiTenant
impl PartialOrd for DshApiTenant
Source§impl Serialize for DshApiTenant
impl Serialize for DshApiTenant
impl StructuralPartialEq for DshApiTenant
Auto Trait Implementations§
impl Freeze for DshApiTenant
impl RefUnwindSafe for DshApiTenant
impl Send for DshApiTenant
impl Sync for DshApiTenant
impl Unpin for DshApiTenant
impl UnsafeUnpin for DshApiTenant
impl UnwindSafe for DshApiTenant
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.