Skip to main content

ApiClient

Struct ApiClient 

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

Implementations§

Source§

impl ApiClient

Source

pub fn new(base_url: &str, api_key: Option<&str>) -> Self

Construct a client authenticated with a raw API key (or nothing).

Part of the crate’s public API and the shape every test constructs, so it stays exactly as it was. Command code goes through ApiClient::with_credential instead, which is why the tracevault BINARY target — where nothing but the lib’s tests calls this — would otherwise report it as dead.

Source

pub fn with_credential(base_url: &str, credential: Option<Credential>) -> Self

Construct a client from a resolved Credential.

Takes an Option because every caller resolves credentials that may be absent (resolve_credentials returns an Option), and an unauthenticated client is a legitimate state — several commands degrade gracefully rather than failing when nothing is configured.

Source

pub async fn register_repo( &self, req: RegisterRepoRequest, ) -> Result<RegisterRepoResponse, Box<dyn Error>>

Source

pub async fn get_me(&self) -> Result<MeResponse, GetMeError>

GET /api/v1/auth/me — validates the bearer token and returns user identity. Used by tracevault status to distinguish “logged out”, “expired token”, and “server unreachable”.

Source

pub async fn list_repos(&self) -> Result<Vec<RepoListItem>, Box<dyn Error>>

Source

pub async fn get_agent_instructions( &self, repo_id: &Uuid, ) -> Result<AgentInstructionsResponse, Box<dyn Error>>

Source

pub async fn verify_commits( &self, repo_id: &Uuid, req: CiVerifyRequest, ) -> Result<CiVerifyResponse, Box<dyn Error>>

Source

pub async fn push_commit( &self, repo_id: &str, req: &CommitPushRequest, ) -> Result<CommitPushResponse, Box<dyn Error>>

Source

pub async fn stream_event( &self, repo_id: &str, req: &StreamEventRequest, ) -> Result<StreamEventResponse, Box<dyn Error>>

Source

pub async fn stream_event_for_project( &self, project_id: Uuid, repo_id: Option<&str>, req: &StreamEventRequest, ) -> Result<StreamEventResponse, Box<dyn Error>>

Project-scoped variant of stream_event: posts to the project’s stream endpoint with the project in the path and repo_id — when there is one — as a query param rather than a path segment. The query is built with Url::query_pairs_mut, mirroring resolve_project’s ?git_url=, so repo_id is percent-encoded rather than string-interpolated into the URL.

repo_id is None for a repo-less session, and the pair is then omitted entirely: the server declares it optional (ProjectStreamQuery::repo_id: Option<Uuid>) and would reject an empty value as a malformed UUID.

Called from commands::stream::send_stream_event for both the Attribution::Repo { project: Some(_) } and Attribution::ProjectOnly routes.

Source

pub async fn check_policies( &self, repo_id: &Uuid, req: CheckPoliciesRequest, ) -> Result<CheckPoliciesResponse, Box<dyn Error>>

Source

pub async fn resolve_remote( &self, git_url: &str, ) -> Result<Option<ResolveRemoteResponse>, Box<dyn Error>>

Resolve a git URL to its codebase (git remote) by NORMALIZED URL — deduped, unlike an exact github_url match. Ok(None) if the codebase isn’t tracked: a genuine domain 404, identified by the server’s JSON error envelope (see [is_domain_error_body]). A bare 404 with no such body — axum’s built-in “no route matched” fallback — is surfaced as Err instead, since it means this server doesn’t have this route at all (most plausibly a CLI/server version skew, e.g. this CLI shipped ahead of a server that still uses the old org-scoped paths) rather than an absent codebase.

Source

pub async fn get_remote_detail( &self, remote_id: Uuid, ) -> Result<RemoteDetail, Box<dyn Error>>

Full detail for a remote (codebase): its display name, normalized URL, clone status, and linked repos.

Source

pub async fn get_remote_repos( &self, remote_id: Uuid, ) -> Result<Vec<RemoteRepoRef>, Box<dyn Error>>

The repos linked to a remote (the codebase’s members).

Source

pub async fn list_projects( &self, ) -> Result<Vec<ProjectListItem>, Box<dyn Error>>

List all projects. GET /api/v1/projects.

Source

pub async fn get_project( &self, id: Uuid, ) -> Result<ProjectDetail, Box<dyn Error>>

Full detail for a project. GET /api/v1/projects/{id}.

Source

pub async fn resolve_project( &self, git_url: &str, ) -> Result<ResolveProjectOutcome, Box<dyn Error>>

Resolve a git URL to its project, distinguishing “no project” (a genuine domain 404 — see [is_domain_error_body]) from “ambiguous, multiple candidate projects” (409). A bare 404 with no domain-error body is surfaced as Err instead of None (see resolve_remote’s doc comment for why). GET /api/v1/projects/resolve?git_url=.

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> Same for T

Source§

type Output = T

Should always be Self
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