dogwood.policy#
Python policy lifecycle objects modeled after dogwood_language.
The high-level SDK follows the Rust workflow:
ServiceSchema + PolicySchema -> ParsedPolicySet -> LoweredPolicySet -> Validator.
When a non-empty Cedar action schema is supplied, operations delegate to the
native PyO3 binding and therefore to Rust dogwood_language. The pure-Python
path is a temporary schema-less fallback for simple examples.
- class dogwood.policy.ServiceSchema[source]#
Dogwood service schema inputs.
Rust mapping:
dogwood_language::ServiceSchema. In Rust this is built withServiceSchema::defaults()orServiceSchema::builder()and can contain an event-schema DSL, provider declarations, and macro source.In dogwood-py,
event_schemais passed through to the native binding asServiceSchema::builder().event_schema_str(...).build().macrosandprovidersare reserved for future binding support.- event_schema: str | None = None#
- macros: str | None = None#
- providers: dict[str, Any] | None = None#
- class dogwood.policy.PolicySchema[source]#
Cedar action schema text used to lower Dogwood policies.
Rust mapping:
dogwood_language::PolicySchemaconstructed withPolicySchema::from_cedarschema_str.- source: str#
- class dogwood.policy.ParsedPolicy[source]#
Schema-free parsed policy summary.
Rust mapping: one policy inside
dogwood_language::ParsedPolicySet. The Python fallback stores only a lightweight summary; native schema-backed parsing/lowering is handled by Rust.- id: str#
- effect: str#
- action: str | None#
- when: tuple[str, ...] = ()#
- unless: tuple[str, ...] = ()#
- temporal: tuple[str, ...] = ()#
- index: int = 0#
- class dogwood.policy.ParsedPolicySet[source]#
Dogwood policy source after schema-free parse.
Rust mapping:
dogwood_language::ParsedPolicySet. The Rust split isParsedPolicySet::parse(source, &service_schema)followed later byParsedPolicySet::lower(&policy_schema)when the Cedar action schema is available.- source: str#
- service_schema: ServiceSchema#
- classmethod parse(source, service_schema=None)[source]#
Parse policy source without a Cedar action schema.
Rust mapping:
ParsedPolicySet::parse(source, &service_schema).- Parameters:
source (str)
service_schema (ServiceSchema | None)
- Return type:
- lower(policy_schema)[source]#
Lower this parsed policy set against a Cedar action schema.
Rust mapping:
ParsedPolicySet::lower(&policy_schema).- Parameters:
policy_schema (PolicySchema)
- Return type:
- lower_with_distincter(policy_schema, distincter)[source]#
Lower with a caller-supplied Cedar identifier namespace.
Rust mapping:
ParsedPolicySet::lower_with_distincter. The current Python fallback usesdistincterfor generated fallback Cedar ids; native distincter support is not yet exposed through PyO3.- Parameters:
policy_schema (PolicySchema)
distincter (str)
- Return type:
- policies()[source]#
- Return type:
tuple[ParsedPolicy, …]
- class dogwood.policy.ValidationResult[source]#
Validation findings for a lowered policy set.
Rust mapping:
dogwood_language::ValidationResult. Errors makevalidation_passedfalse; warnings are reported separately.- errors: tuple[str, ...] = ()#
- warnings: tuple[str, ...] = ()#
- class dogwood.policy.Validator[source]#
Validate a lowered Dogwood policy set.
Rust mapping:
dogwood_language::Validator. Unlike Cedar’s validator, Dogwood’s RustValidator::new()takes no schema because the effective augmented schema travels onLoweredPolicySet.- validate(policies)[source]#
Validate policies and return accumulated errors/warnings.
Rust mapping:
Validator::new().validate(&policies).- Parameters:
policies (LoweredPolicySet)
- Return type:
- class dogwood.policy.LoweredPolicySet[source]#
Policy set lowered against Dogwood service and Cedar action schemas.
Rust mapping:
dogwood_language::LoweredPolicySet. For schema-backed workflows, construction delegates to RustLoweredPolicySet::from_str. The lowered set is schema-bound; validation and Cedar export use the same schemas it was lowered against.- parsed: ParsedPolicySet#
- policy_schema: PolicySchema#
- distincter: str = 'policy'#
- cedar_policies: str#
- source: str#
- classmethod from_str(source, service_schema=None, policy_schema=None)[source]#
Parse and lower policy source in one step.
Rust mapping:
LoweredPolicySet::from_str(source, &service_schema, &policy_schema). This is the fused parse/lower form.- Parameters:
source (str)
service_schema (ServiceSchema | None)
policy_schema (PolicySchema | None)
- Return type:
- as_cedar()[source]#
Return lowered Cedar policy text.
Rust mapping:
LoweredPolicySet::as_cedar()rendered to text.- Return type:
str
- cedar_schema()[source]#
Return the augmented Cedar schema text.
Rust mapping:
LoweredPolicySet::cedar_schema_str().- Return type:
str
- is_self_contained_cedar()[source]#
Return whether exported Cedar is self-contained.
Rust mapping:
LoweredPolicySet::is_self_contained_cedar(). Native support is not fully exposed yet; the Python fallback approximates this by checking whether parsed policies contain temporal clauses.- Return type:
bool