pub struct FormationsReq { /* private fields */ }Expand description
Wraps an SDK FormationsRequest where we do additional things like re-use request access
tokens, allow changing the Formation this request is pointed to, and map errors appropriately.
Implementations§
Source§impl FormationsReq
impl FormationsReq
Sourcepub fn new<S: Into<String>>(ctx: &Ctx, name: Option<S>) -> Result<Self>
pub fn new<S: Into<String>>(ctx: &Ctx, name: Option<S>) -> Result<Self>
Builds a FormationsRequest and immediately requests an access token using the given API key.
If the name is None it should be noted that the only request that can be made without
error is FormationsRequest::list_names
Sourcepub fn new_delay_token(ctx: &Ctx) -> Result<Self>
pub fn new_delay_token(ctx: &Ctx) -> Result<Self>
Builds a FormationsRequest but does not request an access token using the given API key.
You must call refresh_token to have the access token requested.
Sourcepub fn refresh_token(&mut self) -> Result<()>
pub fn refresh_token(&mut self) -> Result<()>
Request a new Access Token
Sourcepub fn token_or_refresh(&mut self) -> Result<&str>
pub fn token_or_refresh(&mut self) -> Result<&str>
Retrieves the JWT access token, requesting a new one if required.
Sourcepub fn set_name<S: Into<String>>(&mut self, name: S) -> Result<()>
pub fn set_name<S: Into<String>>(&mut self, name: S) -> Result<()>
Sets the Formation name and re-builds the inner FormationsRequest also requesting a new access token if required
Sourcepub fn get_all_formations<S: AsRef<str>>(
&mut self,
formation_names: &[S],
pb: &Pb,
) -> Result<Formations>
pub fn get_all_formations<S: AsRef<str>>( &mut self, formation_names: &[S], pb: &Pb, ) -> Result<Formations>
Retrieves all Formations and their Formation Configurations (both active and inactive) from
the Compute API. Makes multiple calls against the API to gather the info and returns a
Formations struct.
It should be noted that the local IDs associated with all the items in the Formations struct are generated unique after retrieval from the compute API. i.e. they do not match anything existing in the local DB even if the contents are otherwise identical.
Sourcepub fn get_formation_names(&mut self) -> Result<Vec<String>>
pub fn get_formation_names(&mut self) -> Result<Vec<String>>
Return a Vec of all known formation names if this FormationsReq currently has no name
associated with it. Otherwise it returns the single name associated with this
FormationsReq (returned in a Vec). This is used when the CLI supports either doing
something to all formations, or just a single one that is passed in by the user.