Skip to content

Commit 7f78c01

Browse files
committed
complete public apu
1 parent 2586af2 commit 7f78c01

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

cedar-policy-core/src/ast/request.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ impl EntityUIDEntry {
120120
}
121121
}
122122

123+
pub fn unknown_of_type(ty: EntityType, loc: Option<Loc>) -> Self {
124+
Self::UnknownOfType { ty, loc }
125+
}
126+
123127
/// Get the UID of the entry, or `None` if it is unknown (partial evaluation)
124128
pub fn uid(&self) -> Option<&EntityUID> {
125129
match self {
@@ -128,6 +132,7 @@ impl EntityUIDEntry {
128132
}
129133
}
130134

135+
/// Get the type of the entry, or `None` if it is unknown (partial evaluation with no type annotation)
131136
pub fn get_type(&self) -> Option<&EntityType> {
132137
match self {
133138
Self::Known { euid, .. } => Some(euid.entity_type()),

cedar-policy/src/api.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3601,6 +3601,17 @@ impl<S> RequestBuilder<S> {
36013601
}
36023602
}
36033603

3604+
/// Set the principal to be unknown, which is known to belong a certain entity type.
3605+
///
3606+
/// Currently, this is used only to in 'is' expressions in the policy.
3607+
#[must_use]
3608+
pub fn some_principal_of_type(self, principal_type: ast::EntityType) -> Self {
3609+
Self {
3610+
principal: ast::EntityUIDEntry::unknown_of_type(principal_type, None),
3611+
..self
3612+
}
3613+
}
3614+
36043615
/// Set the action.
36053616
///
36063617
/// Note that you can create the `EntityUid` using `.parse()` on any
@@ -3625,6 +3636,17 @@ impl<S> RequestBuilder<S> {
36253636
}
36263637
}
36273638

3639+
/// Set the resource to be unknown, which is known to belong a certain entity type.
3640+
///
3641+
/// Currently, this is used only to in 'is' expressions in the policy.
3642+
#[must_use]
3643+
pub fn some_resource_of_type(self, resource_type: ast::EntityType) -> Self {
3644+
Self {
3645+
resource: ast::EntityUIDEntry::unknown_of_type(resource_type, None),
3646+
..self
3647+
}
3648+
}
3649+
36283650
/// Set the context.
36293651
#[must_use]
36303652
pub fn context(self, context: Context) -> Self {

0 commit comments

Comments
 (0)