diff --git a/robosystems_client/models/taxonomy_block_rule.py b/robosystems_client/models/taxonomy_block_rule.py index 7664d4b..c1704b6 100644 --- a/robosystems_client/models/taxonomy_block_rule.py +++ b/robosystems_client/models/taxonomy_block_rule.py @@ -15,24 +15,31 @@ class TaxonomyBlockRule: """Rule projection for the Taxonomy Block envelope. - Attributes: - id (str): - name (str): - rule_category (str): - rule_pattern (str): - rule_expression (str): - severity (str | Unset): Default: 'error'. - origin (str | Unset): 'forked' | 'native' | 'auto' — matches DB CHECK. Default: 'native'. - target_kind (None | str | Unset): - target_ref (None | str | Unset): Polymorphic display string — structure_id, element qname, association_id, or - taxonomy_id depending on ``target_kind``. + Exactly one of ``rule_pattern`` (arithmetic) or ``rule_check_kind`` + (model-structure) is non-null per row, enforced by the + ``check_rule_pattern_kind_xor`` DB constraint. See + information-block.md §5.2.2. + + Attributes: + id (str): + name (str): + rule_category (str): + rule_expression (str): + rule_pattern (None | str | Unset): + rule_check_kind (None | str | Unset): + severity (str | Unset): Default: 'error'. + origin (str | Unset): 'forked' | 'native' | 'auto' — matches DB CHECK. Default: 'native'. + target_kind (None | str | Unset): + target_ref (None | str | Unset): Polymorphic display string — structure_id, element qname, association_id, or + taxonomy_id depending on ``target_kind``. """ id: str name: str rule_category: str - rule_pattern: str rule_expression: str + rule_pattern: None | str | Unset = UNSET + rule_check_kind: None | str | Unset = UNSET severity: str | Unset = "error" origin: str | Unset = "native" target_kind: None | str | Unset = UNSET @@ -46,10 +53,20 @@ def to_dict(self) -> dict[str, Any]: rule_category = self.rule_category - rule_pattern = self.rule_pattern - rule_expression = self.rule_expression + rule_pattern: None | str | Unset + if isinstance(self.rule_pattern, Unset): + rule_pattern = UNSET + else: + rule_pattern = self.rule_pattern + + rule_check_kind: None | str | Unset + if isinstance(self.rule_check_kind, Unset): + rule_check_kind = UNSET + else: + rule_check_kind = self.rule_check_kind + severity = self.severity origin = self.origin @@ -73,10 +90,13 @@ def to_dict(self) -> dict[str, Any]: "id": id, "name": name, "rule_category": rule_category, - "rule_pattern": rule_pattern, "rule_expression": rule_expression, } ) + if rule_pattern is not UNSET: + field_dict["rule_pattern"] = rule_pattern + if rule_check_kind is not UNSET: + field_dict["rule_check_kind"] = rule_check_kind if severity is not UNSET: field_dict["severity"] = severity if origin is not UNSET: @@ -97,10 +117,26 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: rule_category = d.pop("rule_category") - rule_pattern = d.pop("rule_pattern") - rule_expression = d.pop("rule_expression") + def _parse_rule_pattern(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + rule_pattern = _parse_rule_pattern(d.pop("rule_pattern", UNSET)) + + def _parse_rule_check_kind(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + rule_check_kind = _parse_rule_check_kind(d.pop("rule_check_kind", UNSET)) + severity = d.pop("severity", UNSET) origin = d.pop("origin", UNSET) @@ -127,8 +163,9 @@ def _parse_target_ref(data: object) -> None | str | Unset: id=id, name=name, rule_category=rule_category, - rule_pattern=rule_pattern, rule_expression=rule_expression, + rule_pattern=rule_pattern, + rule_check_kind=rule_check_kind, severity=severity, origin=origin, target_kind=target_kind, diff --git a/robosystems_client/models/taxonomy_block_rule_request.py b/robosystems_client/models/taxonomy_block_rule_request.py index 4c6dc3c..777fc68 100644 --- a/robosystems_client/models/taxonomy_block_rule_request.py +++ b/robosystems_client/models/taxonomy_block_rule_request.py @@ -37,6 +37,15 @@ class TaxonomyBlockRuleRequest: ``target_taxonomy_self`` must be set (or all null for a global rule). The ``model_validator`` enforces this contract at the Pydantic layer. + Only **arithmetic** rule patterns are user-creatable via this API + (the ``rule_pattern`` Literal below). The 6 model-structure check + kinds (``NoCycles``, ``NoOrphanArcs``, ``ParentBeforeChild``, + ``LeafHasClassification``, ``LibraryOriginImmutability``, + ``UniqueQNameInTaxonomy``) are system-managed — they're auto-emitted + by :func:`emit_auto_rules` at taxonomy-block creation time and + populate ``rules.rule_check_kind`` instead of ``rule_pattern``. See + information-block.md §5.2.2 for the axis split. + Attributes: name (str): Rule identifier, unique within envelope. rule_category (TaxonomyBlockRuleRequestRuleCategory): One of 8 cm:VerificationRule subclasses.