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
impl ApiClient
Sourcepub fn new(base_url: &str, timeout: Duration) -> Result<Self>
pub fn new(base_url: &str, timeout: Duration) -> Result<Self>
Create a new client with the given base URL and timeout.
Sourcepub fn with_client(client: Client, base_url: &str) -> Self
pub fn with_client(client: Client, base_url: &str) -> Self
Create from an existing reqwest::Client (e.g. shared in tests).
pub fn set_auth(&mut self, token: String)
pub fn auth_token(&self) -> Option<&str>
pub fn base_url(&self) -> &str
Sourcepub fn reqwest_client(&self) -> &Client
pub fn reqwest_client(&self) -> &Client
Access the underlying reqwest::Client.
pub async fn health(&self) -> Result<HealthResponse>
pub async fn login(&self, req: &LoginRequest) -> Result<AuthTokenResponse>
pub async fn register( &self, req: &AuthRegisterRequest, ) -> Result<AuthTokenResponse>
pub async fn verify(&self) -> Result<VerifyResponse>
pub async fn me(&self) -> Result<UserSettingsResponse>
pub async fn refresh(&self, req: &RefreshRequest) -> Result<AuthTokenResponse>
pub async fn logout(&self, req: &LogoutRequest) -> Result<OkResponse>
pub async fn change_password( &self, req: &ChangePasswordRequest, ) -> Result<OkResponse>
pub async fn regenerate_key(&self) -> Result<RegenerateKeyResponse>
pub async fn upload_session( &self, req: &UploadRequest, ) -> Result<UploadResponse>
pub async fn list_sessions( &self, query: &SessionListQuery, ) -> Result<SessionListResponse>
pub async fn get_session(&self, id: &str) -> Result<SessionDetail>
pub async fn get_session_raw(&self, id: &str) -> Result<Value>
pub async fn list_teams(&self) -> Result<ListTeamsResponse>
pub async fn create_team(&self, req: &CreateTeamRequest) -> Result<TeamResponse>
pub async fn get_team(&self, id: &str) -> Result<TeamDetailResponse>
pub async fn update_team( &self, id: &str, req: &UpdateTeamRequest, ) -> Result<TeamResponse>
pub async fn add_member( &self, team_id: &str, req: &AddMemberRequest, ) -> Result<OkResponse>
pub async fn list_members(&self, team_id: &str) -> Result<ListMembersResponse>
pub async fn remove_member( &self, team_id: &str, user_id: &str, ) -> Result<OkResponse>
pub async fn list_invitations(&self) -> Result<ListInvitationsResponse>
pub async fn accept_invitation( &self, id: &str, ) -> Result<AcceptInvitationResponse>
pub async fn decline_invitation(&self, id: &str) -> Result<OkResponse>
pub async fn invite_member( &self, team_id: &str, req: &InviteRequest, ) -> Result<OkResponse>
pub async fn sync_pull( &self, team_id: &str, since: Option<&str>, limit: Option<u32>, ) -> Result<SyncPullResponse>
pub async fn stream_events( &self, session_id: &str, req: &Value, ) -> Result<Response>
pub async fn config_sync(&self, team_id: &str) -> Result<ConfigSyncResponse>
Sourcepub async fn get_with_auth(&self, path: &str, token: &str) -> Result<Response>
pub async fn get_with_auth(&self, path: &str, token: &str) -> Result<Response>
Authenticated GET returning the raw response.
Sourcepub async fn post_with_auth(&self, path: &str, token: &str) -> Result<Response>
pub async fn post_with_auth(&self, path: &str, token: &str) -> Result<Response>
Authenticated POST (no body) returning the raw response.
Sourcepub async fn post_json_with_auth<T: Serialize>(
&self,
path: &str,
token: &str,
body: &T,
) -> Result<Response>
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.
Sourcepub async fn put_json_with_auth<T: Serialize>(
&self,
path: &str,
token: &str,
body: &T,
) -> Result<Response>
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.
Auto Trait Implementations§
impl Freeze for ApiClient
impl !RefUnwindSafe for ApiClient
impl Send for ApiClient
impl Sync for ApiClient
impl Unpin for ApiClient
impl !UnwindSafe for ApiClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more