Struct cedar_policy_validator::ValidatorSchema
source · pub struct ValidatorSchema { /* private fields */ }
Implementations§
source§impl ValidatorSchema
impl ValidatorSchema
sourcepub fn principals(&self) -> impl Iterator<Item = &EntityType>
pub fn principals(&self) -> impl Iterator<Item = &EntityType>
Returns an iterator over every entity type that can be a principal for any action in this schema
sourcepub fn resources(&self) -> impl Iterator<Item = &EntityType>
pub fn resources(&self) -> impl Iterator<Item = &EntityType>
Returns an iterator over every entity type that can be a resource for any action in this schema
sourcepub fn principals_for_action(
&self,
action: &EntityUID,
) -> Option<impl Iterator<Item = &EntityType>>
pub fn principals_for_action( &self, action: &EntityUID, ) -> Option<impl Iterator<Item = &EntityType>>
sourcepub fn resources_for_action(
&self,
action: &EntityUID,
) -> Option<impl Iterator<Item = &EntityType>>
pub fn resources_for_action( &self, action: &EntityUID, ) -> Option<impl Iterator<Item = &EntityType>>
sourcepub fn action_groups(&self) -> impl Iterator<Item = &EntityUID>
pub fn action_groups(&self) -> impl Iterator<Item = &EntityUID>
Returns an iterator over all the action groups defined in this schema
sourcepub fn actions(&self) -> impl Iterator<Item = &EntityUID>
pub fn actions(&self) -> impl Iterator<Item = &EntityUID>
Returns an iterator over all actions defined in this schema
sourcepub fn empty() -> ValidatorSchema
pub fn empty() -> ValidatorSchema
Create a ValidatorSchema
without any definitions (of entity types,
common types, or actions).
sourcepub fn from_json_value(json: Value, extensions: Extensions<'_>) -> Result<Self>
pub fn from_json_value(json: Value, extensions: Extensions<'_>) -> Result<Self>
Construct a ValidatorSchema
from a JSON value (which should be an
object matching the SchemaFileFormat
shape).
sourcepub fn from_file(file: impl Read, extensions: Extensions<'_>) -> Result<Self>
pub fn from_file(file: impl Read, extensions: Extensions<'_>) -> Result<Self>
Construct a ValidatorSchema
directly from a file.
pub fn from_file_natural( r: impl Read, extensions: Extensions<'_>, ) -> Result<(Self, impl Iterator<Item = SchemaWarning>), HumanSchemaError>
pub fn from_str_natural( src: &str, extensions: Extensions<'_>, ) -> Result<(Self, impl Iterator<Item = SchemaWarning>), HumanSchemaError>
pub fn from_schema_file( schema_file: SchemaFragment, action_behavior: ActionBehavior, extensions: Extensions<'_>, ) -> Result<ValidatorSchema>
sourcepub fn from_schema_fragments(
fragments: impl IntoIterator<Item = ValidatorSchemaFragment>,
) -> Result<ValidatorSchema>
pub fn from_schema_fragments( fragments: impl IntoIterator<Item = ValidatorSchemaFragment>, ) -> Result<ValidatorSchema>
Construct a new ValidatorSchema
from some number of schema fragments.
sourcepub fn get_action_id(&self, action_id: &EntityUID) -> Option<&ValidatorActionId>
pub fn get_action_id(&self, action_id: &EntityUID) -> Option<&ValidatorActionId>
Lookup the ValidatorActionId object in the schema with the given name.
sourcepub fn get_entity_type<'a>(
&'a self,
entity_type_id: &Name,
) -> Option<&'a ValidatorEntityType>
pub fn get_entity_type<'a>( &'a self, entity_type_id: &Name, ) -> Option<&'a ValidatorEntityType>
Lookup the ValidatorEntityType object in the schema with the given name.
sourcepub fn entity_types(
&self,
) -> impl Iterator<Item = (&Name, &ValidatorEntityType)>
pub fn entity_types( &self, ) -> impl Iterator<Item = (&Name, &ValidatorEntityType)>
An iterator matching the entity Types to their Validator Types
sourcepub fn context_type(&self, action: &EntityUID) -> Option<Type>
pub fn context_type(&self, action: &EntityUID) -> Option<Type>
Get the Type
of context expected for the given action
.
This always reutrns a closed record type.
Returns None
if the action is not in the schema.
sourcepub fn action_entities(&self) -> Result<Entities, EntitiesError>
pub fn action_entities(&self) -> Result<Entities, EntitiesError>
Construct an Entity
object for each action in the schema
Trait Implementations§
source§impl Clone for ValidatorSchema
impl Clone for ValidatorSchema
source§fn clone(&self) -> ValidatorSchema
fn clone(&self) -> ValidatorSchema
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ValidatorSchema
impl Debug for ValidatorSchema
source§impl FromStr for ValidatorSchema
impl FromStr for ValidatorSchema
source§impl RequestSchema for ValidatorSchema
impl RequestSchema for ValidatorSchema
source§type Error = RequestValidationError
type Error = RequestValidationError
source§fn validate_request(
&self,
request: &Request,
extensions: Extensions<'_>,
) -> Result<(), Self::Error>
fn validate_request( &self, request: &Request, extensions: Extensions<'_>, ) -> Result<(), Self::Error>
request
, returning Err
if it fails validationsource§impl Serialize for ValidatorSchema
impl Serialize for ValidatorSchema
source§impl TryFrom<SchemaFragment> for ValidatorSchema
impl TryFrom<SchemaFragment> for ValidatorSchema
source§type Error = SchemaError
type Error = SchemaError
source§fn try_from(frag: SchemaFragment) -> Result<ValidatorSchema>
fn try_from(frag: SchemaFragment) -> Result<ValidatorSchema>
Auto Trait Implementations§
impl Freeze for ValidatorSchema
impl RefUnwindSafe for ValidatorSchema
impl Send for ValidatorSchema
impl Sync for ValidatorSchema
impl Unpin for ValidatorSchema
impl UnwindSafe for ValidatorSchema
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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