mirror of
https://github.com/andrewthetechie/py-healthchecks.io.git
synced 2025-12-05 09:08:09 +01:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d065a29b66 | ||
|
|
aaad153b83 | ||
|
|
d9493ba25a | ||
|
|
cb9d03af5f | ||
|
|
a4b73966f1 | ||
|
|
e075a31fa3 | ||
|
|
c071ced5bf | ||
|
|
67ec0b5d58 | ||
|
|
6bae975521 | ||
|
|
f9e0fd0bd1 | ||
|
|
7fa3e2ff1a | ||
|
|
4d00499f94 | ||
|
|
5325352bae | ||
|
|
627f070e3f | ||
|
|
b372e66c44 | ||
|
|
55ea01de63 | ||
|
|
a78d6d9a85 | ||
|
|
0f52d6b535 | ||
|
|
e46f70c470 | ||
|
|
e24fcb233b | ||
|
|
afa83a2528 | ||
|
|
f615e35468 | ||
|
|
6e88834d93 |
6
.github/workflows/constraints.txt
vendored
6
.github/workflows/constraints.txt
vendored
@@ -1,6 +1,6 @@
|
||||
pip==24.0.0
|
||||
pip==24.1.1
|
||||
nox==2024.4.15
|
||||
nox-poetry==1.0.3
|
||||
poetry==1.8.2
|
||||
virtualenv==20.26.1
|
||||
poetry==1.8.3
|
||||
virtualenv==20.26.3
|
||||
toml==0.10.2
|
||||
|
||||
2
.github/workflows/pre-release.yml
vendored
2
.github/workflows/pre-release.yml
vendored
@@ -34,7 +34,7 @@ jobs:
|
||||
poetry build --ansi
|
||||
|
||||
- name: Publish package on TestPyPI
|
||||
uses: pypa/gh-action-pypi-publish@v1.8.14
|
||||
uses: pypa/gh-action-pypi-publish@v1.9.0
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.TEST_PYPI_TOKEN }}
|
||||
|
||||
18
CHANGELOG.md
18
CHANGELOG.md
@@ -1,5 +1,23 @@
|
||||
# Changelog
|
||||
|
||||
## [0.4.3](https://github.com/andrewthetechie/py-healthchecks.io/compare/v0.4.2...v0.4.3) (2024-07-03)
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* bump coverage from 7.5.1 to 7.5.2 ([#680](https://github.com/andrewthetechie/py-healthchecks.io/issues/680)) ([b372e66](https://github.com/andrewthetechie/py-healthchecks.io/commit/b372e66c44ae403af042a43b3d7de41142570eb3))
|
||||
* bump coverage from 7.5.2 to 7.5.3 ([#683](https://github.com/andrewthetechie/py-healthchecks.io/issues/683)) ([5325352](https://github.com/andrewthetechie/py-healthchecks.io/commit/5325352bae60b332f4602e37adb3f35cc8ae11c7))
|
||||
* bump httpx from 0.24.1 to 0.27.0 ([#668](https://github.com/andrewthetechie/py-healthchecks.io/issues/668)) ([6e88834](https://github.com/andrewthetechie/py-healthchecks.io/commit/6e88834d93ea28f9bfeb7b81bcac8227ee38580c))
|
||||
* bump pre-commit from 2.21.0 to 3.5.0 ([#669](https://github.com/andrewthetechie/py-healthchecks.io/issues/669)) ([4d00499](https://github.com/andrewthetechie/py-healthchecks.io/commit/4d00499f94c7e6ad4af86742996fca9c266e8ddf))
|
||||
* bump pytz from 2023.4 to 2024.1 ([#670](https://github.com/andrewthetechie/py-healthchecks.io/issues/670)) ([67ec0b5](https://github.com/andrewthetechie/py-healthchecks.io/commit/67ec0b5d58563c0fb92ee5a7754706b07d767c11))
|
||||
* bump reorder-python-imports from 3.12.0 to 3.13.0 ([#685](https://github.com/andrewthetechie/py-healthchecks.io/issues/685)) ([c071ced](https://github.com/andrewthetechie/py-healthchecks.io/commit/c071ced5bfc00fcfef922d01a3c70961f03176d6))
|
||||
* bump ruff from 0.4.3 to 0.4.4 ([#675](https://github.com/andrewthetechie/py-healthchecks.io/issues/675)) ([e46f70c](https://github.com/andrewthetechie/py-healthchecks.io/commit/e46f70c4708eb703c0f02a97efe62a94145f6e58))
|
||||
* bump ruff from 0.4.4 to 0.4.5 ([#679](https://github.com/andrewthetechie/py-healthchecks.io/issues/679)) ([55ea01d](https://github.com/andrewthetechie/py-healthchecks.io/commit/55ea01de63c43865c0b41b4248f02d96b17f1c07))
|
||||
* bump ruff from 0.4.5 to 0.4.6 ([#681](https://github.com/andrewthetechie/py-healthchecks.io/issues/681)) ([627f070](https://github.com/andrewthetechie/py-healthchecks.io/commit/627f070e3fcbaf53a523a5b81b0699e39ffc4229))
|
||||
* bump ruff from 0.4.6 to 0.5.0 ([#699](https://github.com/andrewthetechie/py-healthchecks.io/issues/699)) ([f9e0fd0](https://github.com/andrewthetechie/py-healthchecks.io/commit/f9e0fd0bd135621f031ed5d490cfabdd90c8991d))
|
||||
* bump the pip group with 3 updates ([#694](https://github.com/andrewthetechie/py-healthchecks.io/issues/694)) ([a4b7396](https://github.com/andrewthetechie/py-healthchecks.io/commit/a4b73966f1b44c609bd9bdd25505429bb8b772a8))
|
||||
* bump types-pytz from 2023.4.0.20240130 to 2024.1.0.20240417 ([#672](https://github.com/andrewthetechie/py-healthchecks.io/issues/672)) ([e24fcb2](https://github.com/andrewthetechie/py-healthchecks.io/commit/e24fcb233bd7a35f3999e9fb7bd174ef357ecdcb))
|
||||
|
||||
## [0.4.2](https://github.com/andrewthetechie/py-healthchecks.io/compare/v0.4.1...v0.4.2) (2024-05-07)
|
||||
|
||||
|
||||
|
||||
@@ -121,7 +121,11 @@ def safety(session: Session) -> None:
|
||||
session.install("safety")
|
||||
# ignore https://github.com/pytest-dev/py/issues/287
|
||||
# its an irresposnbily filed CVE causing nose
|
||||
session.run("safety", "check", "--full-report", f"--file={requirements}", "--ignore=51457")
|
||||
# ignore https://data.safetycli.com/v/70612/97c/
|
||||
# Jinja2 vulnerability, maintainer believe it is not a valid vulnerability
|
||||
# ignore https://data.safetycli.com/v/71064/97c/
|
||||
# requests vulnerability. The fixed version is not compatible with the packaging library
|
||||
session.run("safety", "check", "--full-report", f"--file={requirements}", "--ignore=51457,70612,71064")
|
||||
|
||||
|
||||
@session(python=python_versions)
|
||||
|
||||
688
poetry.lock
generated
688
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "healthchecks_io"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
description = "A python client package for Healthchecks.io API"
|
||||
authors = ["Andrew Herrington <andrew.the.techie@gmail.com>"]
|
||||
license = "MIT"
|
||||
@@ -26,10 +26,11 @@ Changelog = "https://github.com/andrewthetechie/py-healthchecks.io/releases"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
pydantic = "^1.9.1"
|
||||
httpx = ">=0.23.0,<0.25.0"
|
||||
pydantic = ">=1.9.1,<3.0.0"
|
||||
httpx = ">=0.23.0,<0.28.0"
|
||||
croniter = ">=1.1,<3.0"
|
||||
pytz = ">=2021.3,<2024.0"
|
||||
pytz = ">=2024.1,<2025.0"
|
||||
packaging = "^24.1"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
pytest = "^7.2.1"
|
||||
@@ -39,20 +40,20 @@ mypy = "^1.0"
|
||||
xdoctest = {extras = ["colors"], version = "^1.1.1"}
|
||||
sphinx = ">=4.3.2,<8.0.0"
|
||||
sphinx-autobuild = ">=2021.3.14"
|
||||
pre-commit = "^2.21.0"
|
||||
pre-commit = ">=2.21,<4.0"
|
||||
reorder-python-imports = "^3.9.0"
|
||||
pre-commit-hooks = "^4.4.0"
|
||||
pyupgrade = "^3.3.1"
|
||||
furo = ">=2021.11.12"
|
||||
pytest-cov = ">=4,<6"
|
||||
types-croniter = ">=1.3.2,<3.0.0"
|
||||
types-pytz = ">=2022.7.1,<2024.0.0"
|
||||
types-pytz = ">=2022.7.1,<2025.0.0"
|
||||
pytest-asyncio = ">=0.20.3,<0.24.0"
|
||||
respx = ">=0.20.1,<0.22.0"
|
||||
pytest-mock = "^3.10.0"
|
||||
pytest-lazy-fixture = "^0.6.3"
|
||||
pytest-xdist = "^3.2.0"
|
||||
ruff = ">=0.0.249,<0.4.4"
|
||||
ruff = ">=0.5.0,<0.5.1"
|
||||
bandit = "^1.7.4"
|
||||
|
||||
[tool.coverage.paths]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Py Healthchecks.Io."""
|
||||
|
||||
# set by poetry-dynamic-versioning
|
||||
__version__ = "0.4.2" # noqa: E402
|
||||
__version__ = "0.4.3" # noqa: E402
|
||||
|
||||
from .client import AsyncClient # noqa: F401, E402
|
||||
from .client import Client # noqa: F401, E402
|
||||
|
||||
@@ -302,6 +302,7 @@ class Client(AbstractClient):
|
||||
|
||||
svg, json, shields: reports two states: "up" and "down". It considers any checks in the grace period
|
||||
as still "up".
|
||||
|
||||
svg3, json3, shields3: reports three states: "up", "late", and "down".
|
||||
|
||||
The response includes a special * entry: this pseudo-tag reports the overal status
|
||||
|
||||
@@ -14,45 +14,45 @@ from urllib.parse import urlparse
|
||||
|
||||
import pytz
|
||||
from croniter import croniter
|
||||
from pydantic import BaseModel
|
||||
from pydantic import field_validator, BaseModel, ValidationInfo
|
||||
from pydantic import Field
|
||||
from pydantic import validator
|
||||
|
||||
|
||||
class Check(BaseModel):
|
||||
"""Schema for a check object, either from a readonly api request or a rw api request."""
|
||||
|
||||
unique_key: Optional[str]
|
||||
unique_key: Optional[str] = None
|
||||
name: str
|
||||
slug: str
|
||||
tags: Optional[str]
|
||||
desc: Optional[str]
|
||||
tags: Optional[str] = None
|
||||
desc: Optional[str] = None
|
||||
grace: int
|
||||
n_pings: int
|
||||
status: str
|
||||
last_ping: Optional[datetime]
|
||||
next_ping: Optional[datetime]
|
||||
last_ping: Optional[datetime] = None
|
||||
next_ping: Optional[datetime] = None
|
||||
manual_resume: bool
|
||||
methods: Optional[str]
|
||||
methods: Optional[str] = None
|
||||
# healthchecks.io's api doesn't return a scheme so we cant use Pydantic AnyUrl here
|
||||
ping_url: Optional[str]
|
||||
update_url: Optional[str]
|
||||
pause_url: Optional[str]
|
||||
channels: Optional[str]
|
||||
timeout: Optional[int]
|
||||
uuid: Optional[str]
|
||||
ping_url: Optional[str] = None
|
||||
update_url: Optional[str] = None
|
||||
pause_url: Optional[str] = None
|
||||
channels: Optional[str] = None
|
||||
timeout: Optional[int] = None
|
||||
uuid: Optional[str] = Field(default=None, validate_default=True)
|
||||
|
||||
@validator("uuid", always=True)
|
||||
def validate_uuid(cls, value: Optional[str], values: Dict[str, Any]) -> Optional[str]: # noqa: B902
|
||||
@field_validator("uuid")
|
||||
@classmethod
|
||||
def validate_uuid(cls, value: Optional[str], info: ValidationInfo) -> Optional[str]: # noqa: B902
|
||||
"""Tries to set the uuid from the ping_url.
|
||||
|
||||
Will return none if a read only token is used because it cannot retrieve the UUID of a check
|
||||
"""
|
||||
if value is None and values.get("ping_url", None) is not None:
|
||||
if value is None and info.data.get("ping_url", None) is not None:
|
||||
# url is like healthchecks.io/ping/8f57b84b-86c2-4546-8923-03f83d27604a, so we want just the
|
||||
# UUID off the end
|
||||
# Parse the url, grab the path and then just get the name using pathlib
|
||||
path = PurePath(str(urlparse(values.get("ping_url")).path))
|
||||
path = PurePath(str(urlparse(info.data.get("ping_url")).path))
|
||||
return path.name
|
||||
return value
|
||||
|
||||
@@ -126,28 +126,32 @@ class CheckCreate(BaseModel):
|
||||
"for the unique field are name, tags, timeout, and grace.",
|
||||
)
|
||||
|
||||
@validator("schedule")
|
||||
@field_validator("schedule")
|
||||
@classmethod
|
||||
def validate_schedule(cls, value: str) -> str:
|
||||
"""Validates that the schedule is a valid cron expression."""
|
||||
if not croniter.is_valid(value):
|
||||
raise ValueError("Schedule is not a valid cron expression")
|
||||
return value
|
||||
|
||||
@validator("tz")
|
||||
@field_validator("tz")
|
||||
@classmethod
|
||||
def validate_tz(cls, value: str) -> str:
|
||||
"""Validates that the timezone is a valid timezone string."""
|
||||
if value not in pytz.all_timezones:
|
||||
raise ValueError("Tz is not a valid timezone")
|
||||
return value
|
||||
|
||||
@validator("methods")
|
||||
@field_validator("methods")
|
||||
@classmethod
|
||||
def validate_methods(cls, value: str) -> str:
|
||||
"""Validate that methods."""
|
||||
if value not in ("", "POST"):
|
||||
raise ValueError("Methods is invalid, it should be either an empty string or POST")
|
||||
return value
|
||||
|
||||
@validator("unique")
|
||||
@field_validator("unique")
|
||||
@classmethod
|
||||
def validate_unique(cls, value: List[Optional[str]]) -> List[Optional[str]]:
|
||||
"""Validate unique list."""
|
||||
for unique in value:
|
||||
|
||||
Reference in New Issue
Block a user