pub struct OpaClient { /* private fields */ }Expand description
Client for interacting with an Open Policy Agent (OPA) server or WASM module.
Implementations§
Source§impl OpaClient
impl OpaClient
Sourcepub fn new(url: Option<String>, tls_config: Option<Arc<ClientConfig>>) -> Self
pub fn new(url: Option<String>, tls_config: Option<Arc<ClientConfig>>) -> Self
Creates a new OpaClient with the given URL and TLS configuration.
Sourcepub fn with_wasm_executor(self, executor: Arc<dyn OpaWasmExecutor>) -> Self
pub fn with_wasm_executor(self, executor: Arc<dyn OpaWasmExecutor>) -> Self
Configures the client to use a WASM executor.
Sourcepub fn with_entrypoint(self, entrypoint: String) -> Self
pub fn with_entrypoint(self, entrypoint: String) -> Self
Sets the entrypoint for the OPA policy.
Sourcepub fn is_configured(&self) -> bool
pub fn is_configured(&self) -> bool
Returns true if the client is configured with either a URL or a WASM executor.
Sourcepub async fn check_context<T: Serialize>(&self, context: T) -> Result<bool>
pub async fn check_context<T: Serialize>(&self, context: T) -> Result<bool>
Flexible check that sends any serializable context to OPA
Trait Implementations§
Source§impl OpaAuthorizer for OpaClient
impl OpaAuthorizer for OpaClient
Source§fn check<'life0, 'life1, 'async_trait>(
&'life0 self,
context: ApiOpaContext<'life1>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn check<'life0, 'life1, 'async_trait>(
&'life0 self,
context: ApiOpaContext<'life1>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Checks the given context against the OPA policy.
Source§fn check_approval<'life0, 'life1, 'async_trait>(
&'life0 self,
context: ApprovalOpaContext<'life1>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn check_approval<'life0, 'life1, 'async_trait>(
&'life0 self,
context: ApprovalOpaContext<'life1>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Checks an approval context against the OPA policy.
Source§fn is_configured(&self) -> bool
fn is_configured(&self) -> bool
Returns true if the authorizer is properly configured.
Auto Trait Implementations§
impl Freeze for OpaClient
impl !RefUnwindSafe for OpaClient
impl Send for OpaClient
impl Sync for OpaClient
impl Unpin for OpaClient
impl UnsafeUnpin for OpaClient
impl !UnwindSafe for OpaClient
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