cubepath-sdk 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.
- cubepath_sdk-0.1.0/.github/workflows/ci.yml +72 -0
- cubepath_sdk-0.1.0/.github/workflows/release.yml +61 -0
- cubepath_sdk-0.1.0/.gitignore +12 -0
- cubepath_sdk-0.1.0/LICENSE +21 -0
- cubepath_sdk-0.1.0/PKG-INFO +196 -0
- cubepath_sdk-0.1.0/README.md +172 -0
- cubepath_sdk-0.1.0/cubepath/__init__.py +15 -0
- cubepath_sdk-0.1.0/cubepath/client.py +203 -0
- cubepath_sdk-0.1.0/cubepath/exceptions.py +49 -0
- cubepath_sdk-0.1.0/cubepath/models/__init__.py +13 -0
- cubepath_sdk-0.1.0/cubepath/models/baremetal.py +236 -0
- cubepath_sdk-0.1.0/cubepath/models/cdn.py +303 -0
- cubepath_sdk-0.1.0/cubepath/models/ddos.py +22 -0
- cubepath_sdk-0.1.0/cubepath/models/dns.py +189 -0
- cubepath_sdk-0.1.0/cubepath/models/firewall.py +108 -0
- cubepath_sdk-0.1.0/cubepath/models/floating_ips.py +51 -0
- cubepath_sdk-0.1.0/cubepath/models/kubernetes.py +374 -0
- cubepath_sdk-0.1.0/cubepath/models/load_balancer.py +281 -0
- cubepath_sdk-0.1.0/cubepath/models/networks.py +58 -0
- cubepath_sdk-0.1.0/cubepath/models/pricing.py +113 -0
- cubepath_sdk-0.1.0/cubepath/models/projects.py +52 -0
- cubepath_sdk-0.1.0/cubepath/models/ssh_keys.py +36 -0
- cubepath_sdk-0.1.0/cubepath/models/vps.py +266 -0
- cubepath_sdk-0.1.0/cubepath/py.typed +0 -0
- cubepath_sdk-0.1.0/cubepath/services/__init__.py +0 -0
- cubepath_sdk-0.1.0/cubepath/services/baremetal.py +76 -0
- cubepath_sdk-0.1.0/cubepath/services/cdn.py +129 -0
- cubepath_sdk-0.1.0/cubepath/services/ddos.py +17 -0
- cubepath_sdk-0.1.0/cubepath/services/dns.py +92 -0
- cubepath_sdk-0.1.0/cubepath/services/firewall.py +42 -0
- cubepath_sdk-0.1.0/cubepath/services/floating_ips.py +42 -0
- cubepath_sdk-0.1.0/cubepath/services/kubernetes.py +119 -0
- cubepath_sdk-0.1.0/cubepath/services/load_balancer.py +111 -0
- cubepath_sdk-0.1.0/cubepath/services/networks.py +28 -0
- cubepath_sdk-0.1.0/cubepath/services/pricing.py +17 -0
- cubepath_sdk-0.1.0/cubepath/services/projects.py +33 -0
- cubepath_sdk-0.1.0/cubepath/services/ssh_keys.py +24 -0
- cubepath_sdk-0.1.0/cubepath/services/vps.py +109 -0
- cubepath_sdk-0.1.0/pyproject.toml +48 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: pip install ruff mypy httpx
|
|
21
|
+
|
|
22
|
+
- name: Ruff check
|
|
23
|
+
run: ruff check cubepath/
|
|
24
|
+
|
|
25
|
+
- name: Ruff format check
|
|
26
|
+
run: ruff format --check cubepath/
|
|
27
|
+
|
|
28
|
+
- name: Type check
|
|
29
|
+
run: mypy cubepath/ --ignore-missing-imports
|
|
30
|
+
|
|
31
|
+
test:
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
strategy:
|
|
34
|
+
matrix:
|
|
35
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v4
|
|
38
|
+
|
|
39
|
+
- uses: actions/setup-python@v5
|
|
40
|
+
with:
|
|
41
|
+
python-version: ${{ matrix.python-version }}
|
|
42
|
+
|
|
43
|
+
- name: Install package
|
|
44
|
+
run: pip install -e ".[test]"
|
|
45
|
+
|
|
46
|
+
- name: Run tests
|
|
47
|
+
run: python -m pytest tests/ -v
|
|
48
|
+
if: hashFiles('tests/') != ''
|
|
49
|
+
|
|
50
|
+
- name: Verify import
|
|
51
|
+
run: python -c "import cubepath; print(cubepath.__version__)"
|
|
52
|
+
|
|
53
|
+
build:
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
needs: [lint, test]
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@v4
|
|
58
|
+
|
|
59
|
+
- uses: actions/setup-python@v5
|
|
60
|
+
with:
|
|
61
|
+
python-version: "3.12"
|
|
62
|
+
|
|
63
|
+
- name: Install build tools
|
|
64
|
+
run: pip install build
|
|
65
|
+
|
|
66
|
+
- name: Build package
|
|
67
|
+
run: python -m build
|
|
68
|
+
|
|
69
|
+
- uses: actions/upload-artifact@v4
|
|
70
|
+
with:
|
|
71
|
+
name: dist
|
|
72
|
+
path: dist/
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.12"
|
|
21
|
+
|
|
22
|
+
- name: Install build tools
|
|
23
|
+
run: pip install build
|
|
24
|
+
|
|
25
|
+
- name: Build package
|
|
26
|
+
run: python -m build
|
|
27
|
+
|
|
28
|
+
- uses: actions/upload-artifact@v4
|
|
29
|
+
with:
|
|
30
|
+
name: dist
|
|
31
|
+
path: dist/
|
|
32
|
+
|
|
33
|
+
publish-pypi:
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
needs: build
|
|
36
|
+
environment: pypi
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/download-artifact@v4
|
|
39
|
+
with:
|
|
40
|
+
name: dist
|
|
41
|
+
path: dist/
|
|
42
|
+
|
|
43
|
+
- name: Publish to PyPI
|
|
44
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
45
|
+
|
|
46
|
+
github-release:
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
needs: build
|
|
49
|
+
steps:
|
|
50
|
+
- uses: actions/checkout@v4
|
|
51
|
+
|
|
52
|
+
- uses: actions/download-artifact@v4
|
|
53
|
+
with:
|
|
54
|
+
name: dist
|
|
55
|
+
path: dist/
|
|
56
|
+
|
|
57
|
+
- name: Create GitHub Release
|
|
58
|
+
uses: softprops/action-gh-release@v2
|
|
59
|
+
with:
|
|
60
|
+
generate_release_notes: true
|
|
61
|
+
files: dist/*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 CubePath Inc.
|
|
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,196 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cubepath-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CubePath Cloud API Python SDK
|
|
5
|
+
Project-URL: Homepage, https://github.com/CubePathInc/cubepath-python-sdk
|
|
6
|
+
Project-URL: Documentation, https://github.com/CubePathInc/cubepath-python-sdk
|
|
7
|
+
Project-URL: Repository, https://github.com/CubePathInc/cubepath-python-sdk
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: httpx<1,>=0.27
|
|
21
|
+
Provides-Extra: test
|
|
22
|
+
Requires-Dist: pytest>=8; extra == 'test'
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# CubePath Python SDK
|
|
26
|
+
|
|
27
|
+
Official Python SDK for the [CubePath Cloud API](https://api.cubepath.com).
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install cubepath
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
import cubepath
|
|
39
|
+
|
|
40
|
+
client = cubepath.CubePathClient(api_token="your-api-token")
|
|
41
|
+
|
|
42
|
+
# List projects
|
|
43
|
+
projects = client.projects.list()
|
|
44
|
+
for p in projects:
|
|
45
|
+
print(p.project.name)
|
|
46
|
+
|
|
47
|
+
# Create a VPS
|
|
48
|
+
from cubepath.models import CreateVPSRequest
|
|
49
|
+
|
|
50
|
+
req = CreateVPSRequest(
|
|
51
|
+
name="my-vps",
|
|
52
|
+
plan_name="gp.nano",
|
|
53
|
+
template_name="debian-12",
|
|
54
|
+
location_name="us-mia-1",
|
|
55
|
+
ssh_key_names=["my-key"],
|
|
56
|
+
)
|
|
57
|
+
task = client.vps.create(project_id="proj-123", req=req)
|
|
58
|
+
print(f"Task: {task.task_id}")
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Services
|
|
62
|
+
|
|
63
|
+
| Service | Access | Description |
|
|
64
|
+
|---------|--------|-------------|
|
|
65
|
+
| Projects | `client.projects` | Manage projects |
|
|
66
|
+
| SSH Keys | `client.ssh_keys` | Manage SSH keys |
|
|
67
|
+
| VPS | `client.vps` | Virtual private servers |
|
|
68
|
+
| VPS Backups | `client.vps.backups()` | VPS backup management |
|
|
69
|
+
| VPS ISOs | `client.vps.isos()` | ISO mount/unmount |
|
|
70
|
+
| Baremetal | `client.baremetal` | Bare metal servers |
|
|
71
|
+
| Networks | `client.networks` | Private networks |
|
|
72
|
+
| Floating IPs | `client.floating_ips` | Floating IP addresses |
|
|
73
|
+
| Firewall | `client.firewall` | Firewall groups & rules |
|
|
74
|
+
| DNS | `client.dns` | DNS zones & records |
|
|
75
|
+
| Load Balancer | `client.load_balancer` | Load balancers, listeners, targets |
|
|
76
|
+
| CDN | `client.cdn` | CDN zones, origins, rules, WAF |
|
|
77
|
+
| Kubernetes | `client.kubernetes` | K8s clusters, node pools, addons |
|
|
78
|
+
| Pricing | `client.pricing` | Pricing information |
|
|
79
|
+
| DDoS | `client.ddos` | DDoS attack reports |
|
|
80
|
+
|
|
81
|
+
## Configuration
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
client = cubepath.CubePathClient(
|
|
85
|
+
api_token="your-api-token",
|
|
86
|
+
base_url="https://api.cubepath.com", # default
|
|
87
|
+
timeout=30.0, # seconds
|
|
88
|
+
max_retries=3, # retry on 429/5xx
|
|
89
|
+
retry_wait_min=1.0, # min backoff seconds
|
|
90
|
+
retry_wait_max=30.0, # max backoff seconds
|
|
91
|
+
rate_limit_interval=0.1, # 10 req/s
|
|
92
|
+
)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Context Manager
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
with cubepath.CubePathClient(api_token="tok") as client:
|
|
99
|
+
zones = client.dns.list_zones()
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Error Handling
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from cubepath import APIError, is_not_found
|
|
106
|
+
|
|
107
|
+
try:
|
|
108
|
+
project = client.projects.get("nonexistent")
|
|
109
|
+
except APIError as e:
|
|
110
|
+
if e.is_not_found():
|
|
111
|
+
print("Project not found")
|
|
112
|
+
elif e.is_rate_limited():
|
|
113
|
+
print("Rate limited, try again later")
|
|
114
|
+
else:
|
|
115
|
+
print(f"API error: {e}")
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Requirements
|
|
119
|
+
|
|
120
|
+
- Python >= 3.10
|
|
121
|
+
- httpx >= 0.27
|
|
122
|
+
|
|
123
|
+
## Examples
|
|
124
|
+
|
|
125
|
+
### Deploy a Baremetal Server
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from cubepath.models import CreateBaremetalRequest
|
|
129
|
+
|
|
130
|
+
req = CreateBaremetalRequest(
|
|
131
|
+
model_name="c1.metal.plus",
|
|
132
|
+
location_name="us-mia-1",
|
|
133
|
+
hostname="db-server",
|
|
134
|
+
password="SecurePass123!",
|
|
135
|
+
os_name="debian-12",
|
|
136
|
+
ssh_key_names=["my-key"],
|
|
137
|
+
)
|
|
138
|
+
task = client.baremetal.deploy(project_id="proj-123", req=req)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Create a Load Balancer
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from cubepath.models import CreateLoadBalancerRequest, CreateListenerRequest
|
|
145
|
+
|
|
146
|
+
lb = client.load_balancer.create(CreateLoadBalancerRequest(
|
|
147
|
+
name="web-lb",
|
|
148
|
+
plan_name="lb.small",
|
|
149
|
+
location_name="us-mia-1",
|
|
150
|
+
))
|
|
151
|
+
|
|
152
|
+
client.load_balancer.create_listener(lb.uuid, CreateListenerRequest(
|
|
153
|
+
name="http",
|
|
154
|
+
protocol="http",
|
|
155
|
+
source_port=80,
|
|
156
|
+
target_port=8080,
|
|
157
|
+
algorithm="round_robin",
|
|
158
|
+
))
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Create a CDN Zone
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from cubepath.models import CreateCDNZoneRequest, CreateCDNOriginRequest
|
|
165
|
+
|
|
166
|
+
zone = client.cdn.create_zone(CreateCDNZoneRequest(
|
|
167
|
+
name="my-site",
|
|
168
|
+
plan_name="cdn.starter",
|
|
169
|
+
custom_domain="cdn.example.com",
|
|
170
|
+
))
|
|
171
|
+
|
|
172
|
+
client.cdn.create_origin(zone.uuid, CreateCDNOriginRequest(
|
|
173
|
+
name="primary-origin",
|
|
174
|
+
address="origin.example.com",
|
|
175
|
+
port=443,
|
|
176
|
+
protocol="https",
|
|
177
|
+
weight=100,
|
|
178
|
+
priority=1,
|
|
179
|
+
health_check_path="/health",
|
|
180
|
+
))
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### DNS Management
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
from cubepath.models import CreateDNSZoneRequest, CreateDNSRecordRequest
|
|
187
|
+
|
|
188
|
+
zone = client.dns.create_zone(CreateDNSZoneRequest(domain="example.com"))
|
|
189
|
+
|
|
190
|
+
client.dns.create_record(zone.uuid, CreateDNSRecordRequest(
|
|
191
|
+
name="@",
|
|
192
|
+
record_type="A",
|
|
193
|
+
content="203.0.113.10",
|
|
194
|
+
ttl=3600,
|
|
195
|
+
))
|
|
196
|
+
```
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# CubePath Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python SDK for the [CubePath Cloud API](https://api.cubepath.com).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install cubepath
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
import cubepath
|
|
15
|
+
|
|
16
|
+
client = cubepath.CubePathClient(api_token="your-api-token")
|
|
17
|
+
|
|
18
|
+
# List projects
|
|
19
|
+
projects = client.projects.list()
|
|
20
|
+
for p in projects:
|
|
21
|
+
print(p.project.name)
|
|
22
|
+
|
|
23
|
+
# Create a VPS
|
|
24
|
+
from cubepath.models import CreateVPSRequest
|
|
25
|
+
|
|
26
|
+
req = CreateVPSRequest(
|
|
27
|
+
name="my-vps",
|
|
28
|
+
plan_name="gp.nano",
|
|
29
|
+
template_name="debian-12",
|
|
30
|
+
location_name="us-mia-1",
|
|
31
|
+
ssh_key_names=["my-key"],
|
|
32
|
+
)
|
|
33
|
+
task = client.vps.create(project_id="proj-123", req=req)
|
|
34
|
+
print(f"Task: {task.task_id}")
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Services
|
|
38
|
+
|
|
39
|
+
| Service | Access | Description |
|
|
40
|
+
|---------|--------|-------------|
|
|
41
|
+
| Projects | `client.projects` | Manage projects |
|
|
42
|
+
| SSH Keys | `client.ssh_keys` | Manage SSH keys |
|
|
43
|
+
| VPS | `client.vps` | Virtual private servers |
|
|
44
|
+
| VPS Backups | `client.vps.backups()` | VPS backup management |
|
|
45
|
+
| VPS ISOs | `client.vps.isos()` | ISO mount/unmount |
|
|
46
|
+
| Baremetal | `client.baremetal` | Bare metal servers |
|
|
47
|
+
| Networks | `client.networks` | Private networks |
|
|
48
|
+
| Floating IPs | `client.floating_ips` | Floating IP addresses |
|
|
49
|
+
| Firewall | `client.firewall` | Firewall groups & rules |
|
|
50
|
+
| DNS | `client.dns` | DNS zones & records |
|
|
51
|
+
| Load Balancer | `client.load_balancer` | Load balancers, listeners, targets |
|
|
52
|
+
| CDN | `client.cdn` | CDN zones, origins, rules, WAF |
|
|
53
|
+
| Kubernetes | `client.kubernetes` | K8s clusters, node pools, addons |
|
|
54
|
+
| Pricing | `client.pricing` | Pricing information |
|
|
55
|
+
| DDoS | `client.ddos` | DDoS attack reports |
|
|
56
|
+
|
|
57
|
+
## Configuration
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
client = cubepath.CubePathClient(
|
|
61
|
+
api_token="your-api-token",
|
|
62
|
+
base_url="https://api.cubepath.com", # default
|
|
63
|
+
timeout=30.0, # seconds
|
|
64
|
+
max_retries=3, # retry on 429/5xx
|
|
65
|
+
retry_wait_min=1.0, # min backoff seconds
|
|
66
|
+
retry_wait_max=30.0, # max backoff seconds
|
|
67
|
+
rate_limit_interval=0.1, # 10 req/s
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Context Manager
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
with cubepath.CubePathClient(api_token="tok") as client:
|
|
75
|
+
zones = client.dns.list_zones()
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Error Handling
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from cubepath import APIError, is_not_found
|
|
82
|
+
|
|
83
|
+
try:
|
|
84
|
+
project = client.projects.get("nonexistent")
|
|
85
|
+
except APIError as e:
|
|
86
|
+
if e.is_not_found():
|
|
87
|
+
print("Project not found")
|
|
88
|
+
elif e.is_rate_limited():
|
|
89
|
+
print("Rate limited, try again later")
|
|
90
|
+
else:
|
|
91
|
+
print(f"API error: {e}")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Requirements
|
|
95
|
+
|
|
96
|
+
- Python >= 3.10
|
|
97
|
+
- httpx >= 0.27
|
|
98
|
+
|
|
99
|
+
## Examples
|
|
100
|
+
|
|
101
|
+
### Deploy a Baremetal Server
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from cubepath.models import CreateBaremetalRequest
|
|
105
|
+
|
|
106
|
+
req = CreateBaremetalRequest(
|
|
107
|
+
model_name="c1.metal.plus",
|
|
108
|
+
location_name="us-mia-1",
|
|
109
|
+
hostname="db-server",
|
|
110
|
+
password="SecurePass123!",
|
|
111
|
+
os_name="debian-12",
|
|
112
|
+
ssh_key_names=["my-key"],
|
|
113
|
+
)
|
|
114
|
+
task = client.baremetal.deploy(project_id="proj-123", req=req)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Create a Load Balancer
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from cubepath.models import CreateLoadBalancerRequest, CreateListenerRequest
|
|
121
|
+
|
|
122
|
+
lb = client.load_balancer.create(CreateLoadBalancerRequest(
|
|
123
|
+
name="web-lb",
|
|
124
|
+
plan_name="lb.small",
|
|
125
|
+
location_name="us-mia-1",
|
|
126
|
+
))
|
|
127
|
+
|
|
128
|
+
client.load_balancer.create_listener(lb.uuid, CreateListenerRequest(
|
|
129
|
+
name="http",
|
|
130
|
+
protocol="http",
|
|
131
|
+
source_port=80,
|
|
132
|
+
target_port=8080,
|
|
133
|
+
algorithm="round_robin",
|
|
134
|
+
))
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Create a CDN Zone
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
from cubepath.models import CreateCDNZoneRequest, CreateCDNOriginRequest
|
|
141
|
+
|
|
142
|
+
zone = client.cdn.create_zone(CreateCDNZoneRequest(
|
|
143
|
+
name="my-site",
|
|
144
|
+
plan_name="cdn.starter",
|
|
145
|
+
custom_domain="cdn.example.com",
|
|
146
|
+
))
|
|
147
|
+
|
|
148
|
+
client.cdn.create_origin(zone.uuid, CreateCDNOriginRequest(
|
|
149
|
+
name="primary-origin",
|
|
150
|
+
address="origin.example.com",
|
|
151
|
+
port=443,
|
|
152
|
+
protocol="https",
|
|
153
|
+
weight=100,
|
|
154
|
+
priority=1,
|
|
155
|
+
health_check_path="/health",
|
|
156
|
+
))
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### DNS Management
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
from cubepath.models import CreateDNSZoneRequest, CreateDNSRecordRequest
|
|
163
|
+
|
|
164
|
+
zone = client.dns.create_zone(CreateDNSZoneRequest(domain="example.com"))
|
|
165
|
+
|
|
166
|
+
client.dns.create_record(zone.uuid, CreateDNSRecordRequest(
|
|
167
|
+
name="@",
|
|
168
|
+
record_type="A",
|
|
169
|
+
content="203.0.113.10",
|
|
170
|
+
ttl=3600,
|
|
171
|
+
))
|
|
172
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""CubePath Cloud API Python SDK."""
|
|
2
|
+
|
|
3
|
+
from cubepath.client import CubePathClient
|
|
4
|
+
from cubepath.exceptions import APIError, is_bad_request, is_conflict, is_not_found, is_rate_limited
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"CubePathClient",
|
|
8
|
+
"APIError",
|
|
9
|
+
"is_not_found",
|
|
10
|
+
"is_conflict",
|
|
11
|
+
"is_rate_limited",
|
|
12
|
+
"is_bad_request",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
__version__ = "0.1.0"
|