#!/usr/bin/env python3
import json
import requests

# Read dashboard JSON
with open('/home/eric/smart-city-digital-twin-martinique/grafana-dashboard-smartcity.json', 'r') as f:
    dashboard = json.load(f)

# Prepare payload for Grafana API
payload = {
    "dashboard": dashboard,
    "overwrite": True,
    "message": "Smart City Dashboard - Martinique"
}

# Import to Grafana
url = "http://grafana.digitribe.fr/api/dashboards/db"
auth = ('admin', 'Digitribe972')

try:
    r = requests.post(url, json=payload, auth=auth)
    print(f"Status: {r.status_code}")
    print(r.json())
except Exception as e:
    print(f"Error: {e}")
