#[non_exhaustive]pub struct IssueAccessTokenInput {
pub id: AccessTokenId,
pub expires_at: Option<S2DateTime>,
pub auto_prefix_streams: bool,
pub scope: AccessTokenScopeInput,
}Expand description
Input for issue_access_token.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: AccessTokenIdAccess token ID.
expires_at: Option<S2DateTime>Expiration time.
Defaults to the expiration time of requestor’s access token passed via
S2Config.
auto_prefix_streams: boolWhether to automatically prefix stream names during creation and strip the prefix during listing.
Note: scope.streams must be set with the
prefix.
Defaults to false.
scope: AccessTokenScopeInputScope of the token.
Implementations§
Source§impl IssueAccessTokenInput
impl IssueAccessTokenInput
Sourcepub fn new(id: AccessTokenId, scope: AccessTokenScopeInput) -> Self
pub fn new(id: AccessTokenId, scope: AccessTokenScopeInput) -> Self
Create a new IssueAccessTokenInput with the given id and scope.
Examples found in repository?
examples/issue_access_token.rs (lines 20-28)
10async fn main() -> Result<(), Box<dyn std::error::Error>> {
11 let access_token =
12 std::env::var("S2_ACCESS_TOKEN").map_err(|_| "S2_ACCESS_TOKEN env var not set")?;
13 let basin_name: BasinName = std::env::var("S2_BASIN")
14 .map_err(|_| "S2_BASIN env var not set")?
15 .parse()?;
16
17 let config = S2Config::new(access_token);
18 let s2 = S2::new(config)?;
19
20 let input = IssueAccessTokenInput::new(
21 "ro-token".parse()?,
22 AccessTokenScopeInput::from_op_group_perms(
23 OperationGroupPermissions::new().with_account(ReadWritePermissions::read_only()),
24 )
25 .with_ops([Operation::CreateStream])
26 .with_streams(StreamMatcher::Prefix("audit".parse()?))
27 .with_basins(BasinMatcher::Exact(basin_name)),
28 );
29 let issued_token = s2.issue_access_token(input).await?;
30 println!("Issued access token: {issued_token}");
31
32 Ok(())
33}Sourcepub fn with_expires_at(self, expires_at: S2DateTime) -> Self
pub fn with_expires_at(self, expires_at: S2DateTime) -> Self
Set the expiration time.
Sourcepub fn with_auto_prefix_streams(self, auto_prefix_streams: bool) -> Self
pub fn with_auto_prefix_streams(self, auto_prefix_streams: bool) -> Self
Set whether to automatically prefix stream names during creation and strip the prefix during listing.
Trait Implementations§
Source§impl Clone for IssueAccessTokenInput
impl Clone for IssueAccessTokenInput
Source§fn clone(&self) -> IssueAccessTokenInput
fn clone(&self) -> IssueAccessTokenInput
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 IssueAccessTokenInput
impl Debug for IssueAccessTokenInput
Source§impl From<IssueAccessTokenInput> for AccessTokenInfo
impl From<IssueAccessTokenInput> for AccessTokenInfo
Source§fn from(value: IssueAccessTokenInput) -> Self
fn from(value: IssueAccessTokenInput) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for IssueAccessTokenInput
impl RefUnwindSafe for IssueAccessTokenInput
impl Send for IssueAccessTokenInput
impl Sync for IssueAccessTokenInput
impl Unpin for IssueAccessTokenInput
impl UnwindSafe for IssueAccessTokenInput
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 more