qiloback-sdk 0.3.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.
- qiloback_sdk-0.3.2/.gitignore +64 -0
- qiloback_sdk-0.3.2/LICENSE +102 -0
- qiloback_sdk-0.3.2/PKG-INFO +73 -0
- qiloback_sdk-0.3.2/README.md +48 -0
- qiloback_sdk-0.3.2/pyproject.toml +39 -0
- qiloback_sdk-0.3.2/src/qiloback/__init__.py +45 -0
- qiloback_sdk-0.3.2/src/qiloback/_client.py +269 -0
- qiloback_sdk-0.3.2/src/qiloback/_errors.py +73 -0
- qiloback_sdk-0.3.2/src/qiloback/_models.py +91 -0
- qiloback_sdk-0.3.2/tests/test_client.py +201 -0
- qiloback_sdk-0.3.2/tests/test_client_extended.py +430 -0
- qiloback_sdk-0.3.2/tests/test_components.py +107 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.pyc
|
|
4
|
+
*.pyo
|
|
5
|
+
*.pyd
|
|
6
|
+
*.egg-info/
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
*.egg
|
|
10
|
+
.venv/
|
|
11
|
+
venv/
|
|
12
|
+
|
|
13
|
+
# uv
|
|
14
|
+
.python-version
|
|
15
|
+
|
|
16
|
+
# Testing
|
|
17
|
+
.coverage
|
|
18
|
+
htmlcov/
|
|
19
|
+
.pytest_cache/
|
|
20
|
+
|
|
21
|
+
# Environment
|
|
22
|
+
.env
|
|
23
|
+
.env.local
|
|
24
|
+
.env.production
|
|
25
|
+
|
|
26
|
+
# Secrets (JWT keys, signing material)
|
|
27
|
+
.keys/
|
|
28
|
+
|
|
29
|
+
# IDE
|
|
30
|
+
.vscode/
|
|
31
|
+
.idea/
|
|
32
|
+
*.swp
|
|
33
|
+
*.swo
|
|
34
|
+
|
|
35
|
+
# OS
|
|
36
|
+
.DS_Store
|
|
37
|
+
Thumbs.db
|
|
38
|
+
|
|
39
|
+
# Node (admin panel)
|
|
40
|
+
node_modules/
|
|
41
|
+
.next/
|
|
42
|
+
out/
|
|
43
|
+
.turbo/
|
|
44
|
+
|
|
45
|
+
# Generated output
|
|
46
|
+
generated/*/
|
|
47
|
+
|
|
48
|
+
# Docker
|
|
49
|
+
*.log
|
|
50
|
+
|
|
51
|
+
# Lock files for generated projects
|
|
52
|
+
# (the platform's own lock files are tracked)
|
|
53
|
+
generated/**/.bp-lock.json
|
|
54
|
+
|
|
55
|
+
# Database
|
|
56
|
+
*.db
|
|
57
|
+
*.sqlite3
|
|
58
|
+
tsconfig.tsbuildinfo
|
|
59
|
+
docs/internal/
|
|
60
|
+
|
|
61
|
+
# uv.lock and pnpm-lock.yaml are committed for reproducibility — see
|
|
62
|
+
# Renovate / Dependabot config for the bot-driven update cadence.
|
|
63
|
+
wrappers/pip/.venv
|
|
64
|
+
wrappers/pip/uv.lock
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, Apache 2.0 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-ALv2
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 XPlus Technologies LLC
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN
|
|
79
|
+
IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following will
|
|
93
|
+
apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
97
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
98
|
+
|
|
99
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
100
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
101
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
102
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qiloback-sdk
|
|
3
|
+
Version: 0.3.2
|
|
4
|
+
Summary: Official QiloBack Python SDK — talk to a QiloBack platform-api from Python.
|
|
5
|
+
Project-URL: Homepage, https://qiloback.dev
|
|
6
|
+
Project-URL: Documentation, https://qiloback.dev/docs/sdk-py
|
|
7
|
+
Project-URL: Repository, https://github.com/delixon-labs/delixon-qiloback
|
|
8
|
+
Project-URL: Issues, https://github.com/delixon-labs/delixon-qiloback/issues
|
|
9
|
+
Author-email: Delixon Labs <hello@delixon.dev>
|
|
10
|
+
License-Expression: LicenseRef-FSL-1.1-ALv2
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: backend,client,dsl,fastapi,qiloback,sdk
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: httpx>=0.27
|
|
23
|
+
Requires-Dist: pydantic>=2.6
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# qiloback-sdk
|
|
27
|
+
|
|
28
|
+
Official Python SDK for the QiloBack platform-api.
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install qiloback-sdk
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick start
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from qiloback import Client
|
|
40
|
+
|
|
41
|
+
with Client(base_url="https://api.qiloback.dev", token="...") as qb:
|
|
42
|
+
project = qb.projects.create(name="My CRM", slug="my_crm")
|
|
43
|
+
qb.projects.upload_dsl(project.id, dsl_yaml)
|
|
44
|
+
log = qb.projects.generate(project.id)
|
|
45
|
+
print(log.status)
|
|
46
|
+
|
|
47
|
+
# Eject a portable bundle and write it to disk
|
|
48
|
+
bundle = qb.projects.eject(project.id)
|
|
49
|
+
bundle.save_to("./my-crm.zip")
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The SDK is intentionally thin: it wraps the most-used surface
|
|
53
|
+
(projects, DSL, generations, eject, audit, health) with type-safe
|
|
54
|
+
methods, and falls back to a raw `client.request(...)` for anything
|
|
55
|
+
not yet covered. The full 193-endpoint surface is auto-generated
|
|
56
|
+
from the OpenAPI snapshot in v0.2.
|
|
57
|
+
|
|
58
|
+
## Auth
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
qb = Client(base_url="...", token="bearer-token")
|
|
62
|
+
# or
|
|
63
|
+
qb = Client(base_url="...")
|
|
64
|
+
qb.set_token("bearer-token")
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The SDK is sync today; an async variant (`AsyncClient`) ships in v0.2
|
|
68
|
+
with the same surface.
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
Source-available under FSL-1.1-ALv2. Auto-conversion to Apache 2.0 two
|
|
73
|
+
years after each release. See the QiloBack LICENSE-FAQ for details.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# qiloback-sdk
|
|
2
|
+
|
|
3
|
+
Official Python SDK for the QiloBack platform-api.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install qiloback-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from qiloback import Client
|
|
15
|
+
|
|
16
|
+
with Client(base_url="https://api.qiloback.dev", token="...") as qb:
|
|
17
|
+
project = qb.projects.create(name="My CRM", slug="my_crm")
|
|
18
|
+
qb.projects.upload_dsl(project.id, dsl_yaml)
|
|
19
|
+
log = qb.projects.generate(project.id)
|
|
20
|
+
print(log.status)
|
|
21
|
+
|
|
22
|
+
# Eject a portable bundle and write it to disk
|
|
23
|
+
bundle = qb.projects.eject(project.id)
|
|
24
|
+
bundle.save_to("./my-crm.zip")
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The SDK is intentionally thin: it wraps the most-used surface
|
|
28
|
+
(projects, DSL, generations, eject, audit, health) with type-safe
|
|
29
|
+
methods, and falls back to a raw `client.request(...)` for anything
|
|
30
|
+
not yet covered. The full 193-endpoint surface is auto-generated
|
|
31
|
+
from the OpenAPI snapshot in v0.2.
|
|
32
|
+
|
|
33
|
+
## Auth
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
qb = Client(base_url="...", token="bearer-token")
|
|
37
|
+
# or
|
|
38
|
+
qb = Client(base_url="...")
|
|
39
|
+
qb.set_token("bearer-token")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The SDK is sync today; an async variant (`AsyncClient`) ships in v0.2
|
|
43
|
+
with the same surface.
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
Source-available under FSL-1.1-ALv2. Auto-conversion to Apache 2.0 two
|
|
48
|
+
years after each release. See the QiloBack LICENSE-FAQ for details.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "qiloback-sdk"
|
|
7
|
+
version = "0.3.2"
|
|
8
|
+
description = "Official QiloBack Python SDK — talk to a QiloBack platform-api from Python."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "LicenseRef-FSL-1.1-ALv2"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "Delixon Labs", email = "hello@delixon.dev"},
|
|
15
|
+
]
|
|
16
|
+
keywords = ["qiloback", "sdk", "client", "backend", "fastapi", "dsl"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 4 - Beta",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"httpx>=0.27",
|
|
29
|
+
"pydantic>=2.6",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://qiloback.dev"
|
|
34
|
+
Documentation = "https://qiloback.dev/docs/sdk-py"
|
|
35
|
+
Repository = "https://github.com/delixon-labs/delixon-qiloback"
|
|
36
|
+
Issues = "https://github.com/delixon-labs/delixon-qiloback/issues"
|
|
37
|
+
|
|
38
|
+
[tool.hatch.build.targets.wheel]
|
|
39
|
+
packages = ["src/qiloback"]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""QiloBack Python SDK — sync client for the platform-api.
|
|
2
|
+
|
|
3
|
+
Public surface kept deliberately small so the import line is a single
|
|
4
|
+
``from qiloback import Client`` and everything else hangs off the
|
|
5
|
+
client. The async variant lands in v0.2 alongside the auto-generated
|
|
6
|
+
full-surface client; until then anything not exposed as a typed method
|
|
7
|
+
is reachable via ``client.request("GET", "/api/v1/...")`` which
|
|
8
|
+
returns the raw ``httpx.Response``.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from qiloback._client import Client, ComponentsAPI
|
|
14
|
+
from qiloback._errors import (
|
|
15
|
+
APIError,
|
|
16
|
+
AuthError,
|
|
17
|
+
NotFoundError,
|
|
18
|
+
QiloBackError,
|
|
19
|
+
ValidationError,
|
|
20
|
+
)
|
|
21
|
+
from qiloback._models import (
|
|
22
|
+
DSLDiff,
|
|
23
|
+
EjectBundle,
|
|
24
|
+
GenerationLog,
|
|
25
|
+
Project,
|
|
26
|
+
ValidationResult,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
__version__ = "0.1.0"
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
"APIError",
|
|
33
|
+
"AuthError",
|
|
34
|
+
"Client",
|
|
35
|
+
"ComponentsAPI",
|
|
36
|
+
"DSLDiff",
|
|
37
|
+
"EjectBundle",
|
|
38
|
+
"GenerationLog",
|
|
39
|
+
"NotFoundError",
|
|
40
|
+
"Project",
|
|
41
|
+
"QiloBackError",
|
|
42
|
+
"ValidationError",
|
|
43
|
+
"ValidationResult",
|
|
44
|
+
"__version__",
|
|
45
|
+
]
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"""Sync client for the QiloBack platform-api.
|
|
2
|
+
|
|
3
|
+
The class layers a small ergonomic surface (``client.projects.list()``)
|
|
4
|
+
on top of an httpx.Client. Anything not covered by the typed methods
|
|
5
|
+
is reachable through ``client.request(method, path, **kwargs)`` which
|
|
6
|
+
returns the raw ``httpx.Response`` (after the 4xx/5xx mapping has run).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import re
|
|
12
|
+
from collections.abc import Sequence
|
|
13
|
+
from types import TracebackType
|
|
14
|
+
from typing import Any
|
|
15
|
+
from uuid import UUID
|
|
16
|
+
|
|
17
|
+
import httpx
|
|
18
|
+
|
|
19
|
+
from qiloback._errors import raise_for_response
|
|
20
|
+
from qiloback._models import DSLDiff, EjectBundle, GenerationLog, Project, ValidationResult
|
|
21
|
+
|
|
22
|
+
_FILENAME_RE = re.compile(r'filename="?([^"]+)"?')
|
|
23
|
+
_DEFAULT_TIMEOUT = httpx.Timeout(30.0, connect=10.0)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Client:
|
|
27
|
+
"""Sync entry point. Use as a context manager when possible.
|
|
28
|
+
|
|
29
|
+
>>> with Client(base_url="...", token="...") as qb:
|
|
30
|
+
... for project in qb.projects.list():
|
|
31
|
+
... print(project.slug)
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
*,
|
|
37
|
+
base_url: str,
|
|
38
|
+
token: str | None = None,
|
|
39
|
+
timeout: float | httpx.Timeout = _DEFAULT_TIMEOUT,
|
|
40
|
+
http_client: httpx.Client | None = None,
|
|
41
|
+
) -> None:
|
|
42
|
+
self._base_url = base_url.rstrip("/")
|
|
43
|
+
self._token = token or ""
|
|
44
|
+
self._owns_http = http_client is None
|
|
45
|
+
self._http = http_client or httpx.Client(
|
|
46
|
+
base_url=self._base_url,
|
|
47
|
+
timeout=timeout,
|
|
48
|
+
)
|
|
49
|
+
self.projects = ProjectsAPI(self)
|
|
50
|
+
self.audit = AuditAPI(self)
|
|
51
|
+
self.components = ComponentsAPI(self)
|
|
52
|
+
|
|
53
|
+
# ── Lifecycle ───────────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
def close(self) -> None:
|
|
56
|
+
if self._owns_http:
|
|
57
|
+
self._http.close()
|
|
58
|
+
|
|
59
|
+
def __enter__(self) -> Client:
|
|
60
|
+
return self
|
|
61
|
+
|
|
62
|
+
def __exit__(
|
|
63
|
+
self,
|
|
64
|
+
exc_type: type[BaseException] | None,
|
|
65
|
+
exc: BaseException | None,
|
|
66
|
+
tb: TracebackType | None,
|
|
67
|
+
) -> None:
|
|
68
|
+
self.close()
|
|
69
|
+
|
|
70
|
+
# ── Auth ────────────────────────────────────────────────────
|
|
71
|
+
|
|
72
|
+
def set_token(self, token: str | None) -> None:
|
|
73
|
+
self._token = token or ""
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def token(self) -> str:
|
|
77
|
+
return self._token
|
|
78
|
+
|
|
79
|
+
# ── HTTP ────────────────────────────────────────────────────
|
|
80
|
+
|
|
81
|
+
def _headers(self, extra: dict[str, str] | None = None) -> dict[str, str]:
|
|
82
|
+
headers: dict[str, str] = {"Accept": "application/json"}
|
|
83
|
+
if self._token:
|
|
84
|
+
headers["Authorization"] = f"Bearer {self._token}"
|
|
85
|
+
if extra:
|
|
86
|
+
headers.update(extra)
|
|
87
|
+
return headers
|
|
88
|
+
|
|
89
|
+
def request(
|
|
90
|
+
self,
|
|
91
|
+
method: str,
|
|
92
|
+
path: str,
|
|
93
|
+
*,
|
|
94
|
+
params: dict[str, Any] | None = None,
|
|
95
|
+
json: Any = None,
|
|
96
|
+
headers: dict[str, str] | None = None,
|
|
97
|
+
timeout: float | httpx.Timeout | None = None,
|
|
98
|
+
) -> httpx.Response:
|
|
99
|
+
"""Lower-level call that bypasses the typed surface.
|
|
100
|
+
|
|
101
|
+
Useful for endpoints not yet wrapped by a method on the SDK.
|
|
102
|
+
Raises one of the SDK exception classes on a non-2xx status;
|
|
103
|
+
otherwise returns the raw ``httpx.Response``.
|
|
104
|
+
"""
|
|
105
|
+
response = self._http.request(
|
|
106
|
+
method,
|
|
107
|
+
path,
|
|
108
|
+
params=params,
|
|
109
|
+
json=json,
|
|
110
|
+
headers=self._headers(headers),
|
|
111
|
+
timeout=timeout if timeout is not None else self._http.timeout,
|
|
112
|
+
)
|
|
113
|
+
raise_for_response(response)
|
|
114
|
+
return response
|
|
115
|
+
|
|
116
|
+
# ── High-level helpers ──────────────────────────────────────
|
|
117
|
+
|
|
118
|
+
def health(self) -> dict[str, Any]:
|
|
119
|
+
"""Hit ``/health`` and return the JSON payload."""
|
|
120
|
+
response = self.request("GET", "/health")
|
|
121
|
+
result = response.json()
|
|
122
|
+
return result if isinstance(result, dict) else {}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
# ── Resource façades ────────────────────────────────────────────
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class _Resource:
|
|
129
|
+
def __init__(self, client: Client) -> None:
|
|
130
|
+
self._client = client
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class ProjectsAPI(_Resource):
|
|
134
|
+
"""Wraps everything under ``/api/v1/projects``."""
|
|
135
|
+
|
|
136
|
+
def list(self, include_archived: bool = False) -> Sequence[Project]:
|
|
137
|
+
response = self._client.request(
|
|
138
|
+
"GET",
|
|
139
|
+
"/api/v1/projects",
|
|
140
|
+
params={"include_archived": str(include_archived).lower()},
|
|
141
|
+
)
|
|
142
|
+
return [Project.model_validate(row) for row in response.json()]
|
|
143
|
+
|
|
144
|
+
def get(self, project_id: UUID | str) -> Project:
|
|
145
|
+
response = self._client.request("GET", f"/api/v1/projects/{project_id}")
|
|
146
|
+
return Project.model_validate(response.json())
|
|
147
|
+
|
|
148
|
+
def create(
|
|
149
|
+
self,
|
|
150
|
+
*,
|
|
151
|
+
name: str,
|
|
152
|
+
slug: str,
|
|
153
|
+
description: str | None = None,
|
|
154
|
+
) -> Project:
|
|
155
|
+
response = self._client.request(
|
|
156
|
+
"POST",
|
|
157
|
+
"/api/v1/projects",
|
|
158
|
+
json={"name": name, "slug": slug, "description": description},
|
|
159
|
+
)
|
|
160
|
+
return Project.model_validate(response.json())
|
|
161
|
+
|
|
162
|
+
def delete(self, project_id: UUID | str) -> None:
|
|
163
|
+
self._client.request("DELETE", f"/api/v1/projects/{project_id}")
|
|
164
|
+
|
|
165
|
+
# ── DSL ───────────────────────────────────────────────────
|
|
166
|
+
|
|
167
|
+
def upload_dsl(self, project_id: UUID | str, content: str) -> dict[str, Any]:
|
|
168
|
+
response = self._client.request(
|
|
169
|
+
"POST",
|
|
170
|
+
f"/api/v1/projects/{project_id}/dsl",
|
|
171
|
+
json={"content": content},
|
|
172
|
+
)
|
|
173
|
+
return dict(response.json())
|
|
174
|
+
|
|
175
|
+
def get_dsl(self, project_id: UUID | str) -> dict[str, Any]:
|
|
176
|
+
response = self._client.request("GET", f"/api/v1/projects/{project_id}/dsl")
|
|
177
|
+
return dict(response.json())
|
|
178
|
+
|
|
179
|
+
def validate_dsl(self, project_id: UUID | str) -> ValidationResult:
|
|
180
|
+
response = self._client.request("POST", f"/api/v1/projects/{project_id}/validate")
|
|
181
|
+
return ValidationResult.model_validate(response.json())
|
|
182
|
+
|
|
183
|
+
def diff_dsl(self, project_id: UUID | str, proposed_content: str) -> DSLDiff:
|
|
184
|
+
response = self._client.request(
|
|
185
|
+
"POST",
|
|
186
|
+
f"/api/v1/projects/{project_id}/dsl/diff",
|
|
187
|
+
json={"content": proposed_content},
|
|
188
|
+
)
|
|
189
|
+
return DSLDiff.model_validate(response.json())
|
|
190
|
+
|
|
191
|
+
# ── Codegen ───────────────────────────────────────────────
|
|
192
|
+
|
|
193
|
+
def generate(self, project_id: UUID | str) -> GenerationLog:
|
|
194
|
+
response = self._client.request("POST", f"/api/v1/projects/{project_id}/generate")
|
|
195
|
+
return GenerationLog.model_validate(response.json())
|
|
196
|
+
|
|
197
|
+
def list_generations(self, project_id: UUID | str) -> Sequence[GenerationLog]:
|
|
198
|
+
response = self._client.request("GET", f"/api/v1/projects/{project_id}/generations")
|
|
199
|
+
return [GenerationLog.model_validate(row) for row in response.json()]
|
|
200
|
+
|
|
201
|
+
# ── Eject (the anti-lock-in surface) ─────────────────────
|
|
202
|
+
|
|
203
|
+
def eject(self, project_id: UUID | str) -> EjectBundle:
|
|
204
|
+
"""Download the portable bundle for a project.
|
|
205
|
+
|
|
206
|
+
Returns an :class:`EjectBundle` carrying the zip bytes and the
|
|
207
|
+
filename suggested by the platform — call ``.save_to(path)``
|
|
208
|
+
to write it to disk.
|
|
209
|
+
"""
|
|
210
|
+
response = self._client.request(
|
|
211
|
+
"POST",
|
|
212
|
+
f"/api/v1/projects/{project_id}/eject",
|
|
213
|
+
)
|
|
214
|
+
return EjectBundle(
|
|
215
|
+
content=response.content,
|
|
216
|
+
filename=_extract_filename(response.headers.get("content-disposition", "")),
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
class ComponentsAPI(_Resource):
|
|
221
|
+
"""Read access to the platform's component marketplace.
|
|
222
|
+
|
|
223
|
+
Same shape the panel and the MCP server consume — list returns
|
|
224
|
+
summaries (light-weight, scannable in a table), get returns the
|
|
225
|
+
full manifest. Both endpoints are unauthenticated by design;
|
|
226
|
+
the marketplace is public information so anyone can browse
|
|
227
|
+
before installing.
|
|
228
|
+
"""
|
|
229
|
+
|
|
230
|
+
def list(self) -> Sequence[dict[str, Any]]:
|
|
231
|
+
response = self._client.request("GET", "/api/v1/components")
|
|
232
|
+
body = response.json()
|
|
233
|
+
if isinstance(body, dict):
|
|
234
|
+
return list(body.get("components", []))
|
|
235
|
+
return list(body) if isinstance(body, list) else []
|
|
236
|
+
|
|
237
|
+
def get(self, name: str) -> dict[str, Any]:
|
|
238
|
+
response = self._client.request("GET", f"/api/v1/components/{name}")
|
|
239
|
+
return dict(response.json())
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class AuditAPI(_Resource):
|
|
243
|
+
"""Read access to the platform's audit log."""
|
|
244
|
+
|
|
245
|
+
def events(
|
|
246
|
+
self,
|
|
247
|
+
*,
|
|
248
|
+
project_id: UUID | str | None = None,
|
|
249
|
+
event_type: str | None = None,
|
|
250
|
+
limit: int = 50,
|
|
251
|
+
) -> Sequence[dict[str, Any]]:
|
|
252
|
+
params: dict[str, Any] = {"limit": int(limit)}
|
|
253
|
+
if project_id is not None:
|
|
254
|
+
params["project_id"] = str(project_id)
|
|
255
|
+
if event_type is not None:
|
|
256
|
+
params["event_type"] = event_type
|
|
257
|
+
response = self._client.request("GET", "/api/v1/audit/events", params=params)
|
|
258
|
+
body = response.json()
|
|
259
|
+
return list(body) if isinstance(body, list) else list(body.get("events", []))
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
# ── Helpers ────────────────────────────────────────────────────
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def _extract_filename(content_disposition: str) -> str:
|
|
266
|
+
if not content_disposition:
|
|
267
|
+
return "qiloback-eject.zip"
|
|
268
|
+
match = _FILENAME_RE.search(content_disposition)
|
|
269
|
+
return match.group(1) if match else "qiloback-eject.zip"
|