pangolin-client 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.
- pangolin_client-0.1.0/.gitignore +41 -0
- pangolin_client-0.1.0/LICENSE +21 -0
- pangolin_client-0.1.0/PKG-INFO +253 -0
- pangolin_client-0.1.0/README.md +223 -0
- pangolin_client-0.1.0/pyproject.toml +76 -0
- pangolin_client-0.1.0/src/pangolin_client/__init__.py +49 -0
- pangolin_client-0.1.0/src/pangolin_client/cli.py +891 -0
- pangolin_client-0.1.0/src/pangolin_client/client.py +711 -0
- pangolin_client-0.1.0/src/pangolin_client/exceptions.py +25 -0
- pangolin_client-0.1.0/src/pangolin_client/models.py +540 -0
- pangolin_client-0.1.0/src/pangolin_client/py.typed +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.pyo
|
|
5
|
+
|
|
6
|
+
# Virtual envs
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
env/
|
|
10
|
+
|
|
11
|
+
# Distribution / packaging
|
|
12
|
+
dist/
|
|
13
|
+
build/
|
|
14
|
+
*.egg-info/
|
|
15
|
+
|
|
16
|
+
# pytest
|
|
17
|
+
.pytest_cache/
|
|
18
|
+
|
|
19
|
+
# mypy
|
|
20
|
+
.mypy_cache/
|
|
21
|
+
|
|
22
|
+
# ruff
|
|
23
|
+
.ruff_cache/
|
|
24
|
+
|
|
25
|
+
# uv
|
|
26
|
+
.uv/
|
|
27
|
+
|
|
28
|
+
# IDE
|
|
29
|
+
.vscode/
|
|
30
|
+
.idea/
|
|
31
|
+
|
|
32
|
+
# Node (prettier hook)
|
|
33
|
+
node_modules/
|
|
34
|
+
|
|
35
|
+
# Secrets
|
|
36
|
+
*.enc.json
|
|
37
|
+
secrets.plain.json
|
|
38
|
+
|
|
39
|
+
# Local CI caches
|
|
40
|
+
.uv-cache/
|
|
41
|
+
.prek-cache/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Simon Maillard
|
|
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,253 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pangolin-client
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python client and CLI for the Pangolin Integration API
|
|
5
|
+
Project-URL: Homepage, https://github.com/maisim/pangolin-client
|
|
6
|
+
Project-URL: Repository, https://github.com/maisim/pangolin-client
|
|
7
|
+
Project-URL: Issues, https://github.com/maisim/pangolin-client/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/maisim/pangolin-client/releases
|
|
9
|
+
Author-email: Simon Maillard <simon@ogesta.fr>
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: api-client,cli,infrastructure,newt,pangolin
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: System Administrators
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Topic :: System :: Systems Administration
|
|
25
|
+
Requires-Python: <4.0,>=3.11
|
|
26
|
+
Requires-Dist: httpx>=0.27
|
|
27
|
+
Requires-Dist: pydantic>=2.0
|
|
28
|
+
Requires-Dist: typer>=0.12
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# pangolin-client
|
|
32
|
+
|
|
33
|
+
> **⚠️ ALPHA RELEASE**: This project is currently in the **Alpha** stage. The API, operation arguments, and features are subject to change at any time without backward compatibility. Do not use in production environments.
|
|
34
|
+
|
|
35
|
+
> **Packaging status**: this repository is the source of truth and is public. Install the latest
|
|
36
|
+
> release from PyPI; while the project is alpha, pin the version you use.
|
|
37
|
+
|
|
38
|
+
Python client library and CLI for the [Pangolin Integration API](https://docs.pangolin.net/integrate/overview) v1.
|
|
39
|
+
|
|
40
|
+
[](https://github.com/maisim/pangolin-client/actions/workflows/python-publish.yml)
|
|
41
|
+
[](https://pypi.org/project/pangolin-client/)
|
|
42
|
+
[](https://pypi.org/project/pangolin-client/)
|
|
43
|
+
[](LICENSE)
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- Full synchronous HTTP client (`PangolinClient`) backed by [httpx](https://www.python-httpx.org/)
|
|
48
|
+
- Pydantic v2 models for all request/response payloads
|
|
49
|
+
- Idempotent helpers (`ensure_site`, `ensure_resource`) safe to call in CI/CD pipelines
|
|
50
|
+
- Typer CLI (`pangolin`) for shell scripts and automation
|
|
51
|
+
- Zero dependency on pyinfra — usable standalone in any Python project
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install pangolin-client
|
|
57
|
+
# or with uv
|
|
58
|
+
uv add pangolin-client
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Requires Python 3.11 or newer, below 4.0.
|
|
62
|
+
|
|
63
|
+
## Configuration
|
|
64
|
+
|
|
65
|
+
All commands and the client accept configuration via environment variables or explicit arguments:
|
|
66
|
+
|
|
67
|
+
| Variable | Description |
|
|
68
|
+
| ------------------ | ---------------------------------------------------- |
|
|
69
|
+
| `PANGOLIN_API_URL` | Base URL, e.g. `https://api.pangolin.example.com/v1` |
|
|
70
|
+
| `PANGOLIN_API_KEY` | Bearer token / API key |
|
|
71
|
+
| `PANGOLIN_ORG_ID` | Default organisation ID |
|
|
72
|
+
|
|
73
|
+
## Python API
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from pangolin_client import PangolinClient, CreateSiteRequest, CreateResourceRequest, CreateTargetRequest
|
|
77
|
+
|
|
78
|
+
with PangolinClient(base_url="https://api.pangolin.example.com/v1", api_key="<your-api-key>") as client:
|
|
79
|
+
# Create a Newt site — credentials are auto-generated
|
|
80
|
+
site, created = client.ensure_site("my-org", name="acme-dev", nice_id="acme-dev")
|
|
81
|
+
print(f"Site {site.site_id}, newt_id={site.newt_id}, created={created}")
|
|
82
|
+
|
|
83
|
+
# Create a public HTTP resource
|
|
84
|
+
resource, created = client.ensure_resource(
|
|
85
|
+
"my-org",
|
|
86
|
+
CreateResourceRequest(name="Acme Odoo", domain_id="dom-123", subdomain="acme-dev"),
|
|
87
|
+
nice_id="acme-odoo",
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# Add a backend target pointing to the Odoo container inside the Newt tunnel
|
|
91
|
+
target = client.create_target(
|
|
92
|
+
resource.resource_id,
|
|
93
|
+
CreateTargetRequest(site_id=site.site_id, ip="odoo", port=8069),
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Or apply a full blueprint at once
|
|
97
|
+
with open("build/pangolin/blueprint.yaml") as f:
|
|
98
|
+
client.apply_blueprint_yaml("my-org", f.read())
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Error handling
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from pangolin_client import PangolinAPIError, PangolinNotFoundError, PangolinAuthError
|
|
105
|
+
|
|
106
|
+
try:
|
|
107
|
+
site = client.get_site_by_nice_id("my-org", "acme-dev")
|
|
108
|
+
except PangolinAuthError:
|
|
109
|
+
print("Invalid API key")
|
|
110
|
+
except PangolinNotFoundError:
|
|
111
|
+
print("Site does not exist")
|
|
112
|
+
except PangolinAPIError as e:
|
|
113
|
+
print(f"API error {e.status_code}: {e.message}")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## CLI
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
Usage: pangolin [OPTIONS] COMMAND [ARGS]...
|
|
120
|
+
|
|
121
|
+
Commands:
|
|
122
|
+
site Manage sites (Newt tunnels)
|
|
123
|
+
resource Manage public resources
|
|
124
|
+
target Manage resource targets
|
|
125
|
+
blueprint Manage blueprints
|
|
126
|
+
domain Manage domains
|
|
127
|
+
site-resource Manage ZTNA site resources
|
|
128
|
+
role Manage access roles
|
|
129
|
+
client Manage machine clients (OLM)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Sites
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# List all sites
|
|
136
|
+
pangolin site list
|
|
137
|
+
|
|
138
|
+
# Create a site (auto-generates Newt credentials)
|
|
139
|
+
pangolin site create --name acme-dev
|
|
140
|
+
|
|
141
|
+
# Get or create by niceId (idempotent — safe to call repeatedly)
|
|
142
|
+
pangolin site ensure --name acme-dev --nice-id acme-dev
|
|
143
|
+
|
|
144
|
+
# Get a site by niceId
|
|
145
|
+
pangolin site get --nice-id acme-dev
|
|
146
|
+
|
|
147
|
+
# Delete a site
|
|
148
|
+
pangolin site delete 42 --yes
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Resources
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
pangolin resource list
|
|
155
|
+
pangolin resource create --name "Acme Odoo" --domain dom-123 --subdomain acme-dev
|
|
156
|
+
pangolin resource get --nice-id acme-odoo
|
|
157
|
+
pangolin resource delete 7 --yes
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Targets
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Add a backend target to a resource
|
|
164
|
+
pangolin target create --resource 7 --site 42 --ip odoo --port 8069
|
|
165
|
+
|
|
166
|
+
# List targets for a resource
|
|
167
|
+
pangolin target list 7
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Blueprints
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Apply a YAML or JSON blueprint
|
|
174
|
+
pangolin blueprint apply --file build/pangolin/blueprint.yaml
|
|
175
|
+
pangolin blueprint list
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Domains
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
pangolin domain list
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Site resources
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
pangolin site-resource list
|
|
188
|
+
|
|
189
|
+
# Expose an SSH endpoint through the site
|
|
190
|
+
pangolin site-resource ensure --name "Odoo SSH" --nice-id acme-odoo-ssh --site 42 \
|
|
191
|
+
--destination odoo --destination-port 22 --alias ssh.acme.foundry.internal
|
|
192
|
+
|
|
193
|
+
pangolin site-resource get --alias ssh.acme.foundry.internal
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Roles
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
pangolin role ensure --name acme-dev --allow-ssh --ssh-sudo-mode commands \
|
|
200
|
+
--ssh-sudo-command "systemctl restart odoo"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Machine clients
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
pangolin client ensure --name gitlab-acme-dev
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## GitLab CI/CD
|
|
210
|
+
|
|
211
|
+
```yaml
|
|
212
|
+
variables:
|
|
213
|
+
PANGOLIN_API_URL: https://api.pangolin.example.com/v1
|
|
214
|
+
PANGOLIN_ORG_ID: my-org
|
|
215
|
+
|
|
216
|
+
configure-pangolin:
|
|
217
|
+
stage: deploy
|
|
218
|
+
image: python:3.12-slim
|
|
219
|
+
script:
|
|
220
|
+
- pip install pangolin-client
|
|
221
|
+
- pangolin site ensure --name "$CI_ENVIRONMENT_SLUG" --nice-id "$INSTANCE_NAME"
|
|
222
|
+
- pangolin blueprint apply -f build/pangolin/blueprint.yaml
|
|
223
|
+
variables:
|
|
224
|
+
PANGOLIN_API_KEY: $PANGOLIN_API_KEY # secret CI variable
|
|
225
|
+
|
|
226
|
+
teardown-pangolin:
|
|
227
|
+
stage: cleanup
|
|
228
|
+
when: manual
|
|
229
|
+
script:
|
|
230
|
+
- pip install pangolin-client
|
|
231
|
+
- SITE_ID=$(pangolin site get --nice-id "$INSTANCE_NAME" | python3 -c "import sys,json; print(json.load(sys.stdin)['site_id'])")
|
|
232
|
+
- pangolin site delete "$SITE_ID" --yes
|
|
233
|
+
variables:
|
|
234
|
+
PANGOLIN_API_KEY: $PANGOLIN_API_KEY
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Development
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
uv sync --group dev
|
|
241
|
+
uv run pytest tests/ -v
|
|
242
|
+
uv run prek run --all-files
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Note on response schemas
|
|
246
|
+
|
|
247
|
+
The Pangolin OpenAPI spec (`/v1/openapi.json`) documents request body schemas thoroughly but declares
|
|
248
|
+
all response bodies as `"properties": {}`. Response models in this library are therefore inferred from
|
|
249
|
+
the API's domain logic and may need minor field-name adjustments if the API returns unexpected keys.
|
|
250
|
+
|
|
251
|
+
## License
|
|
252
|
+
|
|
253
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# pangolin-client
|
|
2
|
+
|
|
3
|
+
> **⚠️ ALPHA RELEASE**: This project is currently in the **Alpha** stage. The API, operation arguments, and features are subject to change at any time without backward compatibility. Do not use in production environments.
|
|
4
|
+
|
|
5
|
+
> **Packaging status**: this repository is the source of truth and is public. Install the latest
|
|
6
|
+
> release from PyPI; while the project is alpha, pin the version you use.
|
|
7
|
+
|
|
8
|
+
Python client library and CLI for the [Pangolin Integration API](https://docs.pangolin.net/integrate/overview) v1.
|
|
9
|
+
|
|
10
|
+
[](https://github.com/maisim/pangolin-client/actions/workflows/python-publish.yml)
|
|
11
|
+
[](https://pypi.org/project/pangolin-client/)
|
|
12
|
+
[](https://pypi.org/project/pangolin-client/)
|
|
13
|
+
[](LICENSE)
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- Full synchronous HTTP client (`PangolinClient`) backed by [httpx](https://www.python-httpx.org/)
|
|
18
|
+
- Pydantic v2 models for all request/response payloads
|
|
19
|
+
- Idempotent helpers (`ensure_site`, `ensure_resource`) safe to call in CI/CD pipelines
|
|
20
|
+
- Typer CLI (`pangolin`) for shell scripts and automation
|
|
21
|
+
- Zero dependency on pyinfra — usable standalone in any Python project
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install pangolin-client
|
|
27
|
+
# or with uv
|
|
28
|
+
uv add pangolin-client
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Requires Python 3.11 or newer, below 4.0.
|
|
32
|
+
|
|
33
|
+
## Configuration
|
|
34
|
+
|
|
35
|
+
All commands and the client accept configuration via environment variables or explicit arguments:
|
|
36
|
+
|
|
37
|
+
| Variable | Description |
|
|
38
|
+
| ------------------ | ---------------------------------------------------- |
|
|
39
|
+
| `PANGOLIN_API_URL` | Base URL, e.g. `https://api.pangolin.example.com/v1` |
|
|
40
|
+
| `PANGOLIN_API_KEY` | Bearer token / API key |
|
|
41
|
+
| `PANGOLIN_ORG_ID` | Default organisation ID |
|
|
42
|
+
|
|
43
|
+
## Python API
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from pangolin_client import PangolinClient, CreateSiteRequest, CreateResourceRequest, CreateTargetRequest
|
|
47
|
+
|
|
48
|
+
with PangolinClient(base_url="https://api.pangolin.example.com/v1", api_key="<your-api-key>") as client:
|
|
49
|
+
# Create a Newt site — credentials are auto-generated
|
|
50
|
+
site, created = client.ensure_site("my-org", name="acme-dev", nice_id="acme-dev")
|
|
51
|
+
print(f"Site {site.site_id}, newt_id={site.newt_id}, created={created}")
|
|
52
|
+
|
|
53
|
+
# Create a public HTTP resource
|
|
54
|
+
resource, created = client.ensure_resource(
|
|
55
|
+
"my-org",
|
|
56
|
+
CreateResourceRequest(name="Acme Odoo", domain_id="dom-123", subdomain="acme-dev"),
|
|
57
|
+
nice_id="acme-odoo",
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# Add a backend target pointing to the Odoo container inside the Newt tunnel
|
|
61
|
+
target = client.create_target(
|
|
62
|
+
resource.resource_id,
|
|
63
|
+
CreateTargetRequest(site_id=site.site_id, ip="odoo", port=8069),
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
# Or apply a full blueprint at once
|
|
67
|
+
with open("build/pangolin/blueprint.yaml") as f:
|
|
68
|
+
client.apply_blueprint_yaml("my-org", f.read())
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Error handling
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from pangolin_client import PangolinAPIError, PangolinNotFoundError, PangolinAuthError
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
site = client.get_site_by_nice_id("my-org", "acme-dev")
|
|
78
|
+
except PangolinAuthError:
|
|
79
|
+
print("Invalid API key")
|
|
80
|
+
except PangolinNotFoundError:
|
|
81
|
+
print("Site does not exist")
|
|
82
|
+
except PangolinAPIError as e:
|
|
83
|
+
print(f"API error {e.status_code}: {e.message}")
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## CLI
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
Usage: pangolin [OPTIONS] COMMAND [ARGS]...
|
|
90
|
+
|
|
91
|
+
Commands:
|
|
92
|
+
site Manage sites (Newt tunnels)
|
|
93
|
+
resource Manage public resources
|
|
94
|
+
target Manage resource targets
|
|
95
|
+
blueprint Manage blueprints
|
|
96
|
+
domain Manage domains
|
|
97
|
+
site-resource Manage ZTNA site resources
|
|
98
|
+
role Manage access roles
|
|
99
|
+
client Manage machine clients (OLM)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Sites
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# List all sites
|
|
106
|
+
pangolin site list
|
|
107
|
+
|
|
108
|
+
# Create a site (auto-generates Newt credentials)
|
|
109
|
+
pangolin site create --name acme-dev
|
|
110
|
+
|
|
111
|
+
# Get or create by niceId (idempotent — safe to call repeatedly)
|
|
112
|
+
pangolin site ensure --name acme-dev --nice-id acme-dev
|
|
113
|
+
|
|
114
|
+
# Get a site by niceId
|
|
115
|
+
pangolin site get --nice-id acme-dev
|
|
116
|
+
|
|
117
|
+
# Delete a site
|
|
118
|
+
pangolin site delete 42 --yes
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Resources
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
pangolin resource list
|
|
125
|
+
pangolin resource create --name "Acme Odoo" --domain dom-123 --subdomain acme-dev
|
|
126
|
+
pangolin resource get --nice-id acme-odoo
|
|
127
|
+
pangolin resource delete 7 --yes
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Targets
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Add a backend target to a resource
|
|
134
|
+
pangolin target create --resource 7 --site 42 --ip odoo --port 8069
|
|
135
|
+
|
|
136
|
+
# List targets for a resource
|
|
137
|
+
pangolin target list 7
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Blueprints
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Apply a YAML or JSON blueprint
|
|
144
|
+
pangolin blueprint apply --file build/pangolin/blueprint.yaml
|
|
145
|
+
pangolin blueprint list
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Domains
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
pangolin domain list
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Site resources
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
pangolin site-resource list
|
|
158
|
+
|
|
159
|
+
# Expose an SSH endpoint through the site
|
|
160
|
+
pangolin site-resource ensure --name "Odoo SSH" --nice-id acme-odoo-ssh --site 42 \
|
|
161
|
+
--destination odoo --destination-port 22 --alias ssh.acme.foundry.internal
|
|
162
|
+
|
|
163
|
+
pangolin site-resource get --alias ssh.acme.foundry.internal
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Roles
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
pangolin role ensure --name acme-dev --allow-ssh --ssh-sudo-mode commands \
|
|
170
|
+
--ssh-sudo-command "systemctl restart odoo"
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Machine clients
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
pangolin client ensure --name gitlab-acme-dev
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## GitLab CI/CD
|
|
180
|
+
|
|
181
|
+
```yaml
|
|
182
|
+
variables:
|
|
183
|
+
PANGOLIN_API_URL: https://api.pangolin.example.com/v1
|
|
184
|
+
PANGOLIN_ORG_ID: my-org
|
|
185
|
+
|
|
186
|
+
configure-pangolin:
|
|
187
|
+
stage: deploy
|
|
188
|
+
image: python:3.12-slim
|
|
189
|
+
script:
|
|
190
|
+
- pip install pangolin-client
|
|
191
|
+
- pangolin site ensure --name "$CI_ENVIRONMENT_SLUG" --nice-id "$INSTANCE_NAME"
|
|
192
|
+
- pangolin blueprint apply -f build/pangolin/blueprint.yaml
|
|
193
|
+
variables:
|
|
194
|
+
PANGOLIN_API_KEY: $PANGOLIN_API_KEY # secret CI variable
|
|
195
|
+
|
|
196
|
+
teardown-pangolin:
|
|
197
|
+
stage: cleanup
|
|
198
|
+
when: manual
|
|
199
|
+
script:
|
|
200
|
+
- pip install pangolin-client
|
|
201
|
+
- SITE_ID=$(pangolin site get --nice-id "$INSTANCE_NAME" | python3 -c "import sys,json; print(json.load(sys.stdin)['site_id'])")
|
|
202
|
+
- pangolin site delete "$SITE_ID" --yes
|
|
203
|
+
variables:
|
|
204
|
+
PANGOLIN_API_KEY: $PANGOLIN_API_KEY
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Development
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
uv sync --group dev
|
|
211
|
+
uv run pytest tests/ -v
|
|
212
|
+
uv run prek run --all-files
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Note on response schemas
|
|
216
|
+
|
|
217
|
+
The Pangolin OpenAPI spec (`/v1/openapi.json`) documents request body schemas thoroughly but declares
|
|
218
|
+
all response bodies as `"properties": {}`. Response models in this library are therefore inferred from
|
|
219
|
+
the API's domain logic and may need minor field-name adjustments if the API returns unexpected keys.
|
|
220
|
+
|
|
221
|
+
## License
|
|
222
|
+
|
|
223
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pangolin-client"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Python client and CLI for the Pangolin Integration API"
|
|
5
|
+
authors = [
|
|
6
|
+
{ name = "Simon Maillard", email = "simon@ogesta.fr" }
|
|
7
|
+
]
|
|
8
|
+
license = { text = "MIT" }
|
|
9
|
+
keywords = ["pangolin", "api-client", "cli", "newt", "infrastructure"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 3 - Alpha",
|
|
12
|
+
"Environment :: Console",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"Intended Audience :: System Administrators",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Operating System :: POSIX :: Linux",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Programming Language :: Python :: 3.14",
|
|
22
|
+
"Topic :: System :: Systems Administration",
|
|
23
|
+
]
|
|
24
|
+
readme = "README.md"
|
|
25
|
+
requires-python = ">=3.11,<4.0"
|
|
26
|
+
dependencies = [
|
|
27
|
+
"httpx>=0.27",
|
|
28
|
+
"pydantic>=2.0",
|
|
29
|
+
"typer>=0.12",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/maisim/pangolin-client"
|
|
34
|
+
Repository = "https://github.com/maisim/pangolin-client"
|
|
35
|
+
Issues = "https://github.com/maisim/pangolin-client/issues"
|
|
36
|
+
Changelog = "https://github.com/maisim/pangolin-client/releases"
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
pangolin = "pangolin_client.cli:app"
|
|
40
|
+
|
|
41
|
+
[build-system]
|
|
42
|
+
requires = ["hatchling"]
|
|
43
|
+
build-backend = "hatchling.build"
|
|
44
|
+
|
|
45
|
+
[tool.hatch.build.targets.wheel]
|
|
46
|
+
packages = ["src/pangolin_client"]
|
|
47
|
+
|
|
48
|
+
[tool.hatch.build.targets.sdist]
|
|
49
|
+
include = ["src/pangolin_client", "README.md", "LICENSE", "pyproject.toml"]
|
|
50
|
+
|
|
51
|
+
[dependency-groups]
|
|
52
|
+
dev = [
|
|
53
|
+
"detect-secrets>=1.4.0",
|
|
54
|
+
# 1.7.8 rather than 1.7.5: 1.7.5 pulls untokenize, whose sdist does not build on Python 3.14.
|
|
55
|
+
"docformatter==1.7.8",
|
|
56
|
+
"mypy>=2.3.1",
|
|
57
|
+
"prek>=0.5.4",
|
|
58
|
+
"pytest>=9.1.1",
|
|
59
|
+
"respx>=0.21",
|
|
60
|
+
"ruff>=0.16.9",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[tool.pytest.ini_options]
|
|
64
|
+
testpaths = ["tests"]
|
|
65
|
+
|
|
66
|
+
[tool.ruff]
|
|
67
|
+
line-length = 120
|
|
68
|
+
target-version = "py311"
|
|
69
|
+
|
|
70
|
+
[tool.ruff.lint]
|
|
71
|
+
select = ["E", "F", "W", "I", "N"]
|
|
72
|
+
|
|
73
|
+
[tool.mypy]
|
|
74
|
+
python_version = "3.11"
|
|
75
|
+
# httpx ships no type information: without this, importing it is an error rather than a silence.
|
|
76
|
+
ignore_missing_imports = true
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pangolin_client.client import PangolinClient
|
|
4
|
+
from pangolin_client.exceptions import PangolinAPIError, PangolinAuthError, PangolinNotFoundError
|
|
5
|
+
from pangolin_client.models import (
|
|
6
|
+
Blueprint,
|
|
7
|
+
Client,
|
|
8
|
+
ClientDefaults,
|
|
9
|
+
CreateClientRequest,
|
|
10
|
+
CreateDomainRequest,
|
|
11
|
+
CreateResourceRequest,
|
|
12
|
+
CreateRoleRequest,
|
|
13
|
+
CreateSiteRequest,
|
|
14
|
+
CreateSiteResourceRequest,
|
|
15
|
+
CreateTargetRequest,
|
|
16
|
+
Domain,
|
|
17
|
+
Resource,
|
|
18
|
+
Role,
|
|
19
|
+
Site,
|
|
20
|
+
SiteDefaults,
|
|
21
|
+
SiteResource,
|
|
22
|
+
Target,
|
|
23
|
+
UpdateSiteResourceRequest,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"PangolinClient",
|
|
28
|
+
"PangolinAPIError",
|
|
29
|
+
"PangolinAuthError",
|
|
30
|
+
"PangolinNotFoundError",
|
|
31
|
+
"Blueprint",
|
|
32
|
+
"Client",
|
|
33
|
+
"ClientDefaults",
|
|
34
|
+
"CreateClientRequest",
|
|
35
|
+
"CreateDomainRequest",
|
|
36
|
+
"CreateResourceRequest",
|
|
37
|
+
"CreateRoleRequest",
|
|
38
|
+
"CreateSiteRequest",
|
|
39
|
+
"CreateSiteResourceRequest",
|
|
40
|
+
"CreateTargetRequest",
|
|
41
|
+
"Domain",
|
|
42
|
+
"Resource",
|
|
43
|
+
"Role",
|
|
44
|
+
"Site",
|
|
45
|
+
"SiteDefaults",
|
|
46
|
+
"SiteResource",
|
|
47
|
+
"Target",
|
|
48
|
+
"UpdateSiteResourceRequest",
|
|
49
|
+
]
|