"""Create synthetic data on the authenticated GitLab account; prints scenario constants.
Requires glab auth. Delete only the returned project with: glab api -X DELETE projects/<id>.
"""
import json
import subprocess
import time

def api(endpoint, method="GET", **fields):
    args = ["glab", "api", "-X", method, endpoint]
    for key, value in fields.items():
        args += ["-f", f"{key}={value}"]
    output = subprocess.check_output(args, text=True)
    return json.loads(output) if output.strip() else None

project = api("projects", "POST", name=f"reaction-refresh-proof-{int(time.time())}", visibility="private")
pid = project["id"]
api(f"projects/{pid}/repository/files/README.md", "POST", branch="main", content="Reaction refresh proof", commit_message="Initial synthetic fixture")
api(f"projects/{pid}/repository/branches", "POST", branch="proof", ref="main")
api(f"projects/{pid}/repository/files/README.md", "PUT", branch="proof", content="Synthetic reaction refresh example", commit_message="Update example")
mr = api(f"projects/{pid}/merge_requests", "POST", source_branch="proof", target_branch="main", title="Reaction refresh example", description="Synthetic example for reaction refresh verification.")
note = api(f"projects/{pid}/merge_requests/{mr['iid']}/notes", "POST", body="Please verify the reaction stays removed after refreshing.")
print(json.dumps({"projectId": pid, "endpoint": f"projects/{pid}/merge_requests/{mr['iid']}/notes/{note['id']}/award_emoji", "remote": project["http_url_to_repo"]}, indent=2))
