diff --git a/src/dlw/marvin_api.py b/src/dlw/marvin_api.py new file mode 100644 index 0000000..2c9f1d3 --- /dev/null +++ b/src/dlw/marvin_api.py @@ -0,0 +1,28 @@ +import requests + +class MarvinClient: + def __init__(self, api_key, asteroid_name): + self.api_key = api_key + self.asteroid = asteroid_name + self.base_url = "https://api.uberspace.de/api/v1/external" + self.headers = {"Authorization": f"Api-Key {api_key}"} + + def setup_webapp_backend(self, port): + """Registriert das Flask-Interface in der Marvin API.""" + url = f"{self.base_url}/asteroids/{self.asteroid}/webbackends/" + data = { + "asteroid": self.asteroid, + "domain": None, + "path": "/admin", # Optionaler Pfad für das Interface + "destination": "PORT", + "port": port + } + res = requests.post(url, headers=self.headers, json=data) + return res.status_code in [201, 200] + + def add_domain(self, domain_name): + """Fügt eine neue Web-Domain hinzu.""" + url = f"{self.base_url}/asteroids/{self.asteroid}/webdomains/" + data = {"name": domain_name, "asteroid": self.asteroid} + res = requests.post(url, headers=self.headers, json=data) + return res.json() \ No newline at end of file