pub struct RainySessionClient { /* private fields */ }Expand description
Client for Rainy API v3 JWT/session endpoints.
Use this client for authentication and dashboard/account operations such as
/api/v1/auth/*, /api/v1/keys, /api/v1/usage/*, and /api/v1/orgs/me.
Implementations§
Source§impl RainySessionClient
impl RainySessionClient
Sourcepub fn with_config(config: SessionConfig) -> Result<Self>
pub fn with_config(config: SessionConfig) -> Result<Self>
Creates a session client with custom configuration.
Sourcepub fn with_base_url(base_url: impl Into<String>) -> Result<Self>
pub fn with_base_url(base_url: impl Into<String>) -> Result<Self>
Creates a session client with only a custom base URL override.
Sourcepub fn set_access_token(&mut self, access_token: impl Into<String>)
pub fn set_access_token(&mut self, access_token: impl Into<String>)
Sets the in-memory access token used for authenticated requests.
Sourcepub fn clear_access_token(&mut self)
pub fn clear_access_token(&mut self)
Clears the in-memory access token.
Sourcepub fn access_token(&self) -> Option<&str>
pub fn access_token(&self) -> Option<&str>
Returns the current in-memory access token, if set.
Sourcepub async fn login(
&mut self,
email: &str,
password: &str,
) -> Result<LoginResponse>
pub async fn login( &mut self, email: &str, password: &str, ) -> Result<LoginResponse>
Authenticates a user and stores the returned access token in the client.
Sourcepub async fn register(
&mut self,
email: &str,
password: &str,
region: &str,
) -> Result<LoginResponse>
pub async fn register( &mut self, email: &str, password: &str, region: &str, ) -> Result<LoginResponse>
Registers a user and stores the returned access token in the client.
Sourcepub async fn refresh(&mut self, refresh_token: &str) -> Result<RefreshResponse>
pub async fn refresh(&mut self, refresh_token: &str) -> Result<RefreshResponse>
Refreshes the session token pair and stores the new access token.
Sourcepub async fn me(&self) -> Result<SessionUser>
pub async fn me(&self) -> Result<SessionUser>
Returns the current authenticated user profile from GET /api/v1/auth/me.
Sourcepub async fn org_me(&self) -> Result<OrgProfile>
pub async fn org_me(&self) -> Result<OrgProfile>
Returns the current organization profile from GET /api/v1/orgs/me.
Sourcepub async fn list_api_keys(&self) -> Result<Vec<SessionApiKeyListItem>>
pub async fn list_api_keys(&self) -> Result<Vec<SessionApiKeyListItem>>
Lists API keys for the authenticated organization/user session.
Sourcepub async fn create_api_key(
&self,
name: &str,
key_type: Option<&str>,
) -> Result<CreatedApiKey>
pub async fn create_api_key( &self, name: &str, key_type: Option<&str>, ) -> Result<CreatedApiKey>
Creates a new API key for the authenticated session.
key_type may be Some("standard"), Some("platform"), or None
to let the server default apply.
Sourcepub async fn delete_api_key(&self, id: &str) -> Result<Value>
pub async fn delete_api_key(&self, id: &str) -> Result<Value>
Deletes an API key by ID.
Returns the server JSON response as-is to avoid over-expanding the SDK surface.
Sourcepub async fn usage_credits(&self) -> Result<UsageCreditsResponse>
pub async fn usage_credits(&self) -> Result<UsageCreditsResponse>
Returns current credit balance information from GET /api/v1/usage/credits.
Sourcepub async fn usage_stats(&self, days: Option<u32>) -> Result<UsageStatsResponse>
pub async fn usage_stats(&self, days: Option<u32>) -> Result<UsageStatsResponse>
Returns usage statistics from GET /api/v1/usage/stats.
When days is None, the server default period is used.
Trait Implementations§
Source§impl Clone for RainySessionClient
impl Clone for RainySessionClient
Source§fn clone(&self) -> RainySessionClient
fn clone(&self) -> RainySessionClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more