pub struct HarmontClient { /* private fields */ }Expand description
A configured client for the Harmont Cloud API.
Construct with HarmontClient::new (prod) or
HarmontClient::with_base_url (self-hosted / local dev). The bearer
token is attached to every request via a preconfigured reqwest::Client.
Implementations§
Source§impl HarmontClient
impl HarmontClient
Sourcepub fn with_base_url(token: impl Into<String>, base: impl Into<String>) -> Self
pub fn with_base_url(token: impl Into<String>, base: impl Into<String>) -> Self
Create a client against an explicit base URL.
§Panics
Panics if token contains characters that are invalid for an HTTP
header value (e.g. non-ASCII or control characters).
Source§impl HarmontClient
impl HarmontClient
Sourcepub async fn submit_build(&self, b: NewBuild) -> Result<Build>
pub async fn submit_build(&self, b: NewBuild) -> Result<Build>
Submit a build from a local worktree. Returns the created Build.
Sourcepub async fn get_build(
&self,
org: &str,
pipeline: &str,
number: i64,
) -> Result<Build>
pub async fn get_build( &self, org: &str, pipeline: &str, number: i64, ) -> Result<Build>
Fetch a build by its pipeline-scoped number.
Source§impl HarmontClient
impl HarmontClient
Sourcepub async fn log_token(
&self,
org: &str,
pipeline: &str,
number: i64,
) -> Result<LogToken>
pub async fn log_token( &self, org: &str, pipeline: &str, number: i64, ) -> Result<LogToken>
Mint a build-scoped HMAC log token (authorizes every job in the build).
Sourcepub async fn stream_job_logs(
&self,
log_base: &str,
job_id: Uuid,
token: &str,
) -> Result<impl Stream<Item = Result<LogEvent>>>
pub async fn stream_job_logs( &self, log_base: &str, job_id: Uuid, token: &str, ) -> Result<impl Stream<Item = Result<LogEvent>>>
Stream a single job’s logs until the done event. log_base is the
host serving /v0/jobs/{id}/logs (the web edge, e.g. the API base);
token comes from Self::log_token.
Source§impl HarmontClient
impl HarmontClient
Sourcepub async fn redeem_code(&self, code: &str) -> Result<String>
pub async fn redeem_code(&self, code: &str) -> Result<String>
Redeem a paste code for a bearer token (headless login).
The user obtains the paste code from the SPA (which calls the authed
GET /api/v0/auth/cli/code endpoint while logged in) and types it into
the CLI. Single-use, expires in 5 minutes.
Sourcepub async fn claim_token(&self, nonce: &str) -> Result<String>
pub async fn claim_token(&self, nonce: &str) -> Result<String>
Claim a loopback-parked token by nonce (browser login).
The CLI generates a random nonce, opens the browser to the SPA, and
polls this endpoint until the token appears (the SPA calls the authed
POST /api/v0/auth/cli/transfer endpoint). Single-use, expires in 60
seconds. Callers should retry on crate::HarmontError::Api with code
cli_code_invalid until the token is claimed or the window closes.
Sourcepub async fn create_api_token(&self, description: &str) -> Result<String>
pub async fn create_api_token(&self, description: &str) -> Result<String>
Mint a personal API token (requires an authenticated client).
The raw token is returned once and never retrievable again. Store it
securely (e.g. in the system keychain or ~/.config/harmont/token).
Trait Implementations§
Source§impl Clone for HarmontClient
impl Clone for HarmontClient
Source§fn clone(&self) -> HarmontClient
fn clone(&self) -> HarmontClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more