Skip to main content

ApiClient

Struct ApiClient 

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

Typed HTTP client for the OpenSession API.

Provides high-level methods for each API endpoint (using the stored auth token) and low-level *_with_auth methods for callers that need per-request auth (e.g. E2E tests exercising multiple users).

Implementations§

Source§

impl ApiClient

Source

pub fn new(base_url: &str, timeout: Duration) -> Result<Self>

Create a new client with the given base URL and timeout.

Source

pub fn with_client(client: Client, base_url: &str) -> Self

Create from an existing reqwest::Client (e.g. shared in tests).

Source

pub fn set_auth(&mut self, token: String)

Source

pub fn auth_token(&self) -> Option<&str>

Source

pub fn base_url(&self) -> &str

Source

pub fn reqwest_client(&self) -> &Client

Access the underlying reqwest::Client.

Source

pub async fn health(&self) -> Result<HealthResponse>

Source

pub async fn login(&self, req: &LoginRequest) -> Result<AuthTokenResponse>

Source

pub async fn register( &self, req: &AuthRegisterRequest, ) -> Result<AuthTokenResponse>

Source

pub async fn verify(&self) -> Result<VerifyResponse>

Source

pub async fn me(&self) -> Result<UserSettingsResponse>

Source

pub async fn refresh(&self, req: &RefreshRequest) -> Result<AuthTokenResponse>

Source

pub async fn logout(&self, req: &LogoutRequest) -> Result<OkResponse>

Source

pub async fn change_password( &self, req: &ChangePasswordRequest, ) -> Result<OkResponse>

Source

pub async fn regenerate_key(&self) -> Result<RegenerateKeyResponse>

Source

pub async fn upload_session( &self, req: &UploadRequest, ) -> Result<UploadResponse>

Source

pub async fn list_sessions( &self, query: &SessionListQuery, ) -> Result<SessionListResponse>

Source

pub async fn get_session(&self, id: &str) -> Result<SessionDetail>

Source

pub async fn get_session_raw(&self, id: &str) -> Result<Value>

Source

pub async fn list_teams(&self) -> Result<ListTeamsResponse>

Source

pub async fn create_team(&self, req: &CreateTeamRequest) -> Result<TeamResponse>

Source

pub async fn get_team(&self, id: &str) -> Result<TeamDetailResponse>

Source

pub async fn update_team( &self, id: &str, req: &UpdateTeamRequest, ) -> Result<TeamResponse>

Source

pub async fn add_member( &self, team_id: &str, req: &AddMemberRequest, ) -> Result<OkResponse>

Source

pub async fn list_members(&self, team_id: &str) -> Result<ListMembersResponse>

Source

pub async fn remove_member( &self, team_id: &str, user_id: &str, ) -> Result<OkResponse>

Source

pub async fn list_invitations(&self) -> Result<ListInvitationsResponse>

Source

pub async fn accept_invitation( &self, id: &str, ) -> Result<AcceptInvitationResponse>

Source

pub async fn decline_invitation(&self, id: &str) -> Result<OkResponse>

Source

pub async fn invite_member( &self, team_id: &str, req: &InviteRequest, ) -> Result<OkResponse>

Source

pub async fn sync_pull( &self, team_id: &str, since: Option<&str>, limit: Option<u32>, ) -> Result<SyncPullResponse>

Source

pub async fn stream_events( &self, session_id: &str, req: &Value, ) -> Result<Response>

Source

pub async fn config_sync(&self, team_id: &str) -> Result<ConfigSyncResponse>

Source

pub async fn get_with_auth(&self, path: &str, token: &str) -> Result<Response>

Authenticated GET returning the raw response.

Source

pub async fn post_with_auth(&self, path: &str, token: &str) -> Result<Response>

Authenticated POST (no body) returning the raw response.

Source

pub async fn post_json_with_auth<T: Serialize>( &self, path: &str, token: &str, body: &T, ) -> Result<Response>

Authenticated POST with JSON body returning the raw response.

Source

pub async fn put_json_with_auth<T: Serialize>( &self, path: &str, token: &str, body: &T, ) -> Result<Response>

Authenticated PUT with JSON body returning the raw response.

Source

pub async fn delete_with_auth( &self, path: &str, token: &str, ) -> Result<Response>

Authenticated DELETE returning the raw response.

Source

pub async fn post_json_raw<T: Serialize>( &self, path: &str, body: &T, ) -> Result<Response>

Unauthenticated POST with JSON body returning the raw response.

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: 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: 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