pub enum ProviderAuth {
Api {
key: String,
},
OAuth {
access: String,
refresh: String,
expires: i64,
name: Option<String>,
},
}Expand description
Authentication credentials for an LLM provider
Variants§
Implementations§
Source§impl ProviderAuth
impl ProviderAuth
Sourcepub fn oauth(
access: impl Into<String>,
refresh: impl Into<String>,
expires: i64,
) -> Self
pub fn oauth( access: impl Into<String>, refresh: impl Into<String>, expires: i64, ) -> Self
Create a new OAuth authentication
Sourcepub fn oauth_with_name(
access: impl Into<String>,
refresh: impl Into<String>,
expires: i64,
name: impl Into<String>,
) -> Self
pub fn oauth_with_name( access: impl Into<String>, refresh: impl Into<String>, expires: i64, name: impl Into<String>, ) -> Self
Create a new OAuth authentication with subscription name
Sourcepub fn needs_refresh(&self) -> bool
pub fn needs_refresh(&self) -> bool
Check if OAuth token needs refresh (within 5 minutes of expiry)
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if OAuth token is expired
Sourcepub fn api_key_value(&self) -> Option<&str>
pub fn api_key_value(&self) -> Option<&str>
Get the API key if this is an API key auth
Sourcepub fn access_token(&self) -> Option<&str>
pub fn access_token(&self) -> Option<&str>
Get the access token if this is an OAuth auth
Sourcepub fn refresh_token(&self) -> Option<&str>
pub fn refresh_token(&self) -> Option<&str>
Get the refresh token if this is an OAuth auth
Sourcepub fn is_api_key(&self) -> bool
pub fn is_api_key(&self) -> bool
Check if this is an API key authentication
Sourcepub fn auth_type_display(&self) -> &'static str
pub fn auth_type_display(&self) -> &'static str
Get a display-safe representation of the auth type
Sourcepub fn subscription_name(&self) -> Option<&str>
pub fn subscription_name(&self) -> Option<&str>
Get the subscription name if this is an OAuth auth with a name
Trait Implementations§
Source§impl Clone for ProviderAuth
impl Clone for ProviderAuth
Source§fn clone(&self) -> ProviderAuth
fn clone(&self) -> ProviderAuth
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ProviderAuth
impl Debug for ProviderAuth
Source§impl<'de> Deserialize<'de> for ProviderAuth
impl<'de> Deserialize<'de> for ProviderAuth
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ProviderAuth
impl PartialEq for ProviderAuth
Source§impl Serialize for ProviderAuth
impl Serialize for ProviderAuth
impl StructuralPartialEq for ProviderAuth
Auto Trait Implementations§
impl Freeze for ProviderAuth
impl RefUnwindSafe for ProviderAuth
impl Send for ProviderAuth
impl Sync for ProviderAuth
impl Unpin for ProviderAuth
impl UnwindSafe for ProviderAuth
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