src/dlw/marvin_api.py hinzugefügt
This commit is contained in:
parent
f184986ec9
commit
eae860d0cd
|
|
@ -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()
|
||||||
Loading…
Reference in New Issue