talkomatic.py
0.1.2
An easy-to-use Python versatile wrapper for the Talkomatic Bot interface ensuring best practices for making bots, and handling the REST API.
Loading...
Searching...
No Matches
health.py
Go to the documentation of this file.
1
from
talkomatic.api.v1.auth
import
get_auth_bot_token
2
3
from
requests
import
get
as
requests_get
4
5
from
dataclasses
import
dataclass
6
7
8
@dataclass
9
class
ServerHealth
:
10
"""
11
A class representing the Talkomatic server uptime.
12
13
Args:
14
status (bool): Whether the server is up.
15
uptime (float): The uptime of the server.
16
since_timestamp (float): The timestamp of when the server was last restarted.
17
server_version (str): The version of the server.
18
"""
19
20
status: bool
21
uptime: float |
None
22
since_timestamp: float |
None
23
server_version: str |
None
24
25
@classmethod
26
def
get
(cls) -> "ServerHealth":
27
response = requests_get(f
"https://classic.talkomatic.co/api/v1/health?token={get_auth_bot_token()}"
)
28
if
response.status_code != 200:
29
return
cls(
30
status =
False
,
31
uptime =
None
,
32
since_timestamp =
None
,
33
server_version =
None
34
)
35
data = response.json()
36
37
return
cls(
38
status =
True
,
39
uptime = data[
"uptime"
],
40
since_timestamp = data[
"timestamp"
],
41
server_version = data[
"version"
]
42
)
43
44
__all__ = [
"ServerHealth"
]
talkomatic.api.v1.health.ServerHealth
Definition
health.py:9
talkomatic.api.v1.health.ServerHealth.get
"ServerHealth" get(cls)
Definition
health.py:26
talkomatic.api.v1.auth
Definition
auth.py:1
talkomatic
api
v1
health.py
Generated by
1.13.2