Skip to main content

DshApiTenant

Struct DshApiTenant 

Source
pub struct DshApiTenant { /* private fields */ }

Implementations§

Source§

impl DshApiTenant

Source

pub fn new<T>(name: T, platform: DshPlatform) -> Self
where T: Into<String>,

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()
);
Source

pub fn from_tenant<T>(tenant_name: T) -> DshApiResult<Self>
where T: Into<String>,

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());
Source

pub fn from_tenant_and_platform<T>( tenant_name: T, platform: DshPlatform, ) -> DshApiResult<Self>
where T: Into<String>,

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());
Source

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());
Source

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());
Source

pub fn platform(&self) -> &DshPlatform

Returns the client’s platform

Source

pub fn name(&self) -> &String

Returns the client’s tenant name

Trait Implementations§

Source§

impl Clone for DshApiTenant

Source§

fn clone(&self) -> DshApiTenant

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DshApiTenant

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DshApiTenant

Source§

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for DshApiTenant

Source§

fn eq(&self, other: &DshApiTenant) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for DshApiTenant

Source§

fn partial_cmp(&self, other: &DshApiTenant) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for DshApiTenant

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DshApiTenant

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more