forked from DGNum/uptime-kuma-api
implement proxies
This commit is contained in:
parent
eab0715d8e
commit
bfe002c11d
3 changed files with 45 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
from .auth_method import AuthMethod
|
from .auth_method import AuthMethod
|
||||||
from .monitor_type import MonitorType
|
from .monitor_type import MonitorType
|
||||||
from .notification_providers import NotificationType, notification_provider_options
|
from .notification_providers import NotificationType, notification_provider_options
|
||||||
|
from .proxy_protocol import ProxyProtocol
|
||||||
from .api import UptimeKumaApi
|
from .api import UptimeKumaApi
|
||||||
|
|
|
@ -5,6 +5,7 @@ import socketio
|
||||||
from . import AuthMethod
|
from . import AuthMethod
|
||||||
from . import MonitorType
|
from . import MonitorType
|
||||||
from . import NotificationType, notification_provider_options
|
from . import NotificationType, notification_provider_options
|
||||||
|
from . import ProxyProtocol
|
||||||
|
|
||||||
|
|
||||||
class UptimeKumaApi(object):
|
class UptimeKumaApi(object):
|
||||||
|
@ -327,8 +328,40 @@ class UptimeKumaApi(object):
|
||||||
def get_proxies(self):
|
def get_proxies(self):
|
||||||
return self.get_event_data("proxyList")
|
return self.get_event_data("proxyList")
|
||||||
|
|
||||||
def add_proxy(self):
|
def add_proxy(self, *args, **kwargs):
|
||||||
pass
|
data = self._build_proxy_data(*args, **kwargs)
|
||||||
|
return self.sio.call('addProxy', (data, None))
|
||||||
|
|
||||||
|
def edit_proxy(self, id_: int, *args, **kwargs):
|
||||||
|
data = self._build_proxy_data(*args, **kwargs)
|
||||||
|
return self.sio.call('addProxy', (data, id_))
|
||||||
|
|
||||||
|
def delete_proxy(self, id_: int):
|
||||||
|
return self.sio.call('deleteProxy', id_)
|
||||||
|
|
||||||
|
def _build_proxy_data(
|
||||||
|
self,
|
||||||
|
protocol: ProxyProtocol,
|
||||||
|
host: str,
|
||||||
|
port: str,
|
||||||
|
auth: bool = False,
|
||||||
|
username: str = None,
|
||||||
|
password: str = None,
|
||||||
|
active: bool = True,
|
||||||
|
default: bool = False,
|
||||||
|
apply_existing: bool = False,
|
||||||
|
):
|
||||||
|
return {
|
||||||
|
"protocol": protocol,
|
||||||
|
"host": host,
|
||||||
|
"port": port,
|
||||||
|
"auth": auth,
|
||||||
|
"username": username,
|
||||||
|
"password": password,
|
||||||
|
"active": active,
|
||||||
|
"default": default,
|
||||||
|
"applyExisting": apply_existing
|
||||||
|
}
|
||||||
|
|
||||||
# status page
|
# status page
|
||||||
|
|
||||||
|
|
9
uptimekumaapi/proxy_protocol.py
Normal file
9
uptimekumaapi/proxy_protocol.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class ProxyProtocol(str, Enum):
|
||||||
|
HTTPS = "https"
|
||||||
|
HTTP = "http"
|
||||||
|
SOCKS = "socks"
|
||||||
|
SOCKS5 = "socks5"
|
||||||
|
SOCKS4 = "socks4"
|
Loading…
Reference in a new issue