generated from coulomb/repo-seed
relationship persistence, context entities, idempotent asset creation, audit/version handling for relationship changes
This commit is contained in:
@@ -41,6 +41,16 @@ class ContextEntity:
|
||||
}
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict[str, Any]) -> "ContextEntity":
|
||||
return cls(
|
||||
entity_id=data["entity_id"],
|
||||
entity_type=ContextEntityType(data["entity_type"]),
|
||||
name=data["name"],
|
||||
external_ref=data.get("external_ref"),
|
||||
metadata=dict(data.get("metadata", {})),
|
||||
)
|
||||
|
||||
|
||||
class RelationshipTargetKind(str, Enum):
|
||||
ASSET = "asset"
|
||||
@@ -80,3 +90,19 @@ class CoreRelationship:
|
||||
}
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict[str, Any]) -> "CoreRelationship":
|
||||
return cls(
|
||||
relationship_id=data["relationship_id"],
|
||||
source_id=data["source_id"],
|
||||
target_id=data["target_id"],
|
||||
predicate=data["predicate"],
|
||||
target_kind=RelationshipTargetKind(data.get("target_kind", RelationshipTargetKind.ASSET.value)),
|
||||
direction=data.get("direction", "outbound"),
|
||||
confidence=data.get("confidence"),
|
||||
valid_from=data.get("valid_from"),
|
||||
valid_to=data.get("valid_to"),
|
||||
actor_id=data.get("actor_id"),
|
||||
provenance=dict(data.get("provenance", {})),
|
||||
created_at=data["created_at"],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user