use crate::{error::Result, models::*, Configuration};
#[derive(Default)]
pub struct AuthenticationLogoutOptions {
pub idempotency_key: Option<String>,
}
#[derive(Default)]
pub struct AuthenticationStreamLogoutOptions {
pub idempotency_key: Option<String>,
}
#[derive(Default)]
pub struct AuthenticationStreamPortalAccessOptions {
pub idempotency_key: Option<String>,
}
#[derive(Default)]
pub struct AuthenticationStreamExpireAllOptions {
pub idempotency_key: Option<String>,
}
#[derive(Default)]
pub struct AuthenticationRotateStreamPollerTokenOptions {
pub idempotency_key: Option<String>,
}
pub struct Authentication<'a> {
cfg: &'a Configuration,
}
impl<'a> Authentication<'a> {
pub(super) fn new(cfg: &'a Configuration) -> Self {
Self { cfg }
}
pub async fn logout(&self, options: Option<AuthenticationLogoutOptions>) -> Result<()> {
let AuthenticationLogoutOptions { idempotency_key } = options.unwrap_or_default();
crate::request::Request::new(http1::Method::POST, "/v1/auth/logout")
.with_optional_header_param("idempotency-key", idempotency_key)
.returns_nothing()
.execute(self.cfg)
.await
}
pub async fn stream_logout(
&self,
options: Option<AuthenticationStreamLogoutOptions>,
) -> Result<()> {
let AuthenticationStreamLogoutOptions { idempotency_key } = options.unwrap_or_default();
crate::request::Request::new(http1::Method::POST, "/v1/auth/stream-logout")
.with_optional_header_param("idempotency-key", idempotency_key)
.returns_nothing()
.execute(self.cfg)
.await
}
pub async fn stream_portal_access(
&self,
stream_id: String,
stream_portal_access_in: StreamPortalAccessIn,
options: Option<AuthenticationStreamPortalAccessOptions>,
) -> Result<AppPortalAccessOut> {
let AuthenticationStreamPortalAccessOptions { idempotency_key } =
options.unwrap_or_default();
crate::request::Request::new(
http1::Method::POST,
"/v1/auth/stream-portal-access/{stream_id}",
)
.with_path_param("stream_id", stream_id)
.with_optional_header_param("idempotency-key", idempotency_key)
.with_body_param(stream_portal_access_in)
.execute(self.cfg)
.await
}
pub async fn stream_expire_all(
&self,
stream_id: String,
stream_token_expire_in: StreamTokenExpireIn,
options: Option<AuthenticationStreamExpireAllOptions>,
) -> Result<()> {
let AuthenticationStreamExpireAllOptions { idempotency_key } = options.unwrap_or_default();
crate::request::Request::new(
http1::Method::POST,
"/v1/auth/stream/{stream_id}/expire-all",
)
.with_path_param("stream_id", stream_id)
.with_optional_header_param("idempotency-key", idempotency_key)
.with_body_param(stream_token_expire_in)
.returns_nothing()
.execute(self.cfg)
.await
}
pub async fn get_stream_poller_token(
&self,
stream_id: String,
sink_id: String,
) -> Result<ApiTokenOut> {
crate::request::Request::new(
http1::Method::GET,
"/v1/auth/stream/{stream_id}/sink/{sink_id}/poller/token",
)
.with_path_param("stream_id", stream_id)
.with_path_param("sink_id", sink_id)
.execute(self.cfg)
.await
}
pub async fn rotate_stream_poller_token(
&self,
stream_id: String,
sink_id: String,
rotate_poller_token_in: RotatePollerTokenIn,
options: Option<AuthenticationRotateStreamPollerTokenOptions>,
) -> Result<ApiTokenOut> {
let AuthenticationRotateStreamPollerTokenOptions { idempotency_key } =
options.unwrap_or_default();
crate::request::Request::new(
http1::Method::POST,
"/v1/auth/stream/{stream_id}/sink/{sink_id}/poller/token/rotate",
)
.with_path_param("stream_id", stream_id)
.with_path_param("sink_id", sink_id)
.with_optional_header_param("idempotency-key", idempotency_key)
.with_body_param(rotate_poller_token_in)
.execute(self.cfg)
.await
}
}