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.
Classes
|
Policy set lowered against Dogwood service and Cedar action schemas. |
|
Schema-free parsed policy summary. |
|
Dogwood policy source after schema-free parse. |
|
Cedar action schema text used to lower Dogwood policies. |
|
Dogwood service schema inputs. |
|
Validation findings for a lowered policy set. |
Validate a lowered Dogwood policy set. |
- class dogwood.policy.ServiceSchema(event_schema: str | None = None, macros: str | None = None, providers: dict[str, Any] | None = None)[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#
- classmethod defaults() ServiceSchema[source]#
Return the default Dogwood service schema.
Rust mapping:
ServiceSchema::defaults().
- __init__(event_schema: str | None = None, macros: str | None = None, providers: dict[str, Any] | None = None) None#
- class dogwood.policy.PolicySchema(source: str)[source]#
Cedar action schema text used to lower Dogwood policies.
Rust mapping:
dogwood_language::PolicySchemaconstructed withPolicySchema::from_cedarschema_str.- source: str#
- classmethod from_cedarschema_str(source: str) PolicySchema[source]#
Create a policy schema from Cedar
.cedarschemasource.Rust mapping:
PolicySchema::from_cedarschema_str(source).
- __init__(source: str) None#
- class dogwood.policy.ParsedPolicy(id: str, effect: str, action: str | None, when: tuple[str, ...] = (), unless: tuple[str, ...] = (), temporal: tuple[str, ...] = (), index: int = 0)[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#
- __init__(id: str, effect: str, action: str | None, when: tuple[str, ...] = (), unless: tuple[str, ...] = (), temporal: tuple[str, ...] = (), index: int = 0) None#
- class dogwood.policy.ParsedPolicySet(source: str, service_schema: ServiceSchema, _policies: tuple[ParsedPolicy, ...])[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: str, service_schema: ServiceSchema | None = None) ParsedPolicySet[source]#
Parse policy source without a Cedar action schema.
Rust mapping:
ParsedPolicySet::parse(source, &service_schema).
- lower(policy_schema: PolicySchema) LoweredPolicySet[source]#
Lower this parsed policy set against a Cedar action schema.
Rust mapping:
ParsedPolicySet::lower(&policy_schema).
- lower_with_distincter(policy_schema: PolicySchema, distincter: str) LoweredPolicySet[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.
- policies() tuple[ParsedPolicy, ...][source]#
- __init__(source: str, service_schema: ServiceSchema, _policies: tuple[ParsedPolicy, ...]) None#
- class dogwood.policy.ValidationResult(errors: tuple[str, ...] = (), warnings: tuple[str, ...] = ())[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, ...] = ()#
- validation_passed() bool[source]#
Return true when validation has no errors.
Rust mapping:
ValidationResult::validation_passed().
- __init__(errors: tuple[str, ...] = (), warnings: tuple[str, ...] = ()) None#
- 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: LoweredPolicySet) ValidationResult[source]#
Validate policies and return accumulated errors/warnings.
Rust mapping:
Validator::new().validate(&policies).
- class dogwood.policy.LoweredPolicySet(parsed: ParsedPolicySet, policy_schema: PolicySchema, distincter: str = 'policy')[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: str, service_schema: ServiceSchema | None = None, policy_schema: PolicySchema | None = None) LoweredPolicySet[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.
- as_cedar() str[source]#
Return lowered Cedar policy text.
Rust mapping:
LoweredPolicySet::as_cedar()rendered to text.
- cedar_schema() str[source]#
Return the augmented Cedar schema text.
Rust mapping:
LoweredPolicySet::cedar_schema_str().
- is_self_contained_cedar() bool[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.
- __init__(parsed: ParsedPolicySet, policy_schema: PolicySchema, distincter: str = 'policy') None#