File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
cedar-policy-core/src/ast Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,10 @@ impl EntityUIDEntry {
120
120
}
121
121
}
122
122
123
+ pub fn unknown_of_type ( ty : EntityType , loc : Option < Loc > ) -> Self {
124
+ Self :: UnknownOfType { ty, loc }
125
+ }
126
+
123
127
/// Get the UID of the entry, or `None` if it is unknown (partial evaluation)
124
128
pub fn uid ( & self ) -> Option < & EntityUID > {
125
129
match self {
@@ -128,6 +132,7 @@ impl EntityUIDEntry {
128
132
}
129
133
}
130
134
135
+ /// Get the type of the entry, or `None` if it is unknown (partial evaluation with no type annotation)
131
136
pub fn get_type ( & self ) -> Option < & EntityType > {
132
137
match self {
133
138
Self :: Known { euid, .. } => Some ( euid. entity_type ( ) ) ,
Original file line number Diff line number Diff line change @@ -3601,6 +3601,17 @@ impl<S> RequestBuilder<S> {
3601
3601
}
3602
3602
}
3603
3603
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
+
3604
3615
/// Set the action.
3605
3616
///
3606
3617
/// Note that you can create the `EntityUid` using `.parse()` on any
@@ -3625,6 +3636,17 @@ impl<S> RequestBuilder<S> {
3625
3636
}
3626
3637
}
3627
3638
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
+
3628
3650
/// Set the context.
3629
3651
#[ must_use]
3630
3652
pub fn context ( self , context : Context ) -> Self {
You can’t perform that action at this time.
0 commit comments