feat(bot): please claude i need this my services are kinda homeless
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
from dataclasses import dataclass
|
||||
from enum import StrEnum
|
||||
|
||||
|
||||
class MatchType(StrEnum):
|
||||
STATUS = "status" # следим только за HTTP-статусом
|
||||
BODY = "body" # тело ответа должно совпадать целиком
|
||||
JSON = "json" # конкретное поле JSON должно быть равно эталону
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class Service:
|
||||
id: int
|
||||
name: str
|
||||
url: str
|
||||
match_type: MatchType
|
||||
ok_status: int
|
||||
ok_body: str
|
||||
json_path: str | None
|
||||
json_value: str | None
|
||||
is_up: bool
|
||||
created_at: str
|
||||
|
||||
@property
|
||||
def rule(self) -> str:
|
||||
if self.match_type is MatchType.STATUS:
|
||||
return f"HTTP-статус = {self.ok_status}"
|
||||
if self.match_type is MatchType.JSON:
|
||||
return f"<code>{self.json_path}</code> = <code>{self.json_value}</code>"
|
||||
return "тело ответа неизменно"
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class Incident:
|
||||
id: int
|
||||
service_id: int
|
||||
started_at: str
|
||||
ended_at: str | None
|
||||
reason: str
|
||||
last_reminder_at: str
|
||||
Reference in New Issue
Block a user