pub enum Credentials {
None,
ApiKey {
key: String,
},
AccessKey {
access_key: String,
secret_key: String,
session_token: Option<String>,
},
OAuth2 {
access_token: String,
refresh_token: Option<String>,
expires_at: Option<DateTime<Utc>>,
},
ServiceAccount {
key_json: String,
project_id: Option<String>,
},
SasToken {
token: String,
expires_at: Option<DateTime<Utc>>,
},
IamRole {
role_arn: String,
session_name: String,
},
Custom {
data: HashMap<String, String>,
},
}Expand description
Authentication credentials
Variants§
None
No authentication
ApiKey
API key authentication
AccessKey
Access key and secret key (AWS-style)
Fields
OAuth2
OAuth 2.0 token
Fields
ServiceAccount
Service account key (GCP-style JSON)
SasToken
Shared Access Signature token (Azure-style)
IamRole
IAM role credentials
Custom
Custom credentials with arbitrary key-value pairs
Implementations§
Source§impl Credentials
impl Credentials
Sourcepub fn access_key(
access_key: impl Into<String>,
secret_key: impl Into<String>,
) -> Self
pub fn access_key( access_key: impl Into<String>, secret_key: impl Into<String>, ) -> Self
Creates access key credentials
Sourcepub fn access_key_with_session(
access_key: impl Into<String>,
secret_key: impl Into<String>,
session_token: impl Into<String>,
) -> Self
pub fn access_key_with_session( access_key: impl Into<String>, secret_key: impl Into<String>, session_token: impl Into<String>, ) -> Self
Creates access key credentials with session token
Sourcepub fn oauth2_with_refresh(
access_token: impl Into<String>,
refresh_token: impl Into<String>,
) -> Self
pub fn oauth2_with_refresh( access_token: impl Into<String>, refresh_token: impl Into<String>, ) -> Self
Creates OAuth 2.0 credentials with refresh token
Sourcepub fn service_account_from_json(json: impl Into<String>) -> Result<Self>
pub fn service_account_from_json(json: impl Into<String>) -> Result<Self>
Creates service account credentials from JSON
Sourcepub fn service_account_from_file(path: impl AsRef<Path>) -> Result<Self>
pub fn service_account_from_file(path: impl AsRef<Path>) -> Result<Self>
Creates service account credentials from file
Sourcepub fn iam_role(
role_arn: impl Into<String>,
session_name: impl Into<String>,
) -> Self
pub fn iam_role( role_arn: impl Into<String>, session_name: impl Into<String>, ) -> Self
Creates IAM role credentials
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Checks if credentials are expired
Sourcepub fn needs_refresh(&self) -> bool
pub fn needs_refresh(&self) -> bool
Returns true if credentials need refresh
Trait Implementations§
Source§impl Clone for Credentials
impl Clone for Credentials
Source§fn clone(&self) -> Credentials
fn clone(&self) -> Credentials
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 moreAuto Trait Implementations§
impl Freeze for Credentials
impl RefUnwindSafe for Credentials
impl Send for Credentials
impl Sync for Credentials
impl Unpin for Credentials
impl UnsafeUnpin for Credentials
impl UnwindSafe for Credentials
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.