pub enum Endpoint {
Account,
Mock(MockBase),
}Expand description
Which UpCloud answers. Built only by Endpoint::account (refuses in a
mock-carrying shell) or Endpoint::mock (refuses anything off loopback).
Variants§
Account
https://api.upcloud.com/1.3. Real machines, a real bill.
Mock(MockBase)
A mock-upcloud on loopback. The base always ends /1.3.
Implementations§
Source§impl Endpoint
impl Endpoint
Sourcepub fn account() -> Result<Endpoint, String>
pub fn account() -> Result<Endpoint, String>
The account — unless the shell carries a mock variable, in which case the
run does not start. An operator who exported MOCK_BASE_ENV for a fake
run and then typed a real verb in the same shell used to get writes to the
account from some clients and to the fake from others.
Sourcepub fn account_given(
env: impl Fn(&str) -> Option<String>,
) -> Result<Endpoint, String>
pub fn account_given( env: impl Fn(&str) -> Option<String>, ) -> Result<Endpoint, String>
Endpoint::account over an injected environment, for tests.
Sourcepub fn mock(base: &str) -> Result<Endpoint, String>
pub fn mock(base: &str) -> Result<Endpoint, String>
A mock-upcloud at base. Loopback or nothing: a fake that can be
pointed off this machine is a fake that can be pointed at something real.
http://127.0.0.1:8099 and http://127.0.0.1:8099/1.3 are the same door.
Sourcepub fn mock_from_env() -> Result<Endpoint, String>
pub fn mock_from_env() -> Result<Endpoint, String>
A mock from MOCK_BASE_ENV, for a run that has ALREADY been selected
as a mock run by what the operator typed. Unset is a refusal by name.
pub fn is_account(&self) -> bool
Sourcepub fn base_for_display(&self) -> &str
pub fn base_for_display(&self) -> &str
Where /… goes — for a report. Never build a request from it; hold an
implementation from connect instead.
The one line that goes at the top of anything a person might read as a measurement of the account.
Sourcepub fn child_args(&self) -> Vec<String>
pub fn child_args(&self) -> Vec<String>
The argv a parent hands a CHILD process so the child makes the same
choice: ["--mock-api", base] for a mock, nothing for the account. A
child that receives nothing and finds a mock variable in its environment
refuses (Endpoint::account) — which is how the choice cannot be lost
crossing a process boundary.