first commit

This commit is contained in:
2025-12-05 16:06:05 +01:00
commit d3adfcf32d
39 changed files with 1458 additions and 0 deletions

60
update_server_groups_link11.py Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/python
from env import *
import requests
import json
# === Konfiguration ===
CONFIG_ID = "prod"
# Proxy Templates nur einen aktiv lassen
PROXY_TEMPLATE = "f4bf25a205a5"
# PROXY_TEMPLATE = "andere_template_id"
# Security Policies nur einen aktiv lassen
SECURITY_POLICY = "16fbf6d51b17" # z.B. Shop022
# SECURITY_POLICY = "3f7a521c6570" # Shop023
# SECURITY_POLICY = "9cc8dd695d5c" # Shop024
# SECURITY_POLICY = "1f707fb18483" # Shop028
# === Header für alle Requests ===
HEADERS = {
"Authorization": f"Bearer {API_TOKEN}",
"Content-Type": "application/json"
}
def get_server_groups():
url = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/server-groups"
response = requests.get(url, headers=HEADERS,)
if response.status_code == 200:
print(f"[✓] Abfrage von server groups erfolgreich.")
else:
print(f"[✗] Fehler bei Abfrage von server groups): {response.status_code}{response.text}")
#print(response.text)
res=json.loads(response.text)
for key,value in res.items():
if ( key != "items" ):
print (key, value, "\n")
else:
print(key)
for items in value: # Items enthält eine einzelne Server Group
for key2, value2 in items.items():
if ( (key2 == "security_policy") and (value2 == "16fbf6d51b17") ):
items['security_policy'] = "secpol-shop022-jtl-hosting-de"
url2 = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/server-groups/{items['id']}"
#print(url2)
response = requests.put(url2, headers=HEADERS,data=json.dumps(items))
if response.status_code == 200:
print(f"[✓] Server group {items['id']} erfolgreich aktualisiert.")
else:
print(f"[✗] Fehler bei Aktualisierung von server group {items['id']}): {response.status_code}{response.text}")
print(key2, value2)
def main():
get_server_groups()
# === CSV-Datei einlesen ===
if __name__ == "__main__":
main()