jaredzhou/mooncedar/ast does not have a README file

    ValidationError

    pub(all) suberror ValidationError {
    ValidationError(String, String)
    } derive(
    Debug
    )

    Validation error with a message and the offending policy id.

    Annotation

    pub(all) struct Annotation {
    key : String
    value : String
    } derive(Eq,
    Debug
    )

    Annotation — key-value metadata attached to a policy. Has no effect on policy evaluation.

    BinaryOp

    pub(all) enum BinaryOp {
    Eq
    Ne
    Less
    LessEq
    Gt
    Ge
    Add
    Sub
    Mul
    In_
    Contains
    ContainsAll
    ContainsAny
    } derive(Eq,
    Debug
    )

    Built-in binary operators.

    Condition

    pub(all) struct Condition {
    kind : ConditionKind
    body : Expr
    } derive(Eq,
    Debug
    )

    ConditionKind

    pub(all) enum ConditionKind {
    When
    Unless
    } derive(Eq,
    Debug
    )

    Entity

    pub(all) struct Entity {
    uid : EntityUID
    attrs : Map[String, Value]
    tags : Map[String, Value]
    parents : Array[EntityUID]
    } derive(Eq,
    Debug
    )

    An entity as provided by the application. Contains attributes (schema-defined), tags (free-form), and parent relationships for hierarchy traversal (in operator).
    impl ToJson for Entity
    impl FromJson for Entity

    EntityType

    An entity type name, e.g. User, Photo.

    EntityUID

    pub(all) struct EntityUID {
    type_ : String
    id : String
    } derive(Eq, Hash,
    Debug
    )

    A unique entity identifier, e.g. User::"alice".
    impl ToJson for EntityUID

    Expr

    pub(all) enum Expr {
    Lit(Literal)
    Var(VarKind)
    If(Expr, Expr, Expr)
    And(Expr, Expr)
    Or(Expr, Expr)
    UnaryApp(UnaryOp, Expr)
    BinaryApp(BinaryOp, Expr, Expr)
    GetAttr(Expr, String)
    HasAttr(Expr, String)
    GetTag(Expr, Expr)
    HasTag(Expr, Expr)
    Like(Expr, Pattern)
    Is(Expr, EntityType)
    Set(Array[Expr])
    Record(Array[(String, Expr)])
    ExtensionApp(Name, Array[Expr])
    Slot(String)
    Unknown(String, Type?)
    } derive(Eq,
    Debug
    )

    The complete expression AST for Cedar. Covers every node type from the Cedar language specification.

    Expr::access

    fn Expr::access(self : Expr, attr : String) -> Expr

    self.attr

    Expr::add

    fn Expr::add(self : Expr, rhs : Expr) -> Expr

    self + rhs

    Expr::and_

    fn Expr::and_(self : Expr, rhs : Expr) -> Expr

    self && rhs (keyword: and)

    Expr::contains

    fn Expr::contains(self : Expr, rhs : Expr) -> Expr

    self.contains(rhs)

    Expr::contains_all

    fn Expr::contains_all(self : Expr, rhs : Expr) -> Expr

    self.contains_all(rhs)

    Expr::contains_any

    fn Expr::contains_any(self : Expr, rhs : Expr) -> Expr

    self.contains_any(rhs)

    Expr::eq

    fn Expr::eq(self : Expr, rhs : Expr) -> Expr

    self == rhs

    Expr::ge

    fn Expr::ge(self : Expr, rhs : Expr) -> Expr

    self >= rhs

    Expr::get_tag

    fn Expr::get_tag(self : Expr, tag : Expr) -> Expr

    self.get_tag(tag)

    Expr::gt

    fn Expr::gt(self : Expr, rhs : Expr) -> Expr

    self > rhs

    Expr::has

    fn Expr::has(self : Expr, attr : String) -> Expr

    self has attr

    Expr::has_tag

    fn Expr::has_tag(self : Expr, tag : Expr) -> Expr

    self.has_tag(tag)

    Expr::in_

    fn Expr::in_(self : Expr, rhs : Expr) -> Expr

    self in rhs (keyword: in)

    Expr::is_

    fn Expr::is_(self : Expr, ty : EntityType) -> Expr

    self is EntityType (keyword: is)

    Expr::is_in

    fn Expr::is_in(self : Expr, ty : EntityType, entity : Expr) -> Expr

    self is ty AND self in entity — desugared to and_ + is_ + in_

    Expr::le

    fn Expr::le(self : Expr, rhs : Expr) -> Expr

    self <= rhs

    Expr::like

    fn Expr::like(self : Expr, pattern : Pattern) -> Expr

    self like pattern

    Expr::lt

    fn Expr::lt(self : Expr, rhs : Expr) -> Expr

    self < rhs

    Expr::mul

    fn Expr::mul(self : Expr, rhs : Expr) -> Expr

    self * rhs

    Expr::ne

    fn Expr::ne(self : Expr, rhs : Expr) -> Expr

    self != rhs

    Expr::or_

    fn Expr::or_(self : Expr, rhs : Expr) -> Expr

    self || rhs (keyword: or)

    Expr::sub

    fn Expr::sub(self : Expr, rhs : Expr) -> Expr

    self - rhs

    Literal

    pub(all) enum Literal {
    Bool(Bool)
    Long(Int64)
    String(String)
    EntityUID(EntityUID)
    } derive(Eq,
    Debug
    )

    A literal value that can appear directly in Cedar source text. Set and Record are NOT literals — they are compound expressions.

    Name

    pub(all) struct Name {
    ns : Array[String]
    name : String
    } derive(Eq, ToJson,
    Debug
    ,
    FromJson
    )

    A namespaced path for extension functions, e.g. ip, decimal.

    PartialValue

    pub(all) enum PartialValue {
    Value(Value)
    Residual(Expr)
    } derive(Eq,
    Debug
    )

    Result of evaluating an expression — either a concrete value or a residual expression that could not be reduced (partial evaluation).

    Also used as the value type in Entity attrs/tags, because entity attributes and tags can be unknown during partial evaluation (source #5 of Unknown).

    Pattern

    pub(all) struct Pattern {
    elements : Array[PatternElem]
    } derive(Eq,
    Debug
    )

    Pattern for the like operator (IAM-style StringLike). The wildcard * matches any string; \* matches a literal *.

    PatternElem

    pub(all) enum PatternElem {
    Char(Char)
    Wildcard
    } derive(Eq,
    Debug
    )

    Policy

    pub(all) struct Policy {
    id : String
    effect : PolicyEffect
    annotations : Array[Annotation]
    principal : ScopeConstraint
    action : ScopeConstraint
    resource : ScopeConstraint
    conditions : Array[Condition]
    } derive(Eq,
    Debug
    )

    A complete Cedar policy.

    Policy::action_eq

    fn Policy::action_eq(self : Policy, type_ : String, id : String) -> Policy

    Policy::action_in

    fn Policy::action_in(self : Policy, type_ : String, id : String) -> Policy

    Policy::action_in_set

    fn Policy::action_in_set(self : Policy, entities : Array[(String, String)]) -> Policy

    Policy::annotate

    fn Policy::annotate(self : Policy, key : String, value : String) -> Policy

    Policy::forbid

    fn Policy::forbid(self : Policy) -> Policy

    Policy::permit

    fn Policy::permit(self : Policy) -> Policy

    Policy::principal_eq

    fn Policy::principal_eq(self : Policy, type_ : String, id : String) -> Policy

    Policy::principal_in

    fn Policy::principal_in(self : Policy, type_ : String, id : String) -> Policy

    Policy::principal_is

    fn Policy::principal_is(self : Policy, type_ : String) -> Policy

    Policy::principal_is_in

    fn Policy::principal_is_in(self : Policy, ty : String, parent_ty : String, parent_id : String) -> Policy

    Policy::resource_eq

    fn Policy::resource_eq(self : Policy, type_ : String, id : String) -> Policy

    Policy::resource_in

    fn Policy::resource_in(self : Policy, type_ : String, id : String) -> Policy

    Policy::resource_is

    fn Policy::resource_is(self : Policy, type_ : String) -> Policy

    Policy::resource_is_in

    fn Policy::resource_is_in(self : Policy, ty : String, parent_ty : String, parent_id : String) -> Policy

    Policy::unless

    fn Policy::unless(self : Policy, body : Expr) -> Policy

    Policy::when_

    fn Policy::when_(self : Policy, body : Expr) -> Policy

    Policy::with_id

    fn Policy::with_id(self : Policy, id : String) -> Policy

    PolicyEffect

    pub(all) enum PolicyEffect {
    Permit
    Forbid
    } derive(Eq,
    Debug
    )

    Position

    pub(all) struct Position {
    filename : String
    offset : Int
    line : Int
    column : Int
    } derive(Eq,
    Debug
    )

    Source position for diagnostics / error messages.

    ScopeConstraint

    pub(all) enum ScopeConstraint {
    All
    Eq(EntityUID)
    In(EntityUID)
    InSet(Array[EntityUID])
    Is(EntityType)
    IsIn(EntityType, EntityUID)
    } derive(Eq,
    Debug
    )

    Scope constraint for principal, action, or resource in a policy.

    Not every variant is valid for every PARC position:
    • Principal: All | Eq | In | Is | IsIn
    • Action: All | Eq | In | InSet
    • Resource: All | Eq | In | Is | IsIn

    Type

    pub(all) enum Type {
    Bool
    Long
    String
    Set
    Record
    Entity(EntityType)
    Extension(Name)
    } derive(Eq,
    Debug
    )

    The runtime type of a Cedar value. Two entity types are equal iff they have the same Name. Two extension types are equal iff they have the same Name.

    UnaryOp

    pub(all) enum UnaryOp {
    Not
    Neg
    IsEmpty
    } derive(Eq,
    Debug
    )

    Built-in unary operators.

    Value

    pub(all) enum Value {
    Bool(Bool)
    Long(Int64)
    String(String)
    EntityUID(EntityUID)
    Set(Array[Value])
    Record(Map[String, Value])
    Extension(Name, String)
    } derive(Eq, ToJson,
    Debug
    ,
    FromJson
    )

    All values that can be the dynamic result of evaluating an Expr. Includes extension values (ip, decimal, datetime, duration, etc.) as opaque Extension(Name, String) entries for MVP.

    VarKind

    pub(all) enum VarKind {
    Principal
    Action
    Resource
    Context
    } derive(Eq,
    Debug
    )

    The four PARC variables that Cedar expressions can reference.

    default

    fn default() -> Policy

    Return a zero-valued Policy with Permit effect, All scopes, empty arrays.

    entity_type

    fn entity_type(name : String) -> EntityType

    Construct an EntityType newtype in builder contexts.

    entity_uid

    fn entity_uid(type_ : String, id : String) -> EntityUID

    Construct an EntityUID in builder contexts.

    expr_action

    fn expr_action() -> Expr

    expr_bool

    fn expr_bool(b : Bool) -> Expr

    expr_context

    fn expr_context() -> Expr

    expr_euid

    fn expr_euid(type_ : String, id : String) -> Expr

    expr_ext_call

    fn expr_ext_call(name : Name, args : Array[Expr]) -> Expr

    expr_if

    fn expr_if(cond : Expr, t : Expr, e : Expr) -> Expr

    expr_is_empty

    fn expr_is_empty(e : Expr) -> Expr

    expr_long

    fn expr_long(l : Int64) -> Expr

    expr_neg

    fn expr_neg(e : Expr) -> Expr

    expr_not

    fn expr_not(e : Expr) -> Expr

    expr_principal

    fn expr_principal() -> Expr

    expr_record

    fn expr_record(pairs : Array[(String, Expr)]) -> Expr

    expr_resource

    fn expr_resource() -> Expr

    expr_set

    fn expr_set(elements : Array[Expr]) -> Expr

    expr_str

    fn expr_str(s : String) -> Expr

    expr_unknown

    fn expr_unknown(name : String) -> Expr

    Convenience constructor for an untyped Unknown (CPE classic).

    validate_policies

    fn validate_policies(policies : Array[Policy]) -> Unit raise ValidationError

    Validate all policies in a policy set. Raises on the first invalid policy found.

    validate_policy

    fn validate_policy(policy : Policy) -> Unit raise ValidationError

    Validate a single policy's scope constraints.

    PositionValid variantsInvalid
    PrincipalAll, Eq, In, Is, IsInInSet
    ActionAll, Eq, In, InSetIs, IsIn
    ResourceAll, Eq, In, Is, IsInInSet