#[non_exhaustive]pub struct AgentRequest {
pub principal: Principal,
pub action: AgentAction,
pub resource: Resource,
pub context: AgentContext,
pub request_id: Option<String>,
pub trace: Option<TraceContext>,
pub tenant_id: Option<String>,
}Expand description
A full authorization request: principal + action + resource + context.
Construct via AgentRequest::new for a quick request, or
AgentRequestBuilder for type-safe incremental construction.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.principal: Principal§action: AgentAction§resource: Resource§context: AgentContext§request_id: Option<String>§trace: Option<TraceContext>Optional W3C Trace Context (parsed from traceparent header).
tenant_id: Option<String>Tenant ID for multi-tenant deployments. Propagated through to
DecisionRecord so per-tenant SAR queries, blast-radius
analyses, and audit log scans can scope by tenant.
No format constraint is enforced here; the caller decides
(UUID, slug, email, etc). with_tenant_id trims whitespace
and converts empty strings to None.
Implementations§
Source§impl AgentRequest
impl AgentRequest
Sourcepub fn new(
principal: Principal,
action: AgentAction,
resource: Resource,
context: AgentContext,
) -> Self
pub fn new( principal: Principal, action: AgentAction, resource: Resource, context: AgentContext, ) -> Self
Construct a request with a fresh UUID v7 request id.
Sourcepub fn with_request_id(self, id: impl Into<String>) -> Self
pub fn with_request_id(self, id: impl Into<String>) -> Self
Override the auto-generated request id.
Sourcepub fn with_trace(self, trace: TraceContext) -> Self
pub fn with_trace(self, trace: TraceContext) -> Self
Attach a W3C Trace Context.
Sourcepub fn with_tenant_id(self, tid: impl Into<String>) -> Self
pub fn with_tenant_id(self, tid: impl Into<String>) -> Self
Set the tenant ID. Whitespace is trimmed; empty/whitespace-only
values become None. No other format constraint.
Sourcepub fn to_cedar_request(&self, schema: Option<&Schema>) -> Result<Request>
pub fn to_cedar_request(&self, schema: Option<&Schema>) -> Result<Request>
Convert to a cedar_policy::Request. schema is used to construct
a typed context (validates context shape per action) when available.
§Errors
Returns Error::InvalidPrincipal / Error::InvalidResource if
the principal type or resource type name is not a valid Cedar
identifier. Returns Error::InvalidContext if the context cannot
be parsed against the schema.
Trait Implementations§
Source§impl Clone for AgentRequest
impl Clone for AgentRequest
Source§fn clone(&self) -> AgentRequest
fn clone(&self) -> AgentRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AgentRequest
impl Debug for AgentRequest
Source§impl<'de> Deserialize<'de> for AgentRequest
impl<'de> Deserialize<'de> for AgentRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for AgentRequest
impl PartialEq for AgentRequest
Source§impl Serialize for AgentRequest
impl Serialize for AgentRequest
impl StructuralPartialEq for AgentRequest
Auto Trait Implementations§
impl Freeze for AgentRequest
impl RefUnwindSafe for AgentRequest
impl Send for AgentRequest
impl Sync for AgentRequest
impl Unpin for AgentRequest
impl UnwindSafe for AgentRequest
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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