pythonkuma 0.0.0rc1__tar.gz → 0.0.0rc2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythonkuma
3
- Version: 0.0.0rc1
3
+ Version: 0.0.0rc2
4
4
  Summary: Simple Python wrapper for Uptime Kuma
5
5
  Project-URL: Source, https://github.com/tr4nt0r/pythonkuma
6
6
  Author-email: Manfred Dennerlein Rodelo <manfred@dennerlein.name>, Jayakorn Karikan <jayakornk@gmail.com>
@@ -8,7 +8,7 @@ from .exceptions import (
8
8
  from .models import MonitorType, UptimeKumaApiResponse, UptimeKumaMonitor
9
9
  from .uptimekuma import UptimeKuma
10
10
 
11
- __version__ = "0.0.0rc1"
11
+ __version__ = "0.0.0rc2"
12
12
 
13
13
  __all__ = [
14
14
  "MonitorType",
@@ -2,13 +2,23 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from dataclasses import dataclass
6
- from enum import StrEnum
5
+ from dataclasses import dataclass, field
6
+ from enum import IntEnum, StrEnum
7
7
  from typing import Any
8
8
 
9
+ from mashumaro import DataClassDictMixin
9
10
  from prometheus_client.parser import text_string_to_metric_families as parser
10
11
 
11
12
 
13
+ class MonitorStatus(IntEnum):
14
+ """Monitor states."""
15
+
16
+ DOWN = 0
17
+ UP = 1
18
+ PENDING = 2
19
+ MAINTENANCE = 3
20
+
21
+
12
22
  class MonitorType(StrEnum):
13
23
  """Monitors type."""
14
24
 
@@ -36,33 +46,24 @@ class MonitorType(StrEnum):
36
46
  TAILSCALE_PING = "tailscale-ping"
37
47
 
38
48
 
39
- class UptimeKumaBaseModel:
49
+ @dataclass
50
+ class UptimeKumaBaseModel(DataClassDictMixin):
40
51
  """UptimeKumaBaseModel."""
41
52
 
42
53
 
43
- @dataclass
54
+ @dataclass(kw_only=True)
44
55
  class UptimeKumaMonitor(UptimeKumaBaseModel):
45
56
  """Monitor model for Uptime Kuma."""
46
57
 
47
- monitor_cert_days_remaining: float = 0
48
- monitor_cert_is_valid: float = 0
49
- monitor_hostname: str = ""
50
- monitor_name: str = ""
51
- monitor_port: str = ""
52
- monitor_response_time: float = 0
53
- monitor_status: float = 0
58
+ monitor_cert_days_remaining: int
59
+ monitor_cert_is_valid: bool
60
+ monitor_hostname: str | None = field(metadata={"deserialize": lambda v: None if v == "null" else v})
61
+ monitor_name: str
62
+ monitor_port: str | None = field(metadata={"deserialize": lambda v: None if v == "null" else v})
63
+ monitor_response_time: int = 0
64
+ monitor_status: MonitorStatus
54
65
  monitor_type: MonitorType = MonitorType.HTTP
55
- monitor_url: str = ""
56
-
57
- @staticmethod
58
- def from_dict(data: dict[str, Any]) -> UptimeKumaMonitor:
59
- """Generate object from json."""
60
- obj: dict[str, Any] = {}
61
- for key, value in data.items():
62
- if hasattr(UptimeKumaMonitor, key):
63
- obj[key] = MonitorType(value) if key == "monitor_type" else value
64
-
65
- return UptimeKumaMonitor(**obj)
66
+ monitor_url: str | None = field(metadata={"deserialize": lambda v: None if v == "null" else v})
66
67
 
67
68
 
68
69
  @dataclass
File without changes
File without changes
File without changes