uptimer-python-sdk 0.2.0__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.
- uptimer_python_sdk-0.2.0/.gitignore +167 -0
- uptimer_python_sdk-0.2.0/.pre-commit-config.yaml +13 -0
- uptimer_python_sdk-0.2.0/.vscode/extensions.json +20 -0
- uptimer_python_sdk-0.2.0/.vscode/launch.json +42 -0
- uptimer_python_sdk-0.2.0/.vscode/settings.json +33 -0
- uptimer_python_sdk-0.2.0/.vscode/tasks.json +131 -0
- uptimer_python_sdk-0.2.0/CHANGELOG.md +13 -0
- uptimer_python_sdk-0.2.0/LICENSE +21 -0
- uptimer_python_sdk-0.2.0/NOTICE +18 -0
- uptimer_python_sdk-0.2.0/PKG-INFO +167 -0
- uptimer_python_sdk-0.2.0/README.md +154 -0
- uptimer_python_sdk-0.2.0/examples/01_client_setup.py +14 -0
- uptimer_python_sdk-0.2.0/examples/02_list_workspaces.py +12 -0
- uptimer_python_sdk-0.2.0/examples/03_list_regions.py +12 -0
- uptimer_python_sdk-0.2.0/examples/04_list_rules.py +13 -0
- uptimer_python_sdk-0.2.0/examples/05_get_rule.py +13 -0
- uptimer_python_sdk-0.2.0/examples/06_create_rule.py +35 -0
- uptimer_python_sdk-0.2.0/examples/07_update_rule.py +37 -0
- uptimer_python_sdk-0.2.0/examples/08_delete_rule.py +13 -0
- uptimer_python_sdk-0.2.0/examples/README.md +40 -0
- uptimer_python_sdk-0.2.0/examples/__init__.py +1 -0
- uptimer_python_sdk-0.2.0/pyproject.toml +103 -0
- uptimer_python_sdk-0.2.0/src/uptimer/__init__.py +3 -0
- uptimer_python_sdk-0.2.0/src/uptimer/client.py +21 -0
- uptimer_python_sdk-0.2.0/src/uptimer/endpoints/__init__.py +0 -0
- uptimer_python_sdk-0.2.0/src/uptimer/endpoints/endpoint.py +38 -0
- uptimer_python_sdk-0.2.0/src/uptimer/endpoints/regions.py +24 -0
- uptimer_python_sdk-0.2.0/src/uptimer/endpoints/rules.py +75 -0
- uptimer_python_sdk-0.2.0/src/uptimer/endpoints/v1.py +17 -0
- uptimer_python_sdk-0.2.0/src/uptimer/endpoints/workspaces.py +24 -0
- uptimer_python_sdk-0.2.0/src/uptimer/errors.py +25 -0
- uptimer_python_sdk-0.2.0/src/uptimer/http.py +52 -0
- uptimer_python_sdk-0.2.0/src/uptimer/models/__init__.py +47 -0
- uptimer_python_sdk-0.2.0/src/uptimer/models/deserialize.py +121 -0
- uptimer_python_sdk-0.2.0/src/uptimer/models/errors.py +44 -0
- uptimer_python_sdk-0.2.0/src/uptimer/models/region.py +9 -0
- uptimer_python_sdk-0.2.0/src/uptimer/models/rule.py +57 -0
- uptimer_python_sdk-0.2.0/src/uptimer/models/workspace.py +9 -0
- uptimer_python_sdk-0.2.0/src/uptimer/py.typed +0 -0
- uptimer_python_sdk-0.2.0/tests/__init__.py +1 -0
- uptimer_python_sdk-0.2.0/tests/conftest.py +57 -0
- uptimer_python_sdk-0.2.0/tests/integrations/__init__.py +0 -0
- uptimer_python_sdk-0.2.0/tests/integrations/conftest.py +23 -0
- uptimer_python_sdk-0.2.0/tests/integrations/test_workspaces.py +152 -0
- uptimer_python_sdk-0.2.0/tests/test_client.py +37 -0
- uptimer_python_sdk-0.2.0/tests/test_endpoint.py +30 -0
- uptimer_python_sdk-0.2.0/tests/test_regions_endpoint.py +46 -0
- uptimer_python_sdk-0.2.0/tests/test_rules_endpoint.py +535 -0
- uptimer_python_sdk-0.2.0/tests/test_workspaces_endpoint.py +10 -0
- uptimer_python_sdk-0.2.0/tools/mypy-diff.sh +3 -0
- uptimer_python_sdk-0.2.0/uv.lock +1218 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Cython debug symbols
|
|
153
|
+
cython_debug/
|
|
154
|
+
|
|
155
|
+
# PyCharm
|
|
156
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
+
# be added to the global gitignore or merged into this project gitignore. For a PyCharm
|
|
158
|
+
# project, it is recommended to include the following files:
|
|
159
|
+
# .idea/
|
|
160
|
+
# *.iml
|
|
161
|
+
# *.ipr
|
|
162
|
+
# *.iws
|
|
163
|
+
|
|
164
|
+
# uv
|
|
165
|
+
.uv/
|
|
166
|
+
.idea/
|
|
167
|
+
sandbox.py
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: local
|
|
3
|
+
hooks:
|
|
4
|
+
- id: mypy-diff
|
|
5
|
+
name: mypy on staged files only
|
|
6
|
+
entry: ./tools/mypy-diff.sh
|
|
7
|
+
language: system
|
|
8
|
+
types: [ python ]
|
|
9
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
10
|
+
rev: v0.12.5
|
|
11
|
+
hooks:
|
|
12
|
+
- id: ruff
|
|
13
|
+
args: [--fix]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"recommendations": [
|
|
3
|
+
"ms-python.python",
|
|
4
|
+
"ms-python.vscode-pylance",
|
|
5
|
+
"charliermarsh.ruff",
|
|
6
|
+
"ms-python.black-formatter",
|
|
7
|
+
"ms-python.flake8",
|
|
8
|
+
"ms-python.mypy-type-checker",
|
|
9
|
+
"ms-python.pytest-adapter",
|
|
10
|
+
"ms-vscode.test-adapter-converter",
|
|
11
|
+
"ms-vscode.vscode-json",
|
|
12
|
+
"redhat.vscode-yaml",
|
|
13
|
+
"ms-vscode.hexeditor",
|
|
14
|
+
"ms-vscode.vscode-typescript-next",
|
|
15
|
+
"bradlc.vscode-tailwindcss",
|
|
16
|
+
"esbenp.prettier-vscode",
|
|
17
|
+
"ms-vscode.vscode-js-debug",
|
|
18
|
+
"ms-vscode.vscode-js-debug-companion"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"name": "Python: Current File",
|
|
6
|
+
"type": "debugpy",
|
|
7
|
+
"request": "launch",
|
|
8
|
+
"program": "${file}",
|
|
9
|
+
"console": "integratedTerminal",
|
|
10
|
+
"justMyCode": true,
|
|
11
|
+
"python": "${workspaceFolder}/.venv/bin/python"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "Python: Debug Tests",
|
|
15
|
+
"type": "debugpy",
|
|
16
|
+
"request": "launch",
|
|
17
|
+
"module": "pytest",
|
|
18
|
+
"args": [
|
|
19
|
+
"tests",
|
|
20
|
+
"-v",
|
|
21
|
+
"--tb=short"
|
|
22
|
+
],
|
|
23
|
+
"console": "integratedTerminal",
|
|
24
|
+
"justMyCode": false,
|
|
25
|
+
"python": "${workspaceFolder}/.venv/bin/python"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "Python: Debug Current Test File",
|
|
29
|
+
"type": "debugpy",
|
|
30
|
+
"request": "launch",
|
|
31
|
+
"module": "pytest",
|
|
32
|
+
"args": [
|
|
33
|
+
"${file}",
|
|
34
|
+
"-v",
|
|
35
|
+
"--tb=short"
|
|
36
|
+
],
|
|
37
|
+
"console": "integratedTerminal",
|
|
38
|
+
"justMyCode": false,
|
|
39
|
+
"python": "${workspaceFolder}/.venv/bin/python"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"python.defaultInterpreterPath": "./.venv/bin/python",
|
|
3
|
+
"python.testing.pytestEnabled": true,
|
|
4
|
+
"python.testing.unittestEnabled": false,
|
|
5
|
+
"python.testing.nosetestsEnabled": false,
|
|
6
|
+
"python.testing.pytestArgs": [
|
|
7
|
+
"tests"
|
|
8
|
+
],
|
|
9
|
+
"python.linting.enabled": true,
|
|
10
|
+
"python.linting.ruffEnabled": true,
|
|
11
|
+
"python.linting.pylintEnabled": false,
|
|
12
|
+
"python.linting.flake8Enabled": false,
|
|
13
|
+
"python.linting.mypyEnabled": false,
|
|
14
|
+
"python.formatting.provider": "ruff",
|
|
15
|
+
"python.formatting.ruffArgs": [],
|
|
16
|
+
"editor.formatOnSave": true,
|
|
17
|
+
"editor.codeActionsOnSave": {
|
|
18
|
+
"source.organizeImports": "explicit",
|
|
19
|
+
"source.fixAll": "explicit"
|
|
20
|
+
},
|
|
21
|
+
"files.exclude": {
|
|
22
|
+
"**/__pycache__": true,
|
|
23
|
+
"**/*.pyc": true,
|
|
24
|
+
"**/.pytest_cache": true,
|
|
25
|
+
"**/.ruff_cache": true,
|
|
26
|
+
"**/htmlcov": true,
|
|
27
|
+
"**/.coverage": true,
|
|
28
|
+
"**/.venv": false
|
|
29
|
+
},
|
|
30
|
+
"python.terminal.activateEnvironment": true,
|
|
31
|
+
"python.terminal.activateEnvInCurrentTerminal": true,
|
|
32
|
+
"python.envFile": "${workspaceFolder}/.env"
|
|
33
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.0",
|
|
3
|
+
"tasks": [
|
|
4
|
+
{
|
|
5
|
+
"label": "Run All Tests",
|
|
6
|
+
"type": "shell",
|
|
7
|
+
"command": "uv",
|
|
8
|
+
"args": [
|
|
9
|
+
"run",
|
|
10
|
+
"python",
|
|
11
|
+
"-m",
|
|
12
|
+
"pytest"
|
|
13
|
+
],
|
|
14
|
+
"group": "test",
|
|
15
|
+
"presentation": {
|
|
16
|
+
"echo": true,
|
|
17
|
+
"reveal": "always",
|
|
18
|
+
"focus": false,
|
|
19
|
+
"panel": "shared",
|
|
20
|
+
"showReuseMessage": true,
|
|
21
|
+
"clear": false
|
|
22
|
+
},
|
|
23
|
+
"problemMatcher": []
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"label": "Run Tests with Coverage",
|
|
27
|
+
"type": "shell",
|
|
28
|
+
"command": "uv",
|
|
29
|
+
"args": [
|
|
30
|
+
"run",
|
|
31
|
+
"python",
|
|
32
|
+
"-m",
|
|
33
|
+
"pytest",
|
|
34
|
+
"--cov=src",
|
|
35
|
+
"--cov-report=html"
|
|
36
|
+
],
|
|
37
|
+
"group": "test",
|
|
38
|
+
"presentation": {
|
|
39
|
+
"echo": true,
|
|
40
|
+
"reveal": "always",
|
|
41
|
+
"focus": false,
|
|
42
|
+
"panel": "shared",
|
|
43
|
+
"showReuseMessage": true,
|
|
44
|
+
"clear": false
|
|
45
|
+
},
|
|
46
|
+
"problemMatcher": []
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"label": "Run Ruff Check",
|
|
50
|
+
"type": "shell",
|
|
51
|
+
"command": "uv",
|
|
52
|
+
"args": [
|
|
53
|
+
"run",
|
|
54
|
+
"ruff",
|
|
55
|
+
"check",
|
|
56
|
+
"."
|
|
57
|
+
],
|
|
58
|
+
"group": "build",
|
|
59
|
+
"presentation": {
|
|
60
|
+
"echo": true,
|
|
61
|
+
"reveal": "always",
|
|
62
|
+
"focus": false,
|
|
63
|
+
"panel": "shared",
|
|
64
|
+
"showReuseMessage": true,
|
|
65
|
+
"clear": false
|
|
66
|
+
},
|
|
67
|
+
"problemMatcher": []
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"label": "Run Ruff Format",
|
|
71
|
+
"type": "shell",
|
|
72
|
+
"command": "uv",
|
|
73
|
+
"args": [
|
|
74
|
+
"run",
|
|
75
|
+
"ruff",
|
|
76
|
+
"format",
|
|
77
|
+
"."
|
|
78
|
+
],
|
|
79
|
+
"group": "build",
|
|
80
|
+
"presentation": {
|
|
81
|
+
"echo": true,
|
|
82
|
+
"reveal": "always",
|
|
83
|
+
"focus": false,
|
|
84
|
+
"panel": "shared",
|
|
85
|
+
"showReuseMessage": true,
|
|
86
|
+
"clear": false
|
|
87
|
+
},
|
|
88
|
+
"problemMatcher": []
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"label": "Run Pre-commit",
|
|
92
|
+
"type": "shell",
|
|
93
|
+
"command": "uv",
|
|
94
|
+
"args": [
|
|
95
|
+
"run",
|
|
96
|
+
"pre-commit",
|
|
97
|
+
"run",
|
|
98
|
+
"--all-files"
|
|
99
|
+
],
|
|
100
|
+
"group": "build",
|
|
101
|
+
"presentation": {
|
|
102
|
+
"echo": true,
|
|
103
|
+
"reveal": "always",
|
|
104
|
+
"focus": false,
|
|
105
|
+
"panel": "shared",
|
|
106
|
+
"showReuseMessage": true,
|
|
107
|
+
"clear": false
|
|
108
|
+
},
|
|
109
|
+
"problemMatcher": []
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"label": "Install Dependencies",
|
|
113
|
+
"type": "shell",
|
|
114
|
+
"command": "uv",
|
|
115
|
+
"args": [
|
|
116
|
+
"sync",
|
|
117
|
+
"--dev"
|
|
118
|
+
],
|
|
119
|
+
"group": "build",
|
|
120
|
+
"presentation": {
|
|
121
|
+
"echo": true,
|
|
122
|
+
"reveal": "always",
|
|
123
|
+
"focus": false,
|
|
124
|
+
"panel": "shared",
|
|
125
|
+
"showReuseMessage": true,
|
|
126
|
+
"clear": false
|
|
127
|
+
},
|
|
128
|
+
"problemMatcher": []
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## 0.2.0 (2025-08-10)
|
|
2
|
+
|
|
3
|
+
### Feat
|
|
4
|
+
|
|
5
|
+
- create/update/delete rule methods.
|
|
6
|
+
- added method to get all rules
|
|
7
|
+
- added regions and get rule API
|
|
8
|
+
- added getting workspace list
|
|
9
|
+
- add Cursor IDE configuration for testing and development
|
|
10
|
+
|
|
11
|
+
### Fix
|
|
12
|
+
|
|
13
|
+
- fixed dependencies in pyproject.toml
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Roman Zadoev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Uptimer Python SDK
|
|
2
|
+
Copyright (c) 2025 myuptime.info
|
|
3
|
+
|
|
4
|
+
This software includes the following third-party components:
|
|
5
|
+
|
|
6
|
+
httpx
|
|
7
|
+
Copyright © 2019, Encode OSS Ltd (https://www.encode.io/).
|
|
8
|
+
All rights reserved.
|
|
9
|
+
|
|
10
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
11
|
+
|
|
12
|
+
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
13
|
+
|
|
14
|
+
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: uptimer-python-sdk
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A Python SDK for uptimer
|
|
5
|
+
Project-URL: Repository, https://github.com/myuptime-info/uptimer-python-sdk
|
|
6
|
+
Author-email: Roman Zadoev <zadoev@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
License-File: NOTICE
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Requires-Dist: httpx>=0.28.1
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# Uptimer Python SDK
|
|
15
|
+
|
|
16
|
+
A Python SDK for [uptimer](https://uptimer.myuptime.info/) - a monitoring and uptime checking service.
|
|
17
|
+
|
|
18
|
+
## License
|
|
19
|
+
|
|
20
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
21
|
+
|
|
22
|
+
For third-party license information, see the [NOTICE](NOTICE) file.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from uptimer.client import UptimerClient
|
|
28
|
+
from uptimer.models.rule import CreateRuleRequest, RuleRequest, RuleResponse, RuleResponseBody
|
|
29
|
+
from uptimer.errors import DefaultUptimerApiError, UptimerInvalidHttpCodeError, UptimerError
|
|
30
|
+
# Initialize the client
|
|
31
|
+
client = UptimerClient(
|
|
32
|
+
api_key="your-api-key-here",
|
|
33
|
+
base_url="http://127.0.0.1:2517/api", # or your custom base URL
|
|
34
|
+
)
|
|
35
|
+
regions = client.v1.regions.all()
|
|
36
|
+
workspaces = client.v1.workspaces.all()
|
|
37
|
+
workspace_id = workspaces[0].id
|
|
38
|
+
rules =client.v1.rules.all(workspace_id)
|
|
39
|
+
|
|
40
|
+
new_rule = client.v1.rules.create(
|
|
41
|
+
CreateRuleRequest(
|
|
42
|
+
name="My Test Rule",
|
|
43
|
+
interval=60, # Check every 60 seconds
|
|
44
|
+
workspace_id=workspace_id,
|
|
45
|
+
request=RuleRequest(
|
|
46
|
+
url="https://example.com",
|
|
47
|
+
method="GET", # PATCH, POST, HEAD
|
|
48
|
+
content_type="application/json", # expected content type
|
|
49
|
+
data="", # data (substring) that should be contained in resonse
|
|
50
|
+
),
|
|
51
|
+
response=RuleResponse(
|
|
52
|
+
statuses=[200, 201, 202], # any of this status means site is up
|
|
53
|
+
body=RuleResponseBody(content="expected response"),
|
|
54
|
+
),
|
|
55
|
+
),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
new_rule_updated = client.v1.rules.update(
|
|
59
|
+
new_rule.id,
|
|
60
|
+
CreateRuleRequest(
|
|
61
|
+
name="Updated Rule Name",
|
|
62
|
+
interval=120, # Change to 2 minutes
|
|
63
|
+
workspace_id=workspace_id,
|
|
64
|
+
request=RuleRequest(
|
|
65
|
+
url="https://updated-example.com",
|
|
66
|
+
method="POST",
|
|
67
|
+
content_type="application/json",
|
|
68
|
+
data='{"key": "value"}',
|
|
69
|
+
),
|
|
70
|
+
response=RuleResponse(
|
|
71
|
+
statuses=[200, 201],
|
|
72
|
+
body=RuleResponseBody(content="updated expected response"),
|
|
73
|
+
),
|
|
74
|
+
),
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# caching errors on delete example
|
|
78
|
+
try:
|
|
79
|
+
client.v1.rules.delete(new_rule_updated.id)
|
|
80
|
+
except DefaultUptimerApiError as e:
|
|
81
|
+
# error responses from uptimer server
|
|
82
|
+
print(
|
|
83
|
+
e.message, # user message
|
|
84
|
+
e.code, # error id
|
|
85
|
+
e.error_type, # class of error,
|
|
86
|
+
e.details, # detailed message for a developer
|
|
87
|
+
)
|
|
88
|
+
except UptimerInvalidHttpCodeError as e:
|
|
89
|
+
# uptimer api always return 200, if not -> http transport error
|
|
90
|
+
# for an example 404 status is really page (url) not found, it doesn't mean that an object with id not found.
|
|
91
|
+
print(
|
|
92
|
+
e.url,
|
|
93
|
+
e.status_code,
|
|
94
|
+
)
|
|
95
|
+
except UptimerError as e: # base error, if you need one
|
|
96
|
+
raise
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Also, check out [examples directory](https://github.com/myuptime-info/uptimer-python-sdk/examples)
|
|
100
|
+
|
|
101
|
+
### Development Setup
|
|
102
|
+
|
|
103
|
+
1. Clone the repository:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
git clone <repository-url>
|
|
107
|
+
cd uptimer-python-sdk
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
2. Install dependencies:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
uv sync --dev
|
|
114
|
+
# for integration tests
|
|
115
|
+
uv run playwright install chromium
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
3. Run tests:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
uv run pytest
|
|
122
|
+
# integration
|
|
123
|
+
docker pull myuptime/uptimer
|
|
124
|
+
docker run -p 2517:2517 myuptime/uptimer
|
|
125
|
+
UPTIMER_URL=http://localhost:2517 uv run --integration
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
4. Run linting:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
uv run ruff check .
|
|
132
|
+
uv run mypy src
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
5. Format code:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
uv run ruff format .
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
6. Run pre-commit hooks:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
uv run pre-commit run --all-files
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Third-Party Licenses
|
|
148
|
+
|
|
149
|
+
This project uses the following third-party libraries:
|
|
150
|
+
|
|
151
|
+
### Production Dependencies
|
|
152
|
+
|
|
153
|
+
- **httpx** (BSD 3-Clause License) - HTTP client for Python
|
|
154
|
+
|
|
155
|
+
### Development Dependencies
|
|
156
|
+
|
|
157
|
+
- **mypy** (Apache 2.0 License) - Static type checker
|
|
158
|
+
- **playwright** (Apache 2.0 License) - Browser automation
|
|
159
|
+
- **pre-commit** (MIT License) - Git hooks framework
|
|
160
|
+
- **pytest** (MIT License) - Testing framework
|
|
161
|
+
- **pytest-cov** (MIT License) - Coverage plugin for pytest
|
|
162
|
+
- **pytest-httpx** (MIT License) - HTTPX plugin for pytest
|
|
163
|
+
- **pytest-playwright** (MIT License) - Playwright plugin for pytest
|
|
164
|
+
- **responses** (Apache 2.0 License) - Mock library for requests
|
|
165
|
+
- **ruff** (MIT License) - Fast Python linter and formatter
|
|
166
|
+
|
|
167
|
+
All third-party licenses are compatible with the MIT License used by this project. Note that the BSD 3-Clause License (used by httpx) includes an additional restriction prohibiting the use of the copyright holder's name for endorsement without permission.
|