.PHONY: credentials verify clean help

CLINIC_OUT  := clinic_credentials.json
GRAFANA_OUT := grafana_storage_state.json

help:
	@echo "clinic-grafana — Obtain Clinic/Grafana API credentials"
	@echo ""
	@echo "  make credentials    Show instructions for extracting credentials from the browser"
	@echo "  make verify         Validate both credential files and test Clinic API auth"
	@echo "  make clean          Delete generated files"
	@echo ""
	@echo "Workflow:"
	@echo "  1. make credentials   (follow the instructions)"

credentials:
	@echo ""
	@echo "=========================================="
	@echo " Extract Clinic + Grafana Credentials"
	@echo "=========================================="
	@echo ""
	@echo "1. Open https://clinic.pingcap.com/portal/ in your browser"
	@echo "2. Log in and wait until the Clusters page is fully loaded"
	@echo "3. Open DevTools (F12) -> Console tab"
	@echo "4. Paste and run the contents of: get_credentials.js"
	@echo "5. Two files download automatically:"
	@echo "   -> $(CLINIC_OUT)     — Clinic HTTP credentials"
	@echo "   -> $(GRAFANA_OUT)    — Grafana browser storage state"
	@echo ""

verify:
	uv run python verify.py

clean:
	rm -f $(CLINIC_OUT) $(GRAFANA_OUT)
