proxmox-sdk 0.0.2__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.
- proxmox_sdk-0.0.2/PKG-INFO +252 -0
- proxmox_sdk-0.0.2/README.md +212 -0
- proxmox_sdk-0.0.2/proxmox_openapi/__init__.py +51 -0
- proxmox_sdk-0.0.2/proxmox_openapi/exception.py +16 -0
- proxmox_sdk-0.0.2/proxmox_openapi/generated/pbs/latest/pydantic_models.py +8098 -0
- proxmox_sdk-0.0.2/proxmox_openapi/generated/proxmox/latest/pydantic_models.py +11972 -0
- proxmox_sdk-0.0.2/proxmox_openapi/logger.py +54 -0
- proxmox_sdk-0.0.2/proxmox_openapi/main.py +221 -0
- proxmox_sdk-0.0.2/proxmox_openapi/mock/__init__.py +37 -0
- proxmox_sdk-0.0.2/proxmox_openapi/mock/app.py +103 -0
- proxmox_sdk-0.0.2/proxmox_openapi/mock/loader.py +90 -0
- proxmox_sdk-0.0.2/proxmox_openapi/mock/routes.py +916 -0
- proxmox_sdk-0.0.2/proxmox_openapi/mock/schema_helpers.py +84 -0
- proxmox_sdk-0.0.2/proxmox_openapi/mock/state.py +414 -0
- proxmox_sdk-0.0.2/proxmox_openapi/mock_main.py +23 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox/__init__.py +8 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox/client.py +121 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox/config.py +259 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox/routes.py +293 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/__init__.py +21 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/app.py +40 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/batch.py +157 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/cache.py +201 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/cli.py +158 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/commands/__init__.py +23 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/commands/_common.py +67 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/commands/create.py +109 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/commands/delete.py +99 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/commands/get.py +150 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/commands/help.py +88 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/commands/ls.py +192 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/commands/set.py +114 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/commands/tui.py +107 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/commands/usage.py +78 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/completion.py +135 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/config.py +302 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/config_commands.py +428 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/doc_commands.py +59 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/docgen/__init__.py +1 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/docgen/discovery.py +53 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/docgen/engine.py +166 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/docgen/models.py +48 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/docgen/specs.py +11 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/docgen_capture.py +50 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/error_suggestions.py +88 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/exceptions.py +78 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/install.py +80 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/output.py +424 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/performance.py +200 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/plugins/__init__.py +3 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/release.py +81 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/sdk_bridge.py +249 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/themes/themes.py +81 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/tui_app.py +406 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/tui_runner.py +28 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_cli/utils.py +162 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_codegen/__init__.py +5 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_codegen/apidoc_parser.py +165 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_codegen/cli.py +140 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_codegen/crawler.py +82 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_codegen/models.py +279 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_codegen/normalize.py +32 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_codegen/openapi_generator.py +68 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_codegen/pipeline.py +325 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_codegen/pydantic_generator.py +249 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_codegen/security.py +211 -0
- proxmox_sdk-0.0.2/proxmox_openapi/proxmox_codegen/utils.py +81 -0
- proxmox_sdk-0.0.2/proxmox_openapi/rate_limit.py +10 -0
- proxmox_sdk-0.0.2/proxmox_openapi/routes/__init__.py +8 -0
- proxmox_sdk-0.0.2/proxmox_openapi/routes/codegen.py +287 -0
- proxmox_sdk-0.0.2/proxmox_openapi/routes/helpers.py +234 -0
- proxmox_sdk-0.0.2/proxmox_openapi/routes/mock.py +34 -0
- proxmox_sdk-0.0.2/proxmox_openapi/routes/versions.py +32 -0
- proxmox_sdk-0.0.2/proxmox_openapi/schema.py +565 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/__init__.py +23 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/api.py +457 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/auth/__init__.py +6 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/auth/base.py +50 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/auth/ticket.py +200 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/auth/token.py +64 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/backends/__init__.py +13 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/backends/_cli_base.py +182 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/backends/base.py +61 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/backends/https.py +455 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/backends/local.py +112 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/backends/mock.py +208 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/backends/openssh.py +180 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/backends/ssh_paramiko.py +179 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/exceptions.py +42 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/resource.py +177 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/services.py +56 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/sync.py +144 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/tools/__init__.py +6 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/tools/files.py +275 -0
- proxmox_sdk-0.0.2/proxmox_openapi/sdk/tools/tasks.py +178 -0
- proxmox_sdk-0.0.2/proxmox_sdk.egg-info/PKG-INFO +252 -0
- proxmox_sdk-0.0.2/proxmox_sdk.egg-info/SOURCES.txt +109 -0
- proxmox_sdk-0.0.2/proxmox_sdk.egg-info/dependency_links.txt +1 -0
- proxmox_sdk-0.0.2/proxmox_sdk.egg-info/entry_points.txt +6 -0
- proxmox_sdk-0.0.2/proxmox_sdk.egg-info/requires.txt +40 -0
- proxmox_sdk-0.0.2/proxmox_sdk.egg-info/top_level.txt +1 -0
- proxmox_sdk-0.0.2/pyproject.toml +123 -0
- proxmox_sdk-0.0.2/setup.cfg +4 -0
- proxmox_sdk-0.0.2/tests/test_codegen_auth.py +57 -0
- proxmox_sdk-0.0.2/tests/test_codegen_security.py +140 -0
- proxmox_sdk-0.0.2/tests/test_docgen_discovery.py +26 -0
- proxmox_sdk-0.0.2/tests/test_docgen_paths.py +21 -0
- proxmox_sdk-0.0.2/tests/test_imports.py +246 -0
- proxmox_sdk-0.0.2/tests/test_loading_validation.py +41 -0
- proxmox_sdk-0.0.2/tests/test_mock_schema_helpers.py +42 -0
- proxmox_sdk-0.0.2/tests/test_pbs_support.py +182 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: proxmox-sdk
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: pvesh-like CLI for Proxmox API with multi-backend support, performance profiling, and advanced configuration management
|
|
5
|
+
Requires-Python: >=3.11
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: fastapi[standard]>=0.135.2
|
|
8
|
+
Requires-Dist: pyyaml>=6.0
|
|
9
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
10
|
+
Requires-Dist: slowapi>=0.1.9
|
|
11
|
+
Provides-Extra: ssh
|
|
12
|
+
Requires-Dist: paramiko>=3.0; extra == "ssh"
|
|
13
|
+
Requires-Dist: openssh-wrapper>=0.4; extra == "ssh"
|
|
14
|
+
Provides-Extra: cli
|
|
15
|
+
Requires-Dist: typer[all]>=0.12.3; extra == "cli"
|
|
16
|
+
Requires-Dist: rich>=13.0.0; extra == "cli"
|
|
17
|
+
Requires-Dist: textual>=0.79.1; extra == "cli"
|
|
18
|
+
Requires-Dist: pyyaml>=6.0; extra == "cli"
|
|
19
|
+
Provides-Extra: all
|
|
20
|
+
Requires-Dist: paramiko>=3.0; extra == "all"
|
|
21
|
+
Requires-Dist: openssh-wrapper>=0.4; extra == "all"
|
|
22
|
+
Requires-Dist: typer[all]>=0.12.3; extra == "all"
|
|
23
|
+
Requires-Dist: rich>=13.0.0; extra == "all"
|
|
24
|
+
Requires-Dist: textual>=0.79.1; extra == "all"
|
|
25
|
+
Requires-Dist: pyyaml>=6.0; extra == "all"
|
|
26
|
+
Provides-Extra: test
|
|
27
|
+
Requires-Dist: httpx>=0.28.1; extra == "test"
|
|
28
|
+
Requires-Dist: playwright>=1.58.0; extra == "test"
|
|
29
|
+
Requires-Dist: pytest>=9.0.2; extra == "test"
|
|
30
|
+
Requires-Dist: pytest-cov>=7.1.0; extra == "test"
|
|
31
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == "test"
|
|
32
|
+
Requires-Dist: pytest-xdist>=3.6.1; extra == "test"
|
|
33
|
+
Provides-Extra: playwright
|
|
34
|
+
Requires-Dist: playwright>=1.58.0; extra == "playwright"
|
|
35
|
+
Provides-Extra: docs
|
|
36
|
+
Requires-Dist: mkdocs>=1.6.1; extra == "docs"
|
|
37
|
+
Requires-Dist: mkdocs-material>=9.7.6; extra == "docs"
|
|
38
|
+
Provides-Extra: granian
|
|
39
|
+
Requires-Dist: granian>=2.7.0; extra == "granian"
|
|
40
|
+
|
|
41
|
+
# proxmox-openapi
|
|
42
|
+
|
|
43
|
+
Schema-driven FastAPI package for Proxmox API: OpenAPI generation, mock data, and in-memory CRUD operations.
|
|
44
|
+
|
|
45
|
+
**📚 [Full Documentation](https://emersonfelipesp.github.io/proxmox-openapi/)**
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- **Dual Mode**: Mock mode (default) for development, Real mode for production Proxmox integration
|
|
50
|
+
- **646 Endpoints**: Pre-generated Proxmox VE 8.1 API with full OpenAPI schema
|
|
51
|
+
- **Mock Data**: Automatically generate mock data for all endpoints with in-memory CRUD
|
|
52
|
+
- **Real API Proxy**: Validated proxy to real Proxmox VE API with request/response validation
|
|
53
|
+
- **Code Generation**: Automatically crawl Proxmox API Viewer and convert to OpenAPI schema
|
|
54
|
+
- **Multi-version Support**: Select multiple Proxmox versions with `latest` mapped to official Proxmox API viewer
|
|
55
|
+
- **Swagger Docs**: FastAPI auto-generates OpenAPI documentation at `/docs`
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install proxmox-openapi
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Quick Start
|
|
64
|
+
|
|
65
|
+
### Mock Mode (Default)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Install
|
|
69
|
+
pip install proxmox-openapi
|
|
70
|
+
|
|
71
|
+
# Start server
|
|
72
|
+
uvicorn proxmox_openapi.main:app --reload
|
|
73
|
+
|
|
74
|
+
# View Swagger docs
|
|
75
|
+
# Open http://localhost:8000/docs
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### SDK Direct Usage (No Server Required)
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from proxmox_openapi.sdk import ProxmoxSDK
|
|
82
|
+
|
|
83
|
+
# Async with mock data
|
|
84
|
+
async with ProxmoxSDK.mock() as proxmox:
|
|
85
|
+
nodes = await proxmox.nodes.get()
|
|
86
|
+
|
|
87
|
+
# Or sync (blocking)
|
|
88
|
+
with ProxmoxSDK.sync_mock() as proxmox:
|
|
89
|
+
nodes = proxmox.nodes.get()
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### CLI TUI
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Install with CLI extras
|
|
96
|
+
pip install proxmox-openapi[cli]
|
|
97
|
+
|
|
98
|
+
# Production TUI
|
|
99
|
+
pbx tui
|
|
100
|
+
|
|
101
|
+
# Mock TUI
|
|
102
|
+
pbx tui mock
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Real Mode (Connect to Proxmox)
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Configure credentials
|
|
109
|
+
export PROXMOX_API_MODE=real
|
|
110
|
+
export PROXMOX_URL=https://proxmox.example.com:8006
|
|
111
|
+
export PROXMOX_API_TOKEN=PVEAPIToken=user@realm!tokenid=uuid
|
|
112
|
+
|
|
113
|
+
# Start server
|
|
114
|
+
uvicorn proxmox_openapi.main:app --reload
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
See the [Quick Start Guide](https://emersonfelipesp.github.io/proxmox-openapi/quickstart/) for more details.
|
|
118
|
+
|
|
119
|
+
## Documentation
|
|
120
|
+
|
|
121
|
+
- **[Home](https://emersonfelipesp.github.io/proxmox-openapi/)** - Overview and features
|
|
122
|
+
- **[Installation](https://emersonfelipesp.github.io/proxmox-openapi/installation/)** - Installation options (pip, uv, Docker, source)
|
|
123
|
+
- **[Quick Start](https://emersonfelipesp.github.io/proxmox-openapi/quickstart/)** - 5-minute getting started guide
|
|
124
|
+
- **[SDK Mock Usage](https://emersonfelipesp.github.io/proxmox-openapi/sdk-mock/)** - Using the SDK with mock data (no server required)
|
|
125
|
+
- **[Mock API](https://emersonfelipesp.github.io/proxmox-openapi/mock-api/)** - Mock mode guide with custom data
|
|
126
|
+
- **[Real API](https://emersonfelipesp.github.io/proxmox-openapi/real-api/)** - Real Proxmox integration guide
|
|
127
|
+
- **[API Reference](https://emersonfelipesp.github.io/proxmox-openapi/api-reference/)** - Endpoint documentation
|
|
128
|
+
- **[Development](https://emersonfelipesp.github.io/proxmox-openapi/development/)** - Contributing guide
|
|
129
|
+
- **[Architecture](https://emersonfelipesp.github.io/proxmox-openapi/architecture/)** - How it works internally
|
|
130
|
+
- **[FAQ](https://emersonfelipesp.github.io/proxmox-openapi/faq/)** - Frequently asked questions
|
|
131
|
+
|
|
132
|
+
## Environment Variables
|
|
133
|
+
|
|
134
|
+
### Mock Mode
|
|
135
|
+
- `PROXMOX_API_MODE` - Set to "mock" (default) or "real"
|
|
136
|
+
- `PROXMOX_MOCK_SCHEMA_VERSION` - Version tag to use (default: "latest")
|
|
137
|
+
- `PROXMOX_MOCK_DATA_PATH` - Path to custom mock data file (default: "/etc/proxmox-openapi/mock-data.json")
|
|
138
|
+
|
|
139
|
+
### Real Mode
|
|
140
|
+
- `PROXMOX_API_MODE` - Set to "real" to enable Proxmox integration
|
|
141
|
+
- `PROXMOX_URL` - Proxmox server URL (e.g., "https://proxmox.example.com:8006")
|
|
142
|
+
- `PROXMOX_API_TOKEN` - API token (recommended, format: "PVEAPIToken=user@realm!tokenid=uuid")
|
|
143
|
+
- `PROXMOX_USERNAME` - Username (fallback, format: "user@realm")
|
|
144
|
+
- `PROXMOX_PASSWORD` - Password (fallback)
|
|
145
|
+
- `PROXMOX_API_VERIFY_SSL` - Verify SSL certificates (default: true)
|
|
146
|
+
|
|
147
|
+
### Server
|
|
148
|
+
- `HOST` - Host to bind to (default: "0.0.0.0")
|
|
149
|
+
- `PORT` - Port to bind to (default: "8000")
|
|
150
|
+
|
|
151
|
+
## Development
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Install dependencies
|
|
155
|
+
uv sync --extra test
|
|
156
|
+
|
|
157
|
+
# Run tests
|
|
158
|
+
pytest
|
|
159
|
+
|
|
160
|
+
# Run linting
|
|
161
|
+
ruff check .
|
|
162
|
+
ruff format --check .
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Docker
|
|
166
|
+
|
|
167
|
+
All images are **Alpine-based** (smaller footprint), built from this repository with **uv** and **`uv.lock`** in a multi-stage Dockerfile. Three variants are published to Docker Hub:
|
|
168
|
+
|
|
169
|
+
| Variant | Tags | Description |
|
|
170
|
+
|---------|------|-------------|
|
|
171
|
+
| **Raw** (default) | `latest`, `<version>` | Pure uvicorn, HTTP only. Smallest image. |
|
|
172
|
+
| **Nginx** | `latest-nginx`, `<version>-nginx` | nginx terminates HTTPS via mkcert; proxies to uvicorn. |
|
|
173
|
+
| **Granian** | `latest-granian`, `<version>-granian` | [Granian](https://github.com/emmett-framework/granian) (Rust ASGI server) with native TLS via mkcert. No nginx. |
|
|
174
|
+
|
|
175
|
+
> **Upgrade note:** before v0.0.2, only runtime+mkcert images existed. From v0.0.2+, `latest` is the raw uvicorn image. Pull `latest-nginx` for HTTPS with nginx.
|
|
176
|
+
|
|
177
|
+
### Raw image (default)
|
|
178
|
+
|
|
179
|
+
Plain uvicorn on HTTP — the simplest option for local dev or when you put your own proxy in front.
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
docker pull emersonfelipesp/proxmox-openapi:latest
|
|
183
|
+
docker run -d -p 8000:8000 --name proxmox-openapi emersonfelipesp/proxmox-openapi:latest
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Build from source:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
docker build -t proxmox-openapi:raw .
|
|
190
|
+
docker run -d -p 8000:8000 proxmox-openapi:raw
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Nginx image (nginx + mkcert HTTPS + uvicorn)
|
|
194
|
+
|
|
195
|
+
**nginx** terminates HTTPS on `PORT` (default **8000**) using certificates from [mkcert](https://github.com/FiloSottile/mkcert) and proxies to **uvicorn** on `127.0.0.1:8001`. **supervisord** manages both processes.
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
docker pull emersonfelipesp/proxmox-openapi:latest-nginx
|
|
199
|
+
docker run -d -p 8443:8000 --name proxmox-openapi-nginx \
|
|
200
|
+
emersonfelipesp/proxmox-openapi:latest-nginx
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Build from source:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
docker build --target nginx -t proxmox-openapi:nginx .
|
|
207
|
+
docker run -d -p 8443:8000 proxmox-openapi:nginx
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Granian image (granian + mkcert HTTPS)
|
|
211
|
+
|
|
212
|
+
[Granian](https://github.com/emmett-framework/granian) is a Rust-based ASGI server with native HTTP/2, WebSocket, and TLS support. This variant eliminates nginx and supervisord — a single granian process handles everything.
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
docker pull emersonfelipesp/proxmox-openapi:latest-granian
|
|
216
|
+
docker run -d -p 8443:8000 --name proxmox-openapi-granian \
|
|
217
|
+
emersonfelipesp/proxmox-openapi:latest-granian
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Build from source:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
docker build --target granian -t proxmox-openapi:granian .
|
|
224
|
+
docker run -d -p 8443:8000 proxmox-openapi:granian
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### mkcert environment variables (nginx and granian images)
|
|
228
|
+
|
|
229
|
+
| Variable | Default | Description |
|
|
230
|
+
|----------|---------|-------------|
|
|
231
|
+
| `PORT` | `8000` | Port the server listens on |
|
|
232
|
+
| `MKCERT_CERT_DIR` | `/certs` | Directory where certs are stored |
|
|
233
|
+
| `MKCERT_EXTRA_NAMES` | — | Extra SANs (commas or spaces), e.g. `proxmox-api.lan,10.0.0.5` |
|
|
234
|
+
| `CAROOT` | — | Mount a volume here to persist the local CA across container restarts |
|
|
235
|
+
| `APP_MODULE` | `proxmox_openapi.mock_main:app` | ASGI app to run (change to `proxmox_openapi.main:app` for real mode) |
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
docker run -d -p 8443:8000 --name proxmox-openapi-tls \
|
|
239
|
+
-e MKCERT_EXTRA_NAMES='myhost.local,192.168.1.10' \
|
|
240
|
+
-e APP_MODULE='proxmox_openapi.main:app' \
|
|
241
|
+
emersonfelipesp/proxmox-openapi:latest-nginx
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
To run a shell instead of starting the server, pass a command (the entrypoint delegates to it):
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
docker run --rm emersonfelipesp/proxmox-openapi:latest-nginx sh
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## License
|
|
251
|
+
|
|
252
|
+
MIT
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# proxmox-openapi
|
|
2
|
+
|
|
3
|
+
Schema-driven FastAPI package for Proxmox API: OpenAPI generation, mock data, and in-memory CRUD operations.
|
|
4
|
+
|
|
5
|
+
**📚 [Full Documentation](https://emersonfelipesp.github.io/proxmox-openapi/)**
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Dual Mode**: Mock mode (default) for development, Real mode for production Proxmox integration
|
|
10
|
+
- **646 Endpoints**: Pre-generated Proxmox VE 8.1 API with full OpenAPI schema
|
|
11
|
+
- **Mock Data**: Automatically generate mock data for all endpoints with in-memory CRUD
|
|
12
|
+
- **Real API Proxy**: Validated proxy to real Proxmox VE API with request/response validation
|
|
13
|
+
- **Code Generation**: Automatically crawl Proxmox API Viewer and convert to OpenAPI schema
|
|
14
|
+
- **Multi-version Support**: Select multiple Proxmox versions with `latest` mapped to official Proxmox API viewer
|
|
15
|
+
- **Swagger Docs**: FastAPI auto-generates OpenAPI documentation at `/docs`
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install proxmox-openapi
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### Mock Mode (Default)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Install
|
|
29
|
+
pip install proxmox-openapi
|
|
30
|
+
|
|
31
|
+
# Start server
|
|
32
|
+
uvicorn proxmox_openapi.main:app --reload
|
|
33
|
+
|
|
34
|
+
# View Swagger docs
|
|
35
|
+
# Open http://localhost:8000/docs
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### SDK Direct Usage (No Server Required)
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from proxmox_openapi.sdk import ProxmoxSDK
|
|
42
|
+
|
|
43
|
+
# Async with mock data
|
|
44
|
+
async with ProxmoxSDK.mock() as proxmox:
|
|
45
|
+
nodes = await proxmox.nodes.get()
|
|
46
|
+
|
|
47
|
+
# Or sync (blocking)
|
|
48
|
+
with ProxmoxSDK.sync_mock() as proxmox:
|
|
49
|
+
nodes = proxmox.nodes.get()
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### CLI TUI
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Install with CLI extras
|
|
56
|
+
pip install proxmox-openapi[cli]
|
|
57
|
+
|
|
58
|
+
# Production TUI
|
|
59
|
+
pbx tui
|
|
60
|
+
|
|
61
|
+
# Mock TUI
|
|
62
|
+
pbx tui mock
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Real Mode (Connect to Proxmox)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Configure credentials
|
|
69
|
+
export PROXMOX_API_MODE=real
|
|
70
|
+
export PROXMOX_URL=https://proxmox.example.com:8006
|
|
71
|
+
export PROXMOX_API_TOKEN=PVEAPIToken=user@realm!tokenid=uuid
|
|
72
|
+
|
|
73
|
+
# Start server
|
|
74
|
+
uvicorn proxmox_openapi.main:app --reload
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
See the [Quick Start Guide](https://emersonfelipesp.github.io/proxmox-openapi/quickstart/) for more details.
|
|
78
|
+
|
|
79
|
+
## Documentation
|
|
80
|
+
|
|
81
|
+
- **[Home](https://emersonfelipesp.github.io/proxmox-openapi/)** - Overview and features
|
|
82
|
+
- **[Installation](https://emersonfelipesp.github.io/proxmox-openapi/installation/)** - Installation options (pip, uv, Docker, source)
|
|
83
|
+
- **[Quick Start](https://emersonfelipesp.github.io/proxmox-openapi/quickstart/)** - 5-minute getting started guide
|
|
84
|
+
- **[SDK Mock Usage](https://emersonfelipesp.github.io/proxmox-openapi/sdk-mock/)** - Using the SDK with mock data (no server required)
|
|
85
|
+
- **[Mock API](https://emersonfelipesp.github.io/proxmox-openapi/mock-api/)** - Mock mode guide with custom data
|
|
86
|
+
- **[Real API](https://emersonfelipesp.github.io/proxmox-openapi/real-api/)** - Real Proxmox integration guide
|
|
87
|
+
- **[API Reference](https://emersonfelipesp.github.io/proxmox-openapi/api-reference/)** - Endpoint documentation
|
|
88
|
+
- **[Development](https://emersonfelipesp.github.io/proxmox-openapi/development/)** - Contributing guide
|
|
89
|
+
- **[Architecture](https://emersonfelipesp.github.io/proxmox-openapi/architecture/)** - How it works internally
|
|
90
|
+
- **[FAQ](https://emersonfelipesp.github.io/proxmox-openapi/faq/)** - Frequently asked questions
|
|
91
|
+
|
|
92
|
+
## Environment Variables
|
|
93
|
+
|
|
94
|
+
### Mock Mode
|
|
95
|
+
- `PROXMOX_API_MODE` - Set to "mock" (default) or "real"
|
|
96
|
+
- `PROXMOX_MOCK_SCHEMA_VERSION` - Version tag to use (default: "latest")
|
|
97
|
+
- `PROXMOX_MOCK_DATA_PATH` - Path to custom mock data file (default: "/etc/proxmox-openapi/mock-data.json")
|
|
98
|
+
|
|
99
|
+
### Real Mode
|
|
100
|
+
- `PROXMOX_API_MODE` - Set to "real" to enable Proxmox integration
|
|
101
|
+
- `PROXMOX_URL` - Proxmox server URL (e.g., "https://proxmox.example.com:8006")
|
|
102
|
+
- `PROXMOX_API_TOKEN` - API token (recommended, format: "PVEAPIToken=user@realm!tokenid=uuid")
|
|
103
|
+
- `PROXMOX_USERNAME` - Username (fallback, format: "user@realm")
|
|
104
|
+
- `PROXMOX_PASSWORD` - Password (fallback)
|
|
105
|
+
- `PROXMOX_API_VERIFY_SSL` - Verify SSL certificates (default: true)
|
|
106
|
+
|
|
107
|
+
### Server
|
|
108
|
+
- `HOST` - Host to bind to (default: "0.0.0.0")
|
|
109
|
+
- `PORT` - Port to bind to (default: "8000")
|
|
110
|
+
|
|
111
|
+
## Development
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Install dependencies
|
|
115
|
+
uv sync --extra test
|
|
116
|
+
|
|
117
|
+
# Run tests
|
|
118
|
+
pytest
|
|
119
|
+
|
|
120
|
+
# Run linting
|
|
121
|
+
ruff check .
|
|
122
|
+
ruff format --check .
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Docker
|
|
126
|
+
|
|
127
|
+
All images are **Alpine-based** (smaller footprint), built from this repository with **uv** and **`uv.lock`** in a multi-stage Dockerfile. Three variants are published to Docker Hub:
|
|
128
|
+
|
|
129
|
+
| Variant | Tags | Description |
|
|
130
|
+
|---------|------|-------------|
|
|
131
|
+
| **Raw** (default) | `latest`, `<version>` | Pure uvicorn, HTTP only. Smallest image. |
|
|
132
|
+
| **Nginx** | `latest-nginx`, `<version>-nginx` | nginx terminates HTTPS via mkcert; proxies to uvicorn. |
|
|
133
|
+
| **Granian** | `latest-granian`, `<version>-granian` | [Granian](https://github.com/emmett-framework/granian) (Rust ASGI server) with native TLS via mkcert. No nginx. |
|
|
134
|
+
|
|
135
|
+
> **Upgrade note:** before v0.0.2, only runtime+mkcert images existed. From v0.0.2+, `latest` is the raw uvicorn image. Pull `latest-nginx` for HTTPS with nginx.
|
|
136
|
+
|
|
137
|
+
### Raw image (default)
|
|
138
|
+
|
|
139
|
+
Plain uvicorn on HTTP — the simplest option for local dev or when you put your own proxy in front.
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
docker pull emersonfelipesp/proxmox-openapi:latest
|
|
143
|
+
docker run -d -p 8000:8000 --name proxmox-openapi emersonfelipesp/proxmox-openapi:latest
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Build from source:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
docker build -t proxmox-openapi:raw .
|
|
150
|
+
docker run -d -p 8000:8000 proxmox-openapi:raw
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Nginx image (nginx + mkcert HTTPS + uvicorn)
|
|
154
|
+
|
|
155
|
+
**nginx** terminates HTTPS on `PORT` (default **8000**) using certificates from [mkcert](https://github.com/FiloSottile/mkcert) and proxies to **uvicorn** on `127.0.0.1:8001`. **supervisord** manages both processes.
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
docker pull emersonfelipesp/proxmox-openapi:latest-nginx
|
|
159
|
+
docker run -d -p 8443:8000 --name proxmox-openapi-nginx \
|
|
160
|
+
emersonfelipesp/proxmox-openapi:latest-nginx
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Build from source:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
docker build --target nginx -t proxmox-openapi:nginx .
|
|
167
|
+
docker run -d -p 8443:8000 proxmox-openapi:nginx
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Granian image (granian + mkcert HTTPS)
|
|
171
|
+
|
|
172
|
+
[Granian](https://github.com/emmett-framework/granian) is a Rust-based ASGI server with native HTTP/2, WebSocket, and TLS support. This variant eliminates nginx and supervisord — a single granian process handles everything.
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
docker pull emersonfelipesp/proxmox-openapi:latest-granian
|
|
176
|
+
docker run -d -p 8443:8000 --name proxmox-openapi-granian \
|
|
177
|
+
emersonfelipesp/proxmox-openapi:latest-granian
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Build from source:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
docker build --target granian -t proxmox-openapi:granian .
|
|
184
|
+
docker run -d -p 8443:8000 proxmox-openapi:granian
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### mkcert environment variables (nginx and granian images)
|
|
188
|
+
|
|
189
|
+
| Variable | Default | Description |
|
|
190
|
+
|----------|---------|-------------|
|
|
191
|
+
| `PORT` | `8000` | Port the server listens on |
|
|
192
|
+
| `MKCERT_CERT_DIR` | `/certs` | Directory where certs are stored |
|
|
193
|
+
| `MKCERT_EXTRA_NAMES` | — | Extra SANs (commas or spaces), e.g. `proxmox-api.lan,10.0.0.5` |
|
|
194
|
+
| `CAROOT` | — | Mount a volume here to persist the local CA across container restarts |
|
|
195
|
+
| `APP_MODULE` | `proxmox_openapi.mock_main:app` | ASGI app to run (change to `proxmox_openapi.main:app` for real mode) |
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
docker run -d -p 8443:8000 --name proxmox-openapi-tls \
|
|
199
|
+
-e MKCERT_EXTRA_NAMES='myhost.local,192.168.1.10' \
|
|
200
|
+
-e APP_MODULE='proxmox_openapi.main:app' \
|
|
201
|
+
emersonfelipesp/proxmox-openapi:latest-nginx
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
To run a shell instead of starting the server, pass a command (the entrypoint delegates to it):
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
docker run --rm emersonfelipesp/proxmox-openapi:latest-nginx sh
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
MIT
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Proxmox OpenAPI — schema-driven FastAPI package and standalone Python SDK."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.0.2"
|
|
4
|
+
|
|
5
|
+
# Lazy imports: avoid constructing FastAPI apps or loading heavy SDK modules
|
|
6
|
+
# at package import time. Attributes are resolved on first access only.
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
# FastAPI
|
|
10
|
+
"app",
|
|
11
|
+
"mock_app",
|
|
12
|
+
"run",
|
|
13
|
+
# SDK
|
|
14
|
+
"ProxmoxSDK",
|
|
15
|
+
"SyncProxmoxSDK",
|
|
16
|
+
"ResourceException",
|
|
17
|
+
"AuthenticationError",
|
|
18
|
+
"BackendNotAvailableError",
|
|
19
|
+
"ProxmoxSDKError",
|
|
20
|
+
"Tasks",
|
|
21
|
+
"Files",
|
|
22
|
+
"__version__",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
_LAZY_IMPORTS: dict[str, tuple[str, str]] = {
|
|
26
|
+
# (module_path, attribute_name)
|
|
27
|
+
"app": ("proxmox_openapi.main", "app"),
|
|
28
|
+
"mock_app": ("proxmox_openapi.mock_main", "app"),
|
|
29
|
+
"run": ("proxmox_openapi.mock_main", "run"),
|
|
30
|
+
"ProxmoxSDK": ("proxmox_openapi.sdk.api", "ProxmoxSDK"),
|
|
31
|
+
"SyncProxmoxSDK": ("proxmox_openapi.sdk.sync", "SyncProxmoxSDK"),
|
|
32
|
+
"ResourceException": ("proxmox_openapi.sdk.exceptions", "ResourceException"),
|
|
33
|
+
"AuthenticationError": ("proxmox_openapi.sdk.exceptions", "AuthenticationError"),
|
|
34
|
+
"BackendNotAvailableError": ("proxmox_openapi.sdk.exceptions", "BackendNotAvailableError"),
|
|
35
|
+
"ProxmoxSDKError": ("proxmox_openapi.sdk.exceptions", "ProxmoxSDKError"),
|
|
36
|
+
"Tasks": ("proxmox_openapi.sdk.tools.tasks", "Tasks"),
|
|
37
|
+
"Files": ("proxmox_openapi.sdk.tools.files", "Files"),
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def __getattr__(name: str):
|
|
42
|
+
if name in _LAZY_IMPORTS:
|
|
43
|
+
module_path, attr = _LAZY_IMPORTS[name]
|
|
44
|
+
import importlib
|
|
45
|
+
|
|
46
|
+
mod = importlib.import_module(module_path)
|
|
47
|
+
value = getattr(mod, attr)
|
|
48
|
+
# Cache on the module so __getattr__ is not called again for this name.
|
|
49
|
+
globals()[name] = value
|
|
50
|
+
return value
|
|
51
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Exception classes for proxmox-openapi."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ProxmoxOpenAPIException(Exception):
|
|
5
|
+
"""Base exception for proxmox-openapi."""
|
|
6
|
+
|
|
7
|
+
def __init__(
|
|
8
|
+
self, message: str, detail: str | None = None, python_exception: str | None = None
|
|
9
|
+
):
|
|
10
|
+
self.message = message
|
|
11
|
+
self.detail = detail
|
|
12
|
+
self.python_exception = python_exception
|
|
13
|
+
super().__init__(self.message)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__all__ = ["ProxmoxOpenAPIException"]
|