Struct cedar_policy_core::ast::PolicySet
source · pub struct PolicySet { /* private fields */ }
Expand description
Represents a set of Policy
s
Implementations§
source§impl PolicySet
impl PolicySet
sourcepub fn add(&mut self, policy: Policy) -> Result<(), PolicySetError>
pub fn add(&mut self, policy: Policy) -> Result<(), PolicySetError>
Add a Policy
to the PolicySet
.
sourcepub fn remove_static(
&mut self,
policy_id: &PolicyID
) -> Result<Policy, PolicySetPolicyRemovalError>
pub fn remove_static( &mut self, policy_id: &PolicyID ) -> Result<Policy, PolicySetPolicyRemovalError>
Remove a static Policy`` from the
PolicySet`.
sourcepub fn add_static(&mut self, policy: StaticPolicy) -> Result<(), PolicySetError>
pub fn add_static(&mut self, policy: StaticPolicy) -> Result<(), PolicySetError>
Add a StaticPolicy
to the PolicySet
.
sourcepub fn add_template(&mut self, t: Template) -> Result<(), PolicySetError>
pub fn add_template(&mut self, t: Template) -> Result<(), PolicySetError>
Add a template to the policy set. If a link, static policy or template with the same name already exists, this will error.
sourcepub fn remove_template(
&mut self,
policy_id: &PolicyID
) -> Result<Template, PolicySetTemplateRemovalError>
pub fn remove_template( &mut self, policy_id: &PolicyID ) -> Result<Template, PolicySetTemplateRemovalError>
Remove a template from the policy set.
This will error if any policy is linked to the template.
This will error if policy_id
is not a template.
sourcepub fn get_linked_policies(
&self,
template_id: &PolicyID
) -> Result<impl Iterator<Item = &PolicyID>, PolicySetGetLinksError>
pub fn get_linked_policies( &self, template_id: &PolicyID ) -> Result<impl Iterator<Item = &PolicyID>, PolicySetGetLinksError>
Get the list of policies linked to template_id
.
Returns all p in links
s.t. p.template().id() == template_id
sourcepub fn link(
&mut self,
template_id: PolicyID,
new_id: PolicyID,
values: HashMap<SlotId, EntityUID>
) -> Result<&Policy, LinkingError>
pub fn link( &mut self, template_id: PolicyID, new_id: PolicyID, values: HashMap<SlotId, EntityUID> ) -> Result<&Policy, LinkingError>
Attempt to create a new template linked policy and add it to the policy set. Returns a references to the new template linked policy if successful.
Errors for two reasons
- The the passed SlotEnv either does not match the slots in the templates
- The passed link Id conflicts with an Id already in the set
sourcepub fn unlink(
&mut self,
policy_id: &PolicyID
) -> Result<Policy, PolicySetUnlinkError>
pub fn unlink( &mut self, policy_id: &PolicyID ) -> Result<Policy, PolicySetUnlinkError>
Unlink policy_id
If it is not a link this will error
sourcepub fn all_templates(&self) -> impl Iterator<Item = &Template>
pub fn all_templates(&self) -> impl Iterator<Item = &Template>
Iterate over everything stored as template, including static policies. Ie: all_templates() should equal templates() ++ static_policies().map(|p| p.template())
sourcepub fn static_policies(&self) -> impl Iterator<Item = &Policy>
pub fn static_policies(&self) -> impl Iterator<Item = &Policy>
Iterate over all of the static policies.
sourcepub fn get_template(&self, id: &PolicyID) -> Option<Arc<Template>>
pub fn get_template(&self, id: &PolicyID) -> Option<Arc<Template>>
Lookup a template by policy id
sourcepub fn try_from_iter<T: IntoIterator<Item = Policy>>(
iter: T
) -> Result<Self, PolicySetError>
pub fn try_from_iter<T: IntoIterator<Item = Policy>>( iter: T ) -> Result<Self, PolicySetError>
Attempt to collect an iterator over policies into a PolicySet