vertracloud-api 0.1.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.
- vertracloud_api-0.1.0/.github/workflows/ci.yml +24 -0
- vertracloud_api-0.1.0/.github/workflows/release.yml +37 -0
- vertracloud_api-0.1.0/.gitignore +14 -0
- vertracloud_api-0.1.0/.release-please-manifest.json +1 -0
- vertracloud_api-0.1.0/CHANGELOG.md +12 -0
- vertracloud_api-0.1.0/LICENSE +21 -0
- vertracloud_api-0.1.0/PKG-INFO +184 -0
- vertracloud_api-0.1.0/README.md +165 -0
- vertracloud_api-0.1.0/pyproject.toml +47 -0
- vertracloud_api-0.1.0/release-please-config.json +50 -0
- vertracloud_api-0.1.0/src/vertracloud/__init__.py +29 -0
- vertracloud_api-0.1.0/src/vertracloud/client.py +228 -0
- vertracloud_api-0.1.0/src/vertracloud/errors.py +93 -0
- vertracloud_api-0.1.0/src/vertracloud/py.typed +0 -0
- vertracloud_api-0.1.0/src/vertracloud/resources/__init__.py +0 -0
- vertracloud_api-0.1.0/src/vertracloud/resources/account.py +112 -0
- vertracloud_api-0.1.0/src/vertracloud/resources/apps.py +418 -0
- vertracloud_api-0.1.0/src/vertracloud/resources/billing.py +51 -0
- vertracloud_api-0.1.0/src/vertracloud/resources/databases.py +127 -0
- vertracloud_api-0.1.0/src/vertracloud/resources/snapshots.py +66 -0
- vertracloud_api-0.1.0/src/vertracloud/resources/workspaces.py +274 -0
- vertracloud_api-0.1.0/src/vertracloud/sse.py +65 -0
- vertracloud_api-0.1.0/src/vertracloud/transport.py +81 -0
- vertracloud_api-0.1.0/src/vertracloud/types.py +742 -0
- vertracloud_api-0.1.0/tests/__init__.py +0 -0
- vertracloud_api-0.1.0/tests/fake_transport.py +80 -0
- vertracloud_api-0.1.0/tests/routes_matrix.py +133 -0
- vertracloud_api-0.1.0/tests/test_client.py +159 -0
- vertracloud_api-0.1.0/tests/test_contract.py +310 -0
- vertracloud_api-0.1.0/tests/test_multipart_and_binary.py +109 -0
- vertracloud_api-0.1.0/tests/test_routes_matrix.py +175 -0
- vertracloud_api-0.1.0/tests/test_sse.py +90 -0
- vertracloud_api-0.1.0/uv.lock +517 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v4
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python-version }}
|
|
20
|
+
- run: pip install -e .[dev]
|
|
21
|
+
- run: ruff check .
|
|
22
|
+
- run: ruff format --check .
|
|
23
|
+
- run: mypy src
|
|
24
|
+
- run: python -m pytest -q
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
pull-requests: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
release-please:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
outputs:
|
|
15
|
+
release_created: ${{ steps.rp.outputs.release_created }}
|
|
16
|
+
steps:
|
|
17
|
+
- id: rp
|
|
18
|
+
uses: googleapis/release-please-action@v4
|
|
19
|
+
with:
|
|
20
|
+
config-file: release-please-config.json
|
|
21
|
+
manifest-file: .release-please-manifest.json
|
|
22
|
+
|
|
23
|
+
publish:
|
|
24
|
+
needs: release-please
|
|
25
|
+
if: ${{ needs.release-please.outputs.release_created == 'true' }}
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
environment: pypi
|
|
28
|
+
permissions:
|
|
29
|
+
id-token: write # trusted publishing no PyPI, sem token
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
- uses: actions/setup-python@v5
|
|
33
|
+
with:
|
|
34
|
+
python-version: "3.12"
|
|
35
|
+
- run: pip install build
|
|
36
|
+
- run: python -m build
|
|
37
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{".":"0.1.0"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (2026-09-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add apps, databases, snapshots, account, workspaces and billing resources ([9c67589](https://github.com/vertracloud/sdk-api-py/commit/9c6758937e20b4fadb4f413cadba2884868b6e14))
|
|
9
|
+
* add HTTP transport and error types ([0ff9ac5](https://github.com/vertracloud/sdk-api-py/commit/0ff9ac5ef13235ab10d83d5e869235ec1f73bd36))
|
|
10
|
+
* add SSE realtime log streaming ([753cd7f](https://github.com/vertracloud/sdk-api-py/commit/753cd7f0433539eb5f291a7f5b582ac1dc0c043a))
|
|
11
|
+
|
|
12
|
+
## Changelog
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Vertra Cloud
|
|
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,184 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: vertracloud-api
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the public API of Vertra Cloud, a Brazilian application hosting platform (PaaS).
|
|
5
|
+
Project-URL: Homepage, https://vertracloud.app
|
|
6
|
+
Project-URL: Documentation, https://docs.vertracloud.app/sdks
|
|
7
|
+
Project-URL: Repository, https://github.com/vertracloud/sdk-api-py
|
|
8
|
+
Project-URL: Issues, https://github.com/vertracloud/sdk-api-py/issues
|
|
9
|
+
Author: Vertra Cloud
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: build>=1.2; extra == 'dev'
|
|
15
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
16
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
17
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# Vertra Cloud Python SDK
|
|
21
|
+
|
|
22
|
+
[](https://pypi.org/project/vertracloud-api/)
|
|
23
|
+
[](LICENSE)
|
|
24
|
+
|
|
25
|
+
Official Python SDK for the [Vertra Cloud](https://vertracloud.app) public API: apps, databases, snapshots, account, workspaces and billing — one typed method per route.
|
|
26
|
+
|
|
27
|
+
- Python 3.10+, fully typed (`py.typed`), with `TypedDict` payloads.
|
|
28
|
+
- Zero dependencies outside the standard library.
|
|
29
|
+
- No hidden retries, caching or state: errors come back as they happened.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install vertracloud-api
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Getting an API key
|
|
38
|
+
|
|
39
|
+
Sign in to the [dashboard](https://vertracloud.app), open **Settings → API keys** and create a key with only the scopes your code needs (e.g. `apps:read`, `apps:write`). Keep it out of your source code — the examples read it from `VERTRA_API_KEY`.
|
|
40
|
+
|
|
41
|
+
## Quick start
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
import os
|
|
45
|
+
|
|
46
|
+
from vertracloud import VertraClient
|
|
47
|
+
|
|
48
|
+
client = VertraClient(api_key=os.environ["VERTRA_API_KEY"])
|
|
49
|
+
|
|
50
|
+
me = client.account.get()
|
|
51
|
+
print(f"Hi {me['name']}! Plan: {me['plan']['name']}")
|
|
52
|
+
|
|
53
|
+
for app in me["applications"]:
|
|
54
|
+
print(app["id"], app["name"], app["status"])
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Documentation
|
|
58
|
+
|
|
59
|
+
- Guide: [docs.vertracloud.app/sdks](https://docs.vertracloud.app/sdks)
|
|
60
|
+
- API reference and scopes: [docs.vertracloud.app/api-reference](https://docs.vertracloud.app/api-reference/introduction)
|
|
61
|
+
|
|
62
|
+
Every method has a docstring with its HTTP route and the API key scope it needs.
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
### Client options
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
client = VertraClient(
|
|
70
|
+
api_key=os.environ["VERTRA_API_KEY"],
|
|
71
|
+
timeout=10, # seconds, default 30 per call
|
|
72
|
+
# base_url, user_agent and a custom transport are also accepted
|
|
73
|
+
)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Per-call options
|
|
77
|
+
|
|
78
|
+
Methods on apps and databases take a keyword-only `workspace_id`; downloads, uploads and streams also take `timeout`:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
# Act on a resource that belongs to a workspace
|
|
82
|
+
app = client.apps.get(app_id, workspace_id=workspace_id)
|
|
83
|
+
|
|
84
|
+
# Give one slow call more time
|
|
85
|
+
zip_bytes = client.apps.download(app_id, timeout=300)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Nested resources are attributes: `client.apps.deploys`, `client.apps.envs`, `client.workspaces.members`, `client.billing.orders`, …
|
|
89
|
+
|
|
90
|
+
### Apps
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
app = client.apps.get(app_id)
|
|
94
|
+
|
|
95
|
+
client.apps.restart(app_id) # normal restart
|
|
96
|
+
client.apps.restart(app_id, {"reinstall_dependencies": True})
|
|
97
|
+
|
|
98
|
+
metrics = client.apps.metrics(app_id, range="24h")
|
|
99
|
+
logs = client.apps.logs(app_id)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Uploading and downloading
|
|
103
|
+
|
|
104
|
+
Uploads take `bytes`; downloads return `bytes`.
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
with open("app.zip", "rb") as f:
|
|
108
|
+
app = client.apps.create({"name": "my-app", "memory": 512}, file=f.read())
|
|
109
|
+
|
|
110
|
+
with open("backup.zip", "wb") as f:
|
|
111
|
+
f.write(client.apps.download(app_id))
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`client.snapshots.download` works the same way.
|
|
115
|
+
|
|
116
|
+
### Realtime logs (SSE)
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
stream = client.apps.realtime(app_id)
|
|
120
|
+
try:
|
|
121
|
+
for event in stream:
|
|
122
|
+
print(event.event, event.data)
|
|
123
|
+
finally:
|
|
124
|
+
stream.close()
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Stop the stream with `break` or `stream.close()`. Pass `since=` to resume. There is no automatic reconnection.
|
|
128
|
+
|
|
129
|
+
### Errors
|
|
130
|
+
|
|
131
|
+
Every non-2xx response raises a `VertraAPIError` carrying the HTTP `status`, the API `code` (e.g. `APP_NOT_FOUND`) and `details`; `str(err)` includes the message. The API key is never part of the error, even when it is printed:
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
from vertracloud import NotFoundError, RateLimitError, VertraAPIError
|
|
135
|
+
|
|
136
|
+
try:
|
|
137
|
+
client.apps.get(app_id)
|
|
138
|
+
except NotFoundError:
|
|
139
|
+
... # 404
|
|
140
|
+
except RateLimitError as err:
|
|
141
|
+
print("retry after", err.retry_after, "s")
|
|
142
|
+
except VertraAPIError as err:
|
|
143
|
+
print(err.status, err.code, err)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Other subclasses: `AuthenticationError` (401), `ScopeDeniedError` (403 — including a missing key scope) and `ValidationError` (400/422). The error codes are listed in the [API reference](https://docs.vertracloud.app/api-reference/introduction).
|
|
147
|
+
|
|
148
|
+
### Testing your code
|
|
149
|
+
|
|
150
|
+
Pass your own `vertracloud.Transport` to the client to answer requests without touching the network:
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
client = VertraClient(api_key="test", transport=my_fake_transport)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Coverage
|
|
157
|
+
|
|
158
|
+
| Domain | Resource | Routes |
|
|
159
|
+
|---|---|---|
|
|
160
|
+
| Apps | `client.apps` (+ `.deploys`, `.network`, `.envs`, `.files`) | 36 |
|
|
161
|
+
| Databases | `client.databases` (+ `.credentials`) | 13 |
|
|
162
|
+
| Snapshots | `client.snapshots` | 5 |
|
|
163
|
+
| Account | `client.account` (+ `.sessions`, `.folders`, `.favorites`) | 10 |
|
|
164
|
+
| Workspaces | `client.workspaces` (+ `.members`, `.roles`, `.invites`, `.action_requests`, `.apps`, `.databases`, `.folders`, `.favorites`) | 30 |
|
|
165
|
+
| Billing | `client.billing` (+ `.orders`) | 5 |
|
|
166
|
+
|
|
167
|
+
Dashboard-only features (activity log, notifications, API key management, the database **Data** tab, plan downgrade, creating workspace invites, transferring workspace ownership and approving action requests) are not part of the public API. See [what an API key cannot do](https://docs.vertracloud.app/sdks).
|
|
168
|
+
|
|
169
|
+
## Versioning
|
|
170
|
+
|
|
171
|
+
The SDK follows semantic versioning. Until `1.0.0`, minor releases may contain breaking changes; they are always called out in the [changelog](CHANGELOG.md).
|
|
172
|
+
|
|
173
|
+
## Contributing
|
|
174
|
+
|
|
175
|
+
Issues and pull requests are welcome. Before sending a change, run:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
pip install -e ".[dev]"
|
|
179
|
+
ruff check . && ruff format --check . && mypy src && python -m pytest -q
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Vertra Cloud Python SDK
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/vertracloud-api/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
Official Python SDK for the [Vertra Cloud](https://vertracloud.app) public API: apps, databases, snapshots, account, workspaces and billing — one typed method per route.
|
|
7
|
+
|
|
8
|
+
- Python 3.10+, fully typed (`py.typed`), with `TypedDict` payloads.
|
|
9
|
+
- Zero dependencies outside the standard library.
|
|
10
|
+
- No hidden retries, caching or state: errors come back as they happened.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install vertracloud-api
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Getting an API key
|
|
19
|
+
|
|
20
|
+
Sign in to the [dashboard](https://vertracloud.app), open **Settings → API keys** and create a key with only the scopes your code needs (e.g. `apps:read`, `apps:write`). Keep it out of your source code — the examples read it from `VERTRA_API_KEY`.
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
import os
|
|
26
|
+
|
|
27
|
+
from vertracloud import VertraClient
|
|
28
|
+
|
|
29
|
+
client = VertraClient(api_key=os.environ["VERTRA_API_KEY"])
|
|
30
|
+
|
|
31
|
+
me = client.account.get()
|
|
32
|
+
print(f"Hi {me['name']}! Plan: {me['plan']['name']}")
|
|
33
|
+
|
|
34
|
+
for app in me["applications"]:
|
|
35
|
+
print(app["id"], app["name"], app["status"])
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Documentation
|
|
39
|
+
|
|
40
|
+
- Guide: [docs.vertracloud.app/sdks](https://docs.vertracloud.app/sdks)
|
|
41
|
+
- API reference and scopes: [docs.vertracloud.app/api-reference](https://docs.vertracloud.app/api-reference/introduction)
|
|
42
|
+
|
|
43
|
+
Every method has a docstring with its HTTP route and the API key scope it needs.
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
### Client options
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
client = VertraClient(
|
|
51
|
+
api_key=os.environ["VERTRA_API_KEY"],
|
|
52
|
+
timeout=10, # seconds, default 30 per call
|
|
53
|
+
# base_url, user_agent and a custom transport are also accepted
|
|
54
|
+
)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Per-call options
|
|
58
|
+
|
|
59
|
+
Methods on apps and databases take a keyword-only `workspace_id`; downloads, uploads and streams also take `timeout`:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
# Act on a resource that belongs to a workspace
|
|
63
|
+
app = client.apps.get(app_id, workspace_id=workspace_id)
|
|
64
|
+
|
|
65
|
+
# Give one slow call more time
|
|
66
|
+
zip_bytes = client.apps.download(app_id, timeout=300)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Nested resources are attributes: `client.apps.deploys`, `client.apps.envs`, `client.workspaces.members`, `client.billing.orders`, …
|
|
70
|
+
|
|
71
|
+
### Apps
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
app = client.apps.get(app_id)
|
|
75
|
+
|
|
76
|
+
client.apps.restart(app_id) # normal restart
|
|
77
|
+
client.apps.restart(app_id, {"reinstall_dependencies": True})
|
|
78
|
+
|
|
79
|
+
metrics = client.apps.metrics(app_id, range="24h")
|
|
80
|
+
logs = client.apps.logs(app_id)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Uploading and downloading
|
|
84
|
+
|
|
85
|
+
Uploads take `bytes`; downloads return `bytes`.
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
with open("app.zip", "rb") as f:
|
|
89
|
+
app = client.apps.create({"name": "my-app", "memory": 512}, file=f.read())
|
|
90
|
+
|
|
91
|
+
with open("backup.zip", "wb") as f:
|
|
92
|
+
f.write(client.apps.download(app_id))
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`client.snapshots.download` works the same way.
|
|
96
|
+
|
|
97
|
+
### Realtime logs (SSE)
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
stream = client.apps.realtime(app_id)
|
|
101
|
+
try:
|
|
102
|
+
for event in stream:
|
|
103
|
+
print(event.event, event.data)
|
|
104
|
+
finally:
|
|
105
|
+
stream.close()
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Stop the stream with `break` or `stream.close()`. Pass `since=` to resume. There is no automatic reconnection.
|
|
109
|
+
|
|
110
|
+
### Errors
|
|
111
|
+
|
|
112
|
+
Every non-2xx response raises a `VertraAPIError` carrying the HTTP `status`, the API `code` (e.g. `APP_NOT_FOUND`) and `details`; `str(err)` includes the message. The API key is never part of the error, even when it is printed:
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from vertracloud import NotFoundError, RateLimitError, VertraAPIError
|
|
116
|
+
|
|
117
|
+
try:
|
|
118
|
+
client.apps.get(app_id)
|
|
119
|
+
except NotFoundError:
|
|
120
|
+
... # 404
|
|
121
|
+
except RateLimitError as err:
|
|
122
|
+
print("retry after", err.retry_after, "s")
|
|
123
|
+
except VertraAPIError as err:
|
|
124
|
+
print(err.status, err.code, err)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Other subclasses: `AuthenticationError` (401), `ScopeDeniedError` (403 — including a missing key scope) and `ValidationError` (400/422). The error codes are listed in the [API reference](https://docs.vertracloud.app/api-reference/introduction).
|
|
128
|
+
|
|
129
|
+
### Testing your code
|
|
130
|
+
|
|
131
|
+
Pass your own `vertracloud.Transport` to the client to answer requests without touching the network:
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
client = VertraClient(api_key="test", transport=my_fake_transport)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Coverage
|
|
138
|
+
|
|
139
|
+
| Domain | Resource | Routes |
|
|
140
|
+
|---|---|---|
|
|
141
|
+
| Apps | `client.apps` (+ `.deploys`, `.network`, `.envs`, `.files`) | 36 |
|
|
142
|
+
| Databases | `client.databases` (+ `.credentials`) | 13 |
|
|
143
|
+
| Snapshots | `client.snapshots` | 5 |
|
|
144
|
+
| Account | `client.account` (+ `.sessions`, `.folders`, `.favorites`) | 10 |
|
|
145
|
+
| Workspaces | `client.workspaces` (+ `.members`, `.roles`, `.invites`, `.action_requests`, `.apps`, `.databases`, `.folders`, `.favorites`) | 30 |
|
|
146
|
+
| Billing | `client.billing` (+ `.orders`) | 5 |
|
|
147
|
+
|
|
148
|
+
Dashboard-only features (activity log, notifications, API key management, the database **Data** tab, plan downgrade, creating workspace invites, transferring workspace ownership and approving action requests) are not part of the public API. See [what an API key cannot do](https://docs.vertracloud.app/sdks).
|
|
149
|
+
|
|
150
|
+
## Versioning
|
|
151
|
+
|
|
152
|
+
The SDK follows semantic versioning. Until `1.0.0`, minor releases may contain breaking changes; they are always called out in the [changelog](CHANGELOG.md).
|
|
153
|
+
|
|
154
|
+
## Contributing
|
|
155
|
+
|
|
156
|
+
Issues and pull requests are welcome. Before sending a change, run:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pip install -e ".[dev]"
|
|
160
|
+
ruff check . && ruff format --check . && mypy src && python -m pytest -q
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vertracloud-api"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python SDK for the public API of Vertra Cloud, a Brazilian application hosting platform (PaaS)."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [{ name = "Vertra Cloud" }]
|
|
13
|
+
dependencies = []
|
|
14
|
+
|
|
15
|
+
[project.urls]
|
|
16
|
+
Homepage = "https://vertracloud.app"
|
|
17
|
+
Documentation = "https://docs.vertracloud.app/sdks"
|
|
18
|
+
Repository = "https://github.com/vertracloud/sdk-api-py"
|
|
19
|
+
Issues = "https://github.com/vertracloud/sdk-api-py/issues"
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
dev = ["pytest>=8", "ruff>=0.6", "mypy>=1.11", "build>=1.2"]
|
|
23
|
+
|
|
24
|
+
[tool.hatch.build.targets.wheel]
|
|
25
|
+
packages = ["src/vertracloud"]
|
|
26
|
+
|
|
27
|
+
[tool.ruff]
|
|
28
|
+
line-length = 120
|
|
29
|
+
target-version = "py310"
|
|
30
|
+
|
|
31
|
+
[tool.ruff.lint]
|
|
32
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
33
|
+
|
|
34
|
+
[tool.mypy]
|
|
35
|
+
python_version = "3.10"
|
|
36
|
+
strict = true
|
|
37
|
+
packages = ["vertracloud"]
|
|
38
|
+
mypy_path = "src"
|
|
39
|
+
|
|
40
|
+
# `resources/*` returns the `Any` from `request_json`/`request_multipart` already annotated
|
|
41
|
+
# with the contract's TypedDict/type — there's no real value in requiring `cast()` on every call.
|
|
42
|
+
[[tool.mypy.overrides]]
|
|
43
|
+
module = "vertracloud.resources.*"
|
|
44
|
+
warn_return_any = false
|
|
45
|
+
|
|
46
|
+
[tool.pytest.ini_options]
|
|
47
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
|
|
3
|
+
"packages": {
|
|
4
|
+
".": {
|
|
5
|
+
"release-type": "python",
|
|
6
|
+
"package-name": "vertracloud-api",
|
|
7
|
+
"bump-minor-pre-major": true,
|
|
8
|
+
"extra-files": [
|
|
9
|
+
"src/vertracloud/client.py"
|
|
10
|
+
],
|
|
11
|
+
"changelog-sections": [
|
|
12
|
+
{
|
|
13
|
+
"type": "feat",
|
|
14
|
+
"section": "Features"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"type": "fix",
|
|
18
|
+
"section": "Bug Fixes"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"type": "perf",
|
|
22
|
+
"section": "Performance"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "docs",
|
|
26
|
+
"section": "Documentation",
|
|
27
|
+
"hidden": true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"type": "chore",
|
|
31
|
+
"hidden": true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"type": "refactor",
|
|
35
|
+
"hidden": true
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"type": "test",
|
|
39
|
+
"hidden": true
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"type": "ci",
|
|
43
|
+
"hidden": true
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"release-as": "0.1.0"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"include-component-in-tag": false
|
|
50
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Typed Python client for the Vertra Cloud public API (`import vertracloud`)."""
|
|
2
|
+
|
|
3
|
+
from .client import VertraClient, __version__
|
|
4
|
+
from .errors import (
|
|
5
|
+
AuthenticationError,
|
|
6
|
+
NotFoundError,
|
|
7
|
+
RateLimitError,
|
|
8
|
+
ScopeDeniedError,
|
|
9
|
+
ValidationError,
|
|
10
|
+
VertraAPIError,
|
|
11
|
+
)
|
|
12
|
+
from .sse import SseEvent, SseStream
|
|
13
|
+
from .transport import Response, Transport, UrllibTransport
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"VertraClient",
|
|
17
|
+
"__version__",
|
|
18
|
+
"VertraAPIError",
|
|
19
|
+
"AuthenticationError",
|
|
20
|
+
"ScopeDeniedError",
|
|
21
|
+
"NotFoundError",
|
|
22
|
+
"ValidationError",
|
|
23
|
+
"RateLimitError",
|
|
24
|
+
"SseEvent",
|
|
25
|
+
"SseStream",
|
|
26
|
+
"Transport",
|
|
27
|
+
"UrllibTransport",
|
|
28
|
+
"Response",
|
|
29
|
+
]
|