You've already forked haproxy-wi
mirror of
https://github.com/roxy-wi/roxy-wi.git
synced 2025-12-15 11:54:05 +08:00
Remove the letsencrypt.sh script and integrate LetsEncrypt functionality directly into the web application via new API endpoints. This includes creating, updating, retrieving, and deleting LetsEncrypt configurations, improving maintainability and user interaction with the LetsEncrypt feature.
55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
from app.modules.db.db_model import LetsEncrypt, Server
|
|
from app.modules.db.common import out_error
|
|
from app.modules.roxywi.exception import RoxywiResourceNotFound
|
|
|
|
|
|
def get_le(le_id: int) -> LetsEncrypt:
|
|
try:
|
|
return LetsEncrypt.get(LetsEncrypt.id == le_id)
|
|
except LetsEncrypt.DoesNotExist:
|
|
raise RoxywiResourceNotFound
|
|
except Exception as e:
|
|
out_error(e)
|
|
|
|
|
|
def get_le_with_group(le_id: int, group_id: int) -> LetsEncrypt:
|
|
try:
|
|
return LetsEncrypt.select().join(Server).where(
|
|
(LetsEncrypt.id == le_id) &
|
|
(Server.group_id == group_id)
|
|
).get()
|
|
except LetsEncrypt.DoesNotExist:
|
|
raise RoxywiResourceNotFound
|
|
except Exception as e:
|
|
out_error(e)
|
|
|
|
|
|
def select_le_with_group(group_id: int) -> LetsEncrypt:
|
|
try:
|
|
return LetsEncrypt.select().join(Server).where(Server.group_id == group_id).execute()
|
|
except Exception as e:
|
|
out_error(e)
|
|
|
|
|
|
def insert_le(**kwargs) -> int:
|
|
try:
|
|
return LetsEncrypt.insert(**kwargs).execute()
|
|
except Exception as e:
|
|
out_error(e)
|
|
|
|
|
|
def update_le(le_id: int, **kwargs) -> int:
|
|
try:
|
|
return LetsEncrypt.update(**kwargs).where(LetsEncrypt.id == le_id).execute()
|
|
except LetsEncrypt.DoesNotExist:
|
|
raise RoxywiResourceNotFound
|
|
except Exception as e:
|
|
out_error(e)
|
|
|
|
|
|
def delete_le(le_id: int) -> None:
|
|
try:
|
|
LetsEncrypt.delete().where(LetsEncrypt.id == le_id).execute()
|
|
except Exception as e:
|
|
out_error(e)
|