pub struct KaslServer { /* private fields */ }Expand description
A client bound to one kasl-server instance.
Implementations§
Source§impl KaslServer
impl KaslServer
Sourcepub fn new(config: &KaslServerConfig) -> Result<Self>
pub fn new(config: &KaslServerConfig) -> Result<Self>
Builds a client for the configured server.
A configured CA certificate is added to the trust store rather than replacing it: a company CA for the server and public CAs for everything else is the normal self-hosted arrangement.
Sourcepub async fn health(&self) -> Result<Health>
pub async fn health(&self) -> Result<Health>
Asks the server whether it is serviceable, and which version it runs.
Unauthenticated: this is the call that tells a misspelled URL from a bad token, so it must not need the token to answer.
Sourcepub async fn identify(&self, token: &str) -> Result<AgentIdentity>
pub async fn identify(&self, token: &str) -> Result<AgentIdentity>
Resolves the agent token to the person it reports for.
Doubles as the token check: the server refuses an unknown, revoked, or
deactivated token with 401, which is reported as such rather than as
a transport failure.
Sourcepub async fn upload_day(
&self,
token: &str,
day: &DayUpload,
) -> Result<DayAccepted, UploadError>
pub async fn upload_day( &self, token: &str, day: &DayUpload, ) -> Result<DayAccepted, UploadError>
Sends one day to POST /api/v1/days.
The last upload wins on the server, so re-sending a day corrects it
and sending the same day twice changes nothing (ADR 0004). That makes
a retry safe by construction, which is what the failure split here is
for: UploadError separates a payload the server will never take
from a server that could not answer this time.
Sourcepub async fn upload_batch(
&self,
token: &str,
days: &[DayUpload],
) -> Result<BatchResult, UploadError>
pub async fn upload_batch( &self, token: &str, days: &[DayUpload], ) -> Result<BatchResult, UploadError>
Sends several days to POST /api/v1/days/batch.
The reason a backlog goes this way rather than as a loop of single uploads is not the round trips - it is that the agent learns about the run as a whole. Each day is written in its own transaction there, so one day the server will never accept does not hold back the rest (ADR 0005).
The error here covers the request: a batch that never arrived, or a
server that refused the whole shape of it. The fate of the days inside
a batch that did arrive is in BatchResult, and has to be read per
day - a 200 here means the request was processed, not that every day
in it was stored.
Trait Implementations§
Source§impl Clone for KaslServer
impl Clone for KaslServer
Source§fn clone(&self) -> KaslServer
fn clone(&self) -> KaslServer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more