"""Security-lake playbook, step 5: approve the data contract.

A fresh draft profiles what the syncs landed; approving it is the sign-off
that the event types and attributes are what the lake should carry.
"""

import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))  # playbooks/playbook_api.py
from playbook_api import Api, State

api, state = Api(), State("security-lake")

draft = api.post("/contracts", key="security-lake-contract")
version = draft["version"]
seen = sorted(draft.get("event_types") or {})
print(f"draft contract profiles: {', '.join(seen)}")
approved = api.post(f"/contracts/{version}:approve")
print(f"contract: {approved['status']}")
state.update(contract_version=version)
