25 lines
721 B
Python
25 lines
721 B
Python
import requests
|
|
import json
|
|
import urllib3
|
|
urllib3.disable_warnings()
|
|
|
|
auth = ("admin", "Katzir476!!!")
|
|
url = "https://grafana.snarfnet.net/api/folders"
|
|
|
|
folders = [
|
|
{"uid": "folder-aerodrome", "title": "Aerodrome"},
|
|
{"uid": "folder-spaceport", "title": "Spaceport"},
|
|
{"uid": "folder-shipyard", "title": "Shipyard"}
|
|
]
|
|
|
|
for f in folders:
|
|
resp = requests.post(url, json=f, auth=auth, verify=False, timeout=10)
|
|
print(f"Folder {f['title']}: {resp.status_code} - {resp.text}")
|
|
|
|
# List all folders
|
|
resp2 = requests.get(url, auth=auth, verify=False, timeout=10)
|
|
print("\nCurrent Folders:")
|
|
for item in resp2.json():
|
|
print(f" ID: {item.get('id')} | UID: {item.get('uid')} | Title: {item.get('title')}")
|
|
|