pub struct Api {
base_url: Url,
auth_data: Arc<Mutex<Option<AuthData>>>,
token_url: Url,
client_id: String,
client_secret: Secret<String>,
}Expand description
The keycloak admin API.
Fields§
§base_url: UrlBase url for the Keycloak admin REST API.
auth_data: Arc<Mutex<Option<AuthData>>>Cached access token (needs to be thread safe). Might be expired, in which case it will be refreshed.
token_url: UrlUrl for requesting the access token from the auth server.
client_id: StringThe client id for the oauth2 client.
client_secret: Secret<String>The client secret for the oauth2 client.
Implementations§
Source§impl Api
impl Api
Sourceasync fn get<T: DeserializeOwned>(&self, client: &Client, url: Url) -> Result<T>
async fn get<T: DeserializeOwned>(&self, client: &Client, url: Url) -> Result<T>
Executes a get request authenticated with the access token.
Sourceasync fn get_or_refresh_access_token(
&self,
client: &Client,
) -> Result<Secret<String>>
async fn get_or_refresh_access_token( &self, client: &Client, ) -> Result<Secret<String>>
Gets the access token or refreshes it if it is expired.
Sourceasync fn refresh_access_token(&self, client: &Client) -> Result<AuthData>
async fn refresh_access_token(&self, client: &Client) -> Result<AuthData>
Refresh the access token.
Trait Implementations§
Source§impl KeycloakApi for Api
impl KeycloakApi for Api
Source§fn search_users_by_username<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
search_params: &'life1 UserSearchParameters,
pagination: &'life2 PageParameters,
client: &'life3 Client,
) -> Pin<Box<dyn Future<Output = Result<Vec<UserDto>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn search_users_by_username<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
search_params: &'life1 UserSearchParameters,
pagination: &'life2 PageParameters,
client: &'life3 Client,
) -> Pin<Box<dyn Future<Output = Result<Vec<UserDto>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Search for users by their username. Read more
Source§fn get_users_by_ids<'life0, 'life1, 'async_trait>(
&'life0 self,
client: &'life1 Client,
user_ids: Vec<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Vec<UserDto>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_users_by_ids<'life0, 'life1, 'async_trait>(
&'life0 self,
client: &'life1 Client,
user_ids: Vec<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Vec<UserDto>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Gets all users given their ids from the Keycloak API. Read more
Source§fn get_user_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
client: &'life1 Client,
user_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<UserDto>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_user_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
client: &'life1 Client,
user_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<UserDto>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Gets a user by its id from the Keycloak API. Read more
Auto Trait Implementations§
impl Freeze for Api
impl !RefUnwindSafe for Api
impl Send for Api
impl Sync for Api
impl Unpin for Api
impl !UnwindSafe for Api
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 moreSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
Convert
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
Convert
&self to an expression for Diesel’s query builder. Read moreSource§impl<T, Conn> RunQueryDsl<Conn> for T
impl<T, Conn> RunQueryDsl<Conn> for T
Source§fn execute<'conn, 'query>(
self,
conn: &'conn mut Conn,
) -> <Conn as AsyncConnection>::ExecuteFuture<'conn, 'query>
fn execute<'conn, 'query>( self, conn: &'conn mut Conn, ) -> <Conn as AsyncConnection>::ExecuteFuture<'conn, 'query>
Executes the given command, returning the number of rows affected. Read more
Source§fn load<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
fn load<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
Source§fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnection,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnection,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
Source§fn get_result<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>, fn(_: Self::Stream<'conn>) -> Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>>
fn get_result<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>, fn(_: Self::Stream<'conn>) -> Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>>
Runs the command, and returns the affected row. Read more
Source§fn get_results<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
fn get_results<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
Runs the command, returning an
Vec with the affected rows. Read moreSource§fn first<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<<Self::Output as LoadQuery<'query, Conn, U>>::LoadFuture<'conn>, Map<StreamFuture<Pin<Box<<Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<<Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>>>)) -> Result<U, Error>>, fn(_: <Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>) -> Map<StreamFuture<Pin<Box<<Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<<Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>>>)) -> Result<U, Error>>>
fn first<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<<Self::Output as LoadQuery<'query, Conn, U>>::LoadFuture<'conn>, Map<StreamFuture<Pin<Box<<Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<<Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>>>)) -> Result<U, Error>>, fn(_: <Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>) -> Map<StreamFuture<Pin<Box<<Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<<Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>>>)) -> Result<U, Error>>>
Attempts to load a single record. Read more