kailash-client 0.9.3__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.
- kailash_client-0.9.3/LICENSE +21 -0
- kailash_client-0.9.3/PKG-INFO +122 -0
- kailash_client-0.9.3/README.md +99 -0
- kailash_client-0.9.3/kailash_client/__init__.py +34 -0
- kailash_client-0.9.3/kailash_client/client.py +69 -0
- kailash_client-0.9.3/kailash_client/errors.py +47 -0
- kailash_client-0.9.3/kailash_client/generated/__init__.py +193 -0
- kailash_client-0.9.3/kailash_client/generated/api/__init__.py +11 -0
- kailash_client-0.9.3/kailash_client/generated/api/audit_controller_api.py +1177 -0
- kailash_client-0.9.3/kailash_client/generated/api/auth_controller_api.py +342 -0
- kailash_client-0.9.3/kailash_client/generated/api/category_controller_api.py +652 -0
- kailash_client-0.9.3/kailash_client/generated/api/cdp_discovery_controller_api.py +366 -0
- kailash_client-0.9.3/kailash_client/generated/api/instance_controller_api.py +183 -0
- kailash_client-0.9.3/kailash_client/generated/api/probe_controller_api.py +546 -0
- kailash_client-0.9.3/kailash_client/generated/api/slot_controller_api.py +724 -0
- kailash_client-0.9.3/kailash_client/generated/api/slot_list_controller_api.py +482 -0
- kailash_client-0.9.3/kailash_client/generated/api/snapshot_controller_api.py +331 -0
- kailash_client-0.9.3/kailash_client/generated/api/tenant_controller_api.py +539 -0
- kailash_client-0.9.3/kailash_client/generated/api/user_controller_api.py +1192 -0
- kailash_client-0.9.3/kailash_client/generated/api_client.py +598 -0
- kailash_client-0.9.3/kailash_client/generated/api_response.py +16 -0
- kailash_client-0.9.3/kailash_client/generated/configuration.py +448 -0
- kailash_client-0.9.3/kailash_client/generated/exceptions.py +152 -0
- kailash_client-0.9.3/kailash_client/generated/models/__init__.py +149 -0
- kailash_client-0.9.3/kailash_client/generated/models/acquire_request.py +95 -0
- kailash_client-0.9.3/kailash_client/generated/models/audit_event_page.py +75 -0
- kailash_client-0.9.3/kailash_client/generated/models/audit_event_view.py +96 -0
- kailash_client-0.9.3/kailash_client/generated/models/audit_stats_bucket.py +74 -0
- kailash_client-0.9.3/kailash_client/generated/models/audit_stats_group.py +83 -0
- kailash_client-0.9.3/kailash_client/generated/models/audit_stats_result.py +88 -0
- kailash_client-0.9.3/kailash_client/generated/models/binding_decl.py +68 -0
- kailash_client-0.9.3/kailash_client/generated/models/category_detail.py +100 -0
- kailash_client-0.9.3/kailash_client/generated/models/category_info.py +77 -0
- kailash_client-0.9.3/kailash_client/generated/models/change_own_password_request.py +64 -0
- kailash_client-0.9.3/kailash_client/generated/models/change_password_request.py +62 -0
- kailash_client-0.9.3/kailash_client/generated/models/chrome_connection.py +69 -0
- kailash_client-0.9.3/kailash_client/generated/models/chrome_slot_spec.py +80 -0
- kailash_client-0.9.3/kailash_client/generated/models/create_tenant_request.py +68 -0
- kailash_client-0.9.3/kailash_client/generated/models/create_user_request.py +72 -0
- kailash_client-0.9.3/kailash_client/generated/models/demo_connection.py +67 -0
- kailash_client-0.9.3/kailash_client/generated/models/demo_seed_spec.py +65 -0
- kailash_client-0.9.3/kailash_client/generated/models/demo_slot_spec.py +86 -0
- kailash_client-0.9.3/kailash_client/generated/models/entry.py +65 -0
- kailash_client-0.9.3/kailash_client/generated/models/es_connection.py +67 -0
- kailash_client-0.9.3/kailash_client/generated/models/es_seed_spec.py +65 -0
- kailash_client-0.9.3/kailash_client/generated/models/es_slot_spec.py +102 -0
- kailash_client-0.9.3/kailash_client/generated/models/es_template_declaration.py +63 -0
- kailash_client-0.9.3/kailash_client/generated/models/exchange_decl.py +68 -0
- kailash_client-0.9.3/kailash_client/generated/models/hatchet_connection.py +69 -0
- kailash_client-0.9.3/kailash_client/generated/models/hatchet_slot_spec.py +78 -0
- kailash_client-0.9.3/kailash_client/generated/models/health_probe.py +78 -0
- kailash_client-0.9.3/kailash_client/generated/models/instance_descriptor.py +81 -0
- kailash_client-0.9.3/kailash_client/generated/models/json_node.py +117 -0
- kailash_client-0.9.3/kailash_client/generated/models/login_request.py +64 -0
- kailash_client-0.9.3/kailash_client/generated/models/login_result.py +64 -0
- kailash_client-0.9.3/kailash_client/generated/models/logs_probe.py +69 -0
- kailash_client-0.9.3/kailash_client/generated/models/minio_connection.py +67 -0
- kailash_client-0.9.3/kailash_client/generated/models/minio_seed_spec.py +73 -0
- kailash_client-0.9.3/kailash_client/generated/models/minio_slot_spec.py +86 -0
- kailash_client-0.9.3/kailash_client/generated/models/mysql_connection.py +69 -0
- kailash_client-0.9.3/kailash_client/generated/models/mysql_seed_spec.py +65 -0
- kailash_client-0.9.3/kailash_client/generated/models/mysql_slot_spec.py +88 -0
- kailash_client-0.9.3/kailash_client/generated/models/page_metadata.py +67 -0
- kailash_client-0.9.3/kailash_client/generated/models/paged_model_slot_view.py +75 -0
- kailash_client-0.9.3/kailash_client/generated/models/paged_model_snapshot.py +75 -0
- kailash_client-0.9.3/kailash_client/generated/models/pg_connection.py +73 -0
- kailash_client-0.9.3/kailash_client/generated/models/pg_seed_spec.py +65 -0
- kailash_client-0.9.3/kailash_client/generated/models/pg_slot_spec.py +88 -0
- kailash_client-0.9.3/kailash_client/generated/models/provision_request.py +65 -0
- kailash_client-0.9.3/kailash_client/generated/models/queue_decl.py +70 -0
- kailash_client-0.9.3/kailash_client/generated/models/rabbitmq_connection.py +71 -0
- kailash_client-0.9.3/kailash_client/generated/models/rabbitmq_seed_spec.py +93 -0
- kailash_client-0.9.3/kailash_client/generated/models/rabbitmq_slot_spec.py +86 -0
- kailash_client-0.9.3/kailash_client/generated/models/redis_connection.py +71 -0
- kailash_client-0.9.3/kailash_client/generated/models/redis_ns_connection.py +67 -0
- kailash_client-0.9.3/kailash_client/generated/models/redis_ns_seed_spec.py +73 -0
- kailash_client-0.9.3/kailash_client/generated/models/redis_ns_slot_spec.py +84 -0
- kailash_client-0.9.3/kailash_client/generated/models/redis_pinned_connection.py +69 -0
- kailash_client-0.9.3/kailash_client/generated/models/redis_pinned_seed_spec.py +73 -0
- kailash_client-0.9.3/kailash_client/generated/models/redis_pinned_slot_spec.py +84 -0
- kailash_client-0.9.3/kailash_client/generated/models/redis_seed_spec.py +73 -0
- kailash_client-0.9.3/kailash_client/generated/models/redis_slot_spec.py +84 -0
- kailash_client-0.9.3/kailash_client/generated/models/resource_connection.py +293 -0
- kailash_client-0.9.3/kailash_client/generated/models/seed_entry.py +65 -0
- kailash_client-0.9.3/kailash_client/generated/models/seed_spec.py +257 -0
- kailash_client-0.9.3/kailash_client/generated/models/slot.py +106 -0
- kailash_client-0.9.3/kailash_client/generated/models/slot_credentials.py +65 -0
- kailash_client-0.9.3/kailash_client/generated/models/slot_spec.py +293 -0
- kailash_client-0.9.3/kailash_client/generated/models/slot_view.py +110 -0
- kailash_client-0.9.3/kailash_client/generated/models/snapshot.py +68 -0
- kailash_client-0.9.3/kailash_client/generated/models/snapshot_create_request.py +61 -0
- kailash_client-0.9.3/kailash_client/generated/models/spec_field_doc.py +67 -0
- kailash_client-0.9.3/kailash_client/generated/models/stats_probe.py +67 -0
- kailash_client-0.9.3/kailash_client/generated/models/tenant_response.py +72 -0
- kailash_client-0.9.3/kailash_client/generated/models/update_own_profile_request.py +63 -0
- kailash_client-0.9.3/kailash_client/generated/models/update_tenant_request.py +65 -0
- kailash_client-0.9.3/kailash_client/generated/models/user_response.py +74 -0
- kailash_client-0.9.3/kailash_client/generated/rest.py +221 -0
- kailash_client-0.9.3/kailash_client.egg-info/PKG-INFO +122 -0
- kailash_client-0.9.3/kailash_client.egg-info/SOURCES.txt +103 -0
- kailash_client-0.9.3/kailash_client.egg-info/dependency_links.txt +1 -0
- kailash_client-0.9.3/kailash_client.egg-info/requires.txt +4 -0
- kailash_client-0.9.3/kailash_client.egg-info/top_level.txt +4 -0
- kailash_client-0.9.3/pyproject.toml +33 -0
- kailash_client-0.9.3/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yiting Qiang
|
|
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,122 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kailash-client
|
|
3
|
+
Version: 0.9.3
|
|
4
|
+
Summary: Kailash test-resource service Python client (full codegen: apis+models+runtime, plus wrapper facade)
|
|
5
|
+
Author: Yiting Qiang
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Topic :: Software Development :: Testing
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: pydantic>=2.7
|
|
19
|
+
Requires-Dist: python-dateutil>=2.8
|
|
20
|
+
Requires-Dist: typing-extensions>=4.8
|
|
21
|
+
Requires-Dist: urllib3>=2.0
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# kailash-client (Python)
|
|
25
|
+
|
|
26
|
+
Python client for [kailash](https://github.com/qiangyt/kailash) — a test-resource
|
|
27
|
+
control plane that hands out isolated, short-lived infrastructure resources
|
|
28
|
+
(PostgreSQL schemas, Elasticsearch indices, Redis databases, MinIO buckets,
|
|
29
|
+
Hatchet tenants, MySQL databases, Chrome contexts) as *slots* acquired from a
|
|
30
|
+
pool of registered instances.
|
|
31
|
+
|
|
32
|
+
The package ships two layers:
|
|
33
|
+
|
|
34
|
+
- a fully generated API/client layer (`kailash_client.generated`, pydantic v2
|
|
35
|
+
models plus one typed API class per kailash endpoint), and
|
|
36
|
+
- a thin hand-written facade, `KailashClient`, which is the recommended entry
|
|
37
|
+
point.
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install kailash-client
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Requires Python 3.10+.
|
|
46
|
+
|
|
47
|
+
## Quickstart
|
|
48
|
+
|
|
49
|
+
Point the client at a running kailash server (`http://localhost:18080` is the
|
|
50
|
+
default) and acquire a slot from the zero-dependency in-memory `demo` category
|
|
51
|
+
(note: `demo` is disabled by default on a stock deployment — a ROOT user can
|
|
52
|
+
enable it via `POST /api/categories/demo/enable`):
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from kailash_client import AcquireRequest, KailashClient, Slot, SlotSpec
|
|
56
|
+
from kailash_client.generated.models import DemoSlotSpec
|
|
57
|
+
|
|
58
|
+
client = KailashClient("http://localhost:18080", auth=("user", "password"))
|
|
59
|
+
|
|
60
|
+
slot: Slot = client.slots.acquire(
|
|
61
|
+
AcquireRequest(
|
|
62
|
+
spec=SlotSpec(
|
|
63
|
+
DemoSlotSpec(
|
|
64
|
+
caller_app="my-app",
|
|
65
|
+
caller_run="run-1",
|
|
66
|
+
timeout_seconds=600,
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
)
|
|
71
|
+
print(slot.slot_id, slot.endpoint)
|
|
72
|
+
|
|
73
|
+
# Release as soon as you are done — the TTL is only a safety net.
|
|
74
|
+
client.slots.release(slot.slot_id)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`SlotSpec(...)` wraps one concrete spec (polymorphic oneOf); every category has
|
|
78
|
+
its own spec model, e.g. `PgSlotSpec`, `RedisSlotSpec`, `EsSlotSpec`.
|
|
79
|
+
|
|
80
|
+
## Authentication
|
|
81
|
+
|
|
82
|
+
kailash requires authentication on all `/api/*` endpoints (Basic or Bearer):
|
|
83
|
+
|
|
84
|
+
- `KailashClient(base_url, auth=(username, password))` sends HTTP Basic on
|
|
85
|
+
every request.
|
|
86
|
+
- `client.login(username, password)` exchanges the credentials for a Bearer
|
|
87
|
+
token (TTL 12h on the server) and uses it for subsequent requests;
|
|
88
|
+
`client.logout()` revokes it and falls back to Basic (or clears the header
|
|
89
|
+
if no Basic credentials were given).
|
|
90
|
+
|
|
91
|
+
## Error handling
|
|
92
|
+
|
|
93
|
+
Server errors can be normalized to a structured triple (`status`, `message`,
|
|
94
|
+
`message_key`) for i18n/branching:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from kailash_client import KailashApiError
|
|
98
|
+
from kailash_client.generated.exceptions import ApiException
|
|
99
|
+
|
|
100
|
+
try:
|
|
101
|
+
client.slots.acquire(request)
|
|
102
|
+
except ApiException as e:
|
|
103
|
+
err = KailashApiError.from_api_exception(e)
|
|
104
|
+
print(err.status, err.message, err.message_key)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Timeouts and retries
|
|
108
|
+
|
|
109
|
+
The client does not impose its own timeouts or automatic retries — pass
|
|
110
|
+
`_request_timeout=...` per call or configure the urllib3 pool on the generated
|
|
111
|
+
`Configuration`. See the
|
|
112
|
+
[main README](https://github.com/qiangyt/kailash) for the full auth model,
|
|
113
|
+
error contract, and plugin/category documentation.
|
|
114
|
+
|
|
115
|
+
## Other clients
|
|
116
|
+
|
|
117
|
+
The same API is available as
|
|
118
|
+
[Java](https://github.com/qiangyt/kailash/tree/main/clients/kailash-client-java),
|
|
119
|
+
[TypeScript](https://github.com/qiangyt/kailash/tree/main/clients/kailash-client-typescript),
|
|
120
|
+
[JavaScript](https://github.com/qiangyt/kailash/tree/main/clients/kailash-client-javascript),
|
|
121
|
+
[Rust](https://github.com/qiangyt/kailash/tree/main/clients/kailash-client-rust), and
|
|
122
|
+
[Go](https://github.com/qiangyt/kailash/tree/main/clients/kailash-client-go) clients.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# kailash-client (Python)
|
|
2
|
+
|
|
3
|
+
Python client for [kailash](https://github.com/qiangyt/kailash) — a test-resource
|
|
4
|
+
control plane that hands out isolated, short-lived infrastructure resources
|
|
5
|
+
(PostgreSQL schemas, Elasticsearch indices, Redis databases, MinIO buckets,
|
|
6
|
+
Hatchet tenants, MySQL databases, Chrome contexts) as *slots* acquired from a
|
|
7
|
+
pool of registered instances.
|
|
8
|
+
|
|
9
|
+
The package ships two layers:
|
|
10
|
+
|
|
11
|
+
- a fully generated API/client layer (`kailash_client.generated`, pydantic v2
|
|
12
|
+
models plus one typed API class per kailash endpoint), and
|
|
13
|
+
- a thin hand-written facade, `KailashClient`, which is the recommended entry
|
|
14
|
+
point.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install kailash-client
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Requires Python 3.10+.
|
|
23
|
+
|
|
24
|
+
## Quickstart
|
|
25
|
+
|
|
26
|
+
Point the client at a running kailash server (`http://localhost:18080` is the
|
|
27
|
+
default) and acquire a slot from the zero-dependency in-memory `demo` category
|
|
28
|
+
(note: `demo` is disabled by default on a stock deployment — a ROOT user can
|
|
29
|
+
enable it via `POST /api/categories/demo/enable`):
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from kailash_client import AcquireRequest, KailashClient, Slot, SlotSpec
|
|
33
|
+
from kailash_client.generated.models import DemoSlotSpec
|
|
34
|
+
|
|
35
|
+
client = KailashClient("http://localhost:18080", auth=("user", "password"))
|
|
36
|
+
|
|
37
|
+
slot: Slot = client.slots.acquire(
|
|
38
|
+
AcquireRequest(
|
|
39
|
+
spec=SlotSpec(
|
|
40
|
+
DemoSlotSpec(
|
|
41
|
+
caller_app="my-app",
|
|
42
|
+
caller_run="run-1",
|
|
43
|
+
timeout_seconds=600,
|
|
44
|
+
)
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
print(slot.slot_id, slot.endpoint)
|
|
49
|
+
|
|
50
|
+
# Release as soon as you are done — the TTL is only a safety net.
|
|
51
|
+
client.slots.release(slot.slot_id)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`SlotSpec(...)` wraps one concrete spec (polymorphic oneOf); every category has
|
|
55
|
+
its own spec model, e.g. `PgSlotSpec`, `RedisSlotSpec`, `EsSlotSpec`.
|
|
56
|
+
|
|
57
|
+
## Authentication
|
|
58
|
+
|
|
59
|
+
kailash requires authentication on all `/api/*` endpoints (Basic or Bearer):
|
|
60
|
+
|
|
61
|
+
- `KailashClient(base_url, auth=(username, password))` sends HTTP Basic on
|
|
62
|
+
every request.
|
|
63
|
+
- `client.login(username, password)` exchanges the credentials for a Bearer
|
|
64
|
+
token (TTL 12h on the server) and uses it for subsequent requests;
|
|
65
|
+
`client.logout()` revokes it and falls back to Basic (or clears the header
|
|
66
|
+
if no Basic credentials were given).
|
|
67
|
+
|
|
68
|
+
## Error handling
|
|
69
|
+
|
|
70
|
+
Server errors can be normalized to a structured triple (`status`, `message`,
|
|
71
|
+
`message_key`) for i18n/branching:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from kailash_client import KailashApiError
|
|
75
|
+
from kailash_client.generated.exceptions import ApiException
|
|
76
|
+
|
|
77
|
+
try:
|
|
78
|
+
client.slots.acquire(request)
|
|
79
|
+
except ApiException as e:
|
|
80
|
+
err = KailashApiError.from_api_exception(e)
|
|
81
|
+
print(err.status, err.message, err.message_key)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Timeouts and retries
|
|
85
|
+
|
|
86
|
+
The client does not impose its own timeouts or automatic retries — pass
|
|
87
|
+
`_request_timeout=...` per call or configure the urllib3 pool on the generated
|
|
88
|
+
`Configuration`. See the
|
|
89
|
+
[main README](https://github.com/qiangyt/kailash) for the full auth model,
|
|
90
|
+
error contract, and plugin/category documentation.
|
|
91
|
+
|
|
92
|
+
## Other clients
|
|
93
|
+
|
|
94
|
+
The same API is available as
|
|
95
|
+
[Java](https://github.com/qiangyt/kailash/tree/main/clients/kailash-client-java),
|
|
96
|
+
[TypeScript](https://github.com/qiangyt/kailash/tree/main/clients/kailash-client-typescript),
|
|
97
|
+
[JavaScript](https://github.com/qiangyt/kailash/tree/main/clients/kailash-client-javascript),
|
|
98
|
+
[Rust](https://github.com/qiangyt/kailash/tree/main/clients/kailash-client-rust), and
|
|
99
|
+
[Go](https://github.com/qiangyt/kailash/tree/main/clients/kailash-client-go) clients.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2026 Yiting Qiang
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
from kailash_client.client import KailashClient
|
|
7
|
+
from kailash_client.errors import KailashApiError
|
|
8
|
+
from kailash_client.generated.exceptions import ApiException
|
|
9
|
+
from kailash_client.generated.models import (
|
|
10
|
+
AcquireRequest,
|
|
11
|
+
ChromeSlotSpec,
|
|
12
|
+
MinioSlotSpec,
|
|
13
|
+
RedisNsSlotSpec,
|
|
14
|
+
RedisPinnedSlotSpec,
|
|
15
|
+
RedisSlotSpec,
|
|
16
|
+
Slot,
|
|
17
|
+
SlotCredentials,
|
|
18
|
+
SlotSpec,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"AcquireRequest",
|
|
23
|
+
"ApiException",
|
|
24
|
+
"ChromeSlotSpec",
|
|
25
|
+
"KailashApiError",
|
|
26
|
+
"KailashClient",
|
|
27
|
+
"MinioSlotSpec",
|
|
28
|
+
"RedisNsSlotSpec",
|
|
29
|
+
"RedisPinnedSlotSpec",
|
|
30
|
+
"RedisSlotSpec",
|
|
31
|
+
"Slot",
|
|
32
|
+
"SlotCredentials",
|
|
33
|
+
"SlotSpec",
|
|
34
|
+
]
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2026 Yiting Qiang
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import base64
|
|
9
|
+
|
|
10
|
+
from kailash_client.generated import ApiClient, Configuration
|
|
11
|
+
from kailash_client.generated.api.audit_controller_api import AuditControllerApi
|
|
12
|
+
from kailash_client.generated.api.auth_controller_api import AuthControllerApi
|
|
13
|
+
from kailash_client.generated.api.category_controller_api import CategoryControllerApi
|
|
14
|
+
from kailash_client.generated.api.cdp_discovery_controller_api import (
|
|
15
|
+
CdpDiscoveryControllerApi,
|
|
16
|
+
)
|
|
17
|
+
from kailash_client.generated.api.instance_controller_api import InstanceControllerApi
|
|
18
|
+
from kailash_client.generated.api.probe_controller_api import ProbeControllerApi
|
|
19
|
+
from kailash_client.generated.api.slot_controller_api import SlotControllerApi
|
|
20
|
+
from kailash_client.generated.api.slot_list_controller_api import SlotListControllerApi
|
|
21
|
+
from kailash_client.generated.api.snapshot_controller_api import SnapshotControllerApi
|
|
22
|
+
from kailash_client.generated.api.user_controller_api import UserControllerApi
|
|
23
|
+
from kailash_client.generated.models.login_request import LoginRequest
|
|
24
|
+
|
|
25
|
+
DEFAULT_BASE_URL = "http://localhost:18080"
|
|
26
|
+
|
|
27
|
+
class KailashClient:
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
base_url: str = DEFAULT_BASE_URL,
|
|
31
|
+
auth: tuple[str, str] | None = None,
|
|
32
|
+
) -> None:
|
|
33
|
+
self.configuration = Configuration(host=base_url)
|
|
34
|
+
self._basic: str | None = (
|
|
35
|
+
"Basic " + base64.b64encode(f"{auth[0]}:{auth[1]}".encode()).decode()
|
|
36
|
+
if auth is not None
|
|
37
|
+
else None
|
|
38
|
+
)
|
|
39
|
+
self._api_client = (
|
|
40
|
+
ApiClient(self.configuration, header_name="Authorization", header_value=self._basic)
|
|
41
|
+
if self._basic is not None
|
|
42
|
+
else ApiClient(self.configuration)
|
|
43
|
+
)
|
|
44
|
+
self.auth = AuthControllerApi(self._api_client)
|
|
45
|
+
self.audit = AuditControllerApi(self._api_client)
|
|
46
|
+
self.categories = CategoryControllerApi(self._api_client)
|
|
47
|
+
self.cdp = CdpDiscoveryControllerApi(self._api_client)
|
|
48
|
+
self.instances = InstanceControllerApi(self._api_client)
|
|
49
|
+
self.probes = ProbeControllerApi(self._api_client)
|
|
50
|
+
self.slots = SlotControllerApi(self._api_client)
|
|
51
|
+
self.slot_list = SlotListControllerApi(self._api_client)
|
|
52
|
+
self.snapshots = SnapshotControllerApi(self._api_client)
|
|
53
|
+
self.users = UserControllerApi(self._api_client)
|
|
54
|
+
|
|
55
|
+
def login(self, username: str, password: str) -> None:
|
|
56
|
+
result = self.auth.login(LoginRequest(username=username, password=password))
|
|
57
|
+
if not result.token:
|
|
58
|
+
|
|
59
|
+
raise RuntimeError("kailash login response missing token")
|
|
60
|
+
self._api_client.default_headers["Authorization"] = f"Bearer {result.token}"
|
|
61
|
+
|
|
62
|
+
def logout(self) -> None:
|
|
63
|
+
try:
|
|
64
|
+
self.auth.logout()
|
|
65
|
+
finally:
|
|
66
|
+
if self._basic is not None:
|
|
67
|
+
self._api_client.default_headers["Authorization"] = self._basic
|
|
68
|
+
else:
|
|
69
|
+
self._api_client.default_headers.pop("Authorization", None)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2026 Yiting Qiang
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
|
|
10
|
+
from kailash_client.generated.exceptions import ApiException
|
|
11
|
+
|
|
12
|
+
class KailashApiError(Exception):
|
|
13
|
+
|
|
14
|
+
def __init__(self, *, status: int, message: str, message_key: str | None = None) -> None:
|
|
15
|
+
super().__init__(f"HTTP {status}: {message}")
|
|
16
|
+
self.status = status
|
|
17
|
+
self.message = message
|
|
18
|
+
self.message_key = message_key
|
|
19
|
+
|
|
20
|
+
@classmethod
|
|
21
|
+
def from_api_exception(cls, exc: ApiException) -> KailashApiError:
|
|
22
|
+
|
|
23
|
+
status: int = exc.status if isinstance(exc.status, int) else 0
|
|
24
|
+
body = _parse_error_body(exc.body)
|
|
25
|
+
if body is not None:
|
|
26
|
+
message = body.get("message")
|
|
27
|
+
message_key = body.get("messageKey")
|
|
28
|
+
return cls(
|
|
29
|
+
status=status,
|
|
30
|
+
message=message if isinstance(message, str) else _fallback(status, exc.reason),
|
|
31
|
+
message_key=message_key if isinstance(message_key, str) else None,
|
|
32
|
+
)
|
|
33
|
+
return cls(status=status, message=_fallback(status, exc.reason))
|
|
34
|
+
|
|
35
|
+
def _parse_error_body(body: str | None) -> dict[str, object] | None:
|
|
36
|
+
|
|
37
|
+
if not body:
|
|
38
|
+
return None
|
|
39
|
+
try:
|
|
40
|
+
parsed: object = json.loads(body)
|
|
41
|
+
except ValueError:
|
|
42
|
+
return None
|
|
43
|
+
return parsed if isinstance(parsed, dict) else None
|
|
44
|
+
|
|
45
|
+
def _fallback(status: int, reason: str | None) -> str:
|
|
46
|
+
|
|
47
|
+
return reason if reason else f"HTTP {status}"
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
__version__ = "0.2.1"
|
|
2
|
+
|
|
3
|
+
__all__ = [
|
|
4
|
+
"AuditControllerApi",
|
|
5
|
+
"AuthControllerApi",
|
|
6
|
+
"CategoryControllerApi",
|
|
7
|
+
"CdpDiscoveryControllerApi",
|
|
8
|
+
"InstanceControllerApi",
|
|
9
|
+
"ProbeControllerApi",
|
|
10
|
+
"SlotControllerApi",
|
|
11
|
+
"SlotListControllerApi",
|
|
12
|
+
"SnapshotControllerApi",
|
|
13
|
+
"TenantControllerApi",
|
|
14
|
+
"UserControllerApi",
|
|
15
|
+
"ApiResponse",
|
|
16
|
+
"ApiClient",
|
|
17
|
+
"Configuration",
|
|
18
|
+
"OpenApiException",
|
|
19
|
+
"ApiTypeError",
|
|
20
|
+
"ApiValueError",
|
|
21
|
+
"ApiKeyError",
|
|
22
|
+
"ApiAttributeError",
|
|
23
|
+
"ApiException",
|
|
24
|
+
"AcquireRequest",
|
|
25
|
+
"AuditEventPage",
|
|
26
|
+
"AuditEventView",
|
|
27
|
+
"AuditStatsBucket",
|
|
28
|
+
"AuditStatsGroup",
|
|
29
|
+
"AuditStatsResult",
|
|
30
|
+
"BindingDecl",
|
|
31
|
+
"CategoryDetail",
|
|
32
|
+
"CategoryInfo",
|
|
33
|
+
"ChangeOwnPasswordRequest",
|
|
34
|
+
"ChangePasswordRequest",
|
|
35
|
+
"ChromeConnection",
|
|
36
|
+
"ChromeSlotSpec",
|
|
37
|
+
"CreateTenantRequest",
|
|
38
|
+
"CreateUserRequest",
|
|
39
|
+
"DemoConnection",
|
|
40
|
+
"DemoSeedSpec",
|
|
41
|
+
"DemoSlotSpec",
|
|
42
|
+
"Entry",
|
|
43
|
+
"EsConnection",
|
|
44
|
+
"EsSeedSpec",
|
|
45
|
+
"EsSlotSpec",
|
|
46
|
+
"EsTemplateDeclaration",
|
|
47
|
+
"ExchangeDecl",
|
|
48
|
+
"HatchetConnection",
|
|
49
|
+
"HatchetSlotSpec",
|
|
50
|
+
"HealthProbe",
|
|
51
|
+
"InstanceDescriptor",
|
|
52
|
+
"JsonNode",
|
|
53
|
+
"LoginRequest",
|
|
54
|
+
"LoginResult",
|
|
55
|
+
"LogsProbe",
|
|
56
|
+
"MinioConnection",
|
|
57
|
+
"MinioSeedSpec",
|
|
58
|
+
"MinioSlotSpec",
|
|
59
|
+
"MysqlConnection",
|
|
60
|
+
"MysqlSeedSpec",
|
|
61
|
+
"MysqlSlotSpec",
|
|
62
|
+
"PageMetadata",
|
|
63
|
+
"PagedModelSlotView",
|
|
64
|
+
"PagedModelSnapshot",
|
|
65
|
+
"PgConnection",
|
|
66
|
+
"PgSeedSpec",
|
|
67
|
+
"PgSlotSpec",
|
|
68
|
+
"ProvisionRequest",
|
|
69
|
+
"QueueDecl",
|
|
70
|
+
"RabbitmqConnection",
|
|
71
|
+
"RabbitmqSeedSpec",
|
|
72
|
+
"RabbitmqSlotSpec",
|
|
73
|
+
"RedisConnection",
|
|
74
|
+
"RedisNsConnection",
|
|
75
|
+
"RedisNsSeedSpec",
|
|
76
|
+
"RedisNsSlotSpec",
|
|
77
|
+
"RedisPinnedConnection",
|
|
78
|
+
"RedisPinnedSeedSpec",
|
|
79
|
+
"RedisPinnedSlotSpec",
|
|
80
|
+
"RedisSeedSpec",
|
|
81
|
+
"RedisSlotSpec",
|
|
82
|
+
"ResourceConnection",
|
|
83
|
+
"SeedEntry",
|
|
84
|
+
"SeedSpec",
|
|
85
|
+
"Slot",
|
|
86
|
+
"SlotCredentials",
|
|
87
|
+
"SlotSpec",
|
|
88
|
+
"SlotView",
|
|
89
|
+
"Snapshot",
|
|
90
|
+
"SnapshotCreateRequest",
|
|
91
|
+
"SpecFieldDoc",
|
|
92
|
+
"StatsProbe",
|
|
93
|
+
"TenantResponse",
|
|
94
|
+
"UpdateOwnProfileRequest",
|
|
95
|
+
"UpdateTenantRequest",
|
|
96
|
+
"UserResponse",
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
from kailash_client.generated.api.audit_controller_api import AuditControllerApi as AuditControllerApi
|
|
100
|
+
from kailash_client.generated.api.auth_controller_api import AuthControllerApi as AuthControllerApi
|
|
101
|
+
from kailash_client.generated.api.category_controller_api import CategoryControllerApi as CategoryControllerApi
|
|
102
|
+
from kailash_client.generated.api.cdp_discovery_controller_api import CdpDiscoveryControllerApi as CdpDiscoveryControllerApi
|
|
103
|
+
from kailash_client.generated.api.instance_controller_api import InstanceControllerApi as InstanceControllerApi
|
|
104
|
+
from kailash_client.generated.api.probe_controller_api import ProbeControllerApi as ProbeControllerApi
|
|
105
|
+
from kailash_client.generated.api.slot_controller_api import SlotControllerApi as SlotControllerApi
|
|
106
|
+
from kailash_client.generated.api.slot_list_controller_api import SlotListControllerApi as SlotListControllerApi
|
|
107
|
+
from kailash_client.generated.api.snapshot_controller_api import SnapshotControllerApi as SnapshotControllerApi
|
|
108
|
+
from kailash_client.generated.api.tenant_controller_api import TenantControllerApi as TenantControllerApi
|
|
109
|
+
from kailash_client.generated.api.user_controller_api import UserControllerApi as UserControllerApi
|
|
110
|
+
|
|
111
|
+
from kailash_client.generated.api_response import ApiResponse as ApiResponse
|
|
112
|
+
from kailash_client.generated.api_client import ApiClient as ApiClient
|
|
113
|
+
from kailash_client.generated.configuration import Configuration as Configuration
|
|
114
|
+
from kailash_client.generated.exceptions import OpenApiException as OpenApiException
|
|
115
|
+
from kailash_client.generated.exceptions import ApiTypeError as ApiTypeError
|
|
116
|
+
from kailash_client.generated.exceptions import ApiValueError as ApiValueError
|
|
117
|
+
from kailash_client.generated.exceptions import ApiKeyError as ApiKeyError
|
|
118
|
+
from kailash_client.generated.exceptions import ApiAttributeError as ApiAttributeError
|
|
119
|
+
from kailash_client.generated.exceptions import ApiException as ApiException
|
|
120
|
+
|
|
121
|
+
from kailash_client.generated.models.acquire_request import AcquireRequest as AcquireRequest
|
|
122
|
+
from kailash_client.generated.models.audit_event_page import AuditEventPage as AuditEventPage
|
|
123
|
+
from kailash_client.generated.models.audit_event_view import AuditEventView as AuditEventView
|
|
124
|
+
from kailash_client.generated.models.audit_stats_bucket import AuditStatsBucket as AuditStatsBucket
|
|
125
|
+
from kailash_client.generated.models.audit_stats_group import AuditStatsGroup as AuditStatsGroup
|
|
126
|
+
from kailash_client.generated.models.audit_stats_result import AuditStatsResult as AuditStatsResult
|
|
127
|
+
from kailash_client.generated.models.binding_decl import BindingDecl as BindingDecl
|
|
128
|
+
from kailash_client.generated.models.category_detail import CategoryDetail as CategoryDetail
|
|
129
|
+
from kailash_client.generated.models.category_info import CategoryInfo as CategoryInfo
|
|
130
|
+
from kailash_client.generated.models.change_own_password_request import ChangeOwnPasswordRequest as ChangeOwnPasswordRequest
|
|
131
|
+
from kailash_client.generated.models.change_password_request import ChangePasswordRequest as ChangePasswordRequest
|
|
132
|
+
from kailash_client.generated.models.chrome_connection import ChromeConnection as ChromeConnection
|
|
133
|
+
from kailash_client.generated.models.chrome_slot_spec import ChromeSlotSpec as ChromeSlotSpec
|
|
134
|
+
from kailash_client.generated.models.create_tenant_request import CreateTenantRequest as CreateTenantRequest
|
|
135
|
+
from kailash_client.generated.models.create_user_request import CreateUserRequest as CreateUserRequest
|
|
136
|
+
from kailash_client.generated.models.demo_connection import DemoConnection as DemoConnection
|
|
137
|
+
from kailash_client.generated.models.demo_seed_spec import DemoSeedSpec as DemoSeedSpec
|
|
138
|
+
from kailash_client.generated.models.demo_slot_spec import DemoSlotSpec as DemoSlotSpec
|
|
139
|
+
from kailash_client.generated.models.entry import Entry as Entry
|
|
140
|
+
from kailash_client.generated.models.es_connection import EsConnection as EsConnection
|
|
141
|
+
from kailash_client.generated.models.es_seed_spec import EsSeedSpec as EsSeedSpec
|
|
142
|
+
from kailash_client.generated.models.es_slot_spec import EsSlotSpec as EsSlotSpec
|
|
143
|
+
from kailash_client.generated.models.es_template_declaration import EsTemplateDeclaration as EsTemplateDeclaration
|
|
144
|
+
from kailash_client.generated.models.exchange_decl import ExchangeDecl as ExchangeDecl
|
|
145
|
+
from kailash_client.generated.models.hatchet_connection import HatchetConnection as HatchetConnection
|
|
146
|
+
from kailash_client.generated.models.hatchet_slot_spec import HatchetSlotSpec as HatchetSlotSpec
|
|
147
|
+
from kailash_client.generated.models.health_probe import HealthProbe as HealthProbe
|
|
148
|
+
from kailash_client.generated.models.instance_descriptor import InstanceDescriptor as InstanceDescriptor
|
|
149
|
+
from kailash_client.generated.models.json_node import JsonNode as JsonNode
|
|
150
|
+
from kailash_client.generated.models.login_request import LoginRequest as LoginRequest
|
|
151
|
+
from kailash_client.generated.models.login_result import LoginResult as LoginResult
|
|
152
|
+
from kailash_client.generated.models.logs_probe import LogsProbe as LogsProbe
|
|
153
|
+
from kailash_client.generated.models.minio_connection import MinioConnection as MinioConnection
|
|
154
|
+
from kailash_client.generated.models.minio_seed_spec import MinioSeedSpec as MinioSeedSpec
|
|
155
|
+
from kailash_client.generated.models.minio_slot_spec import MinioSlotSpec as MinioSlotSpec
|
|
156
|
+
from kailash_client.generated.models.mysql_connection import MysqlConnection as MysqlConnection
|
|
157
|
+
from kailash_client.generated.models.mysql_seed_spec import MysqlSeedSpec as MysqlSeedSpec
|
|
158
|
+
from kailash_client.generated.models.mysql_slot_spec import MysqlSlotSpec as MysqlSlotSpec
|
|
159
|
+
from kailash_client.generated.models.page_metadata import PageMetadata as PageMetadata
|
|
160
|
+
from kailash_client.generated.models.paged_model_slot_view import PagedModelSlotView as PagedModelSlotView
|
|
161
|
+
from kailash_client.generated.models.paged_model_snapshot import PagedModelSnapshot as PagedModelSnapshot
|
|
162
|
+
from kailash_client.generated.models.pg_connection import PgConnection as PgConnection
|
|
163
|
+
from kailash_client.generated.models.pg_seed_spec import PgSeedSpec as PgSeedSpec
|
|
164
|
+
from kailash_client.generated.models.pg_slot_spec import PgSlotSpec as PgSlotSpec
|
|
165
|
+
from kailash_client.generated.models.provision_request import ProvisionRequest as ProvisionRequest
|
|
166
|
+
from kailash_client.generated.models.queue_decl import QueueDecl as QueueDecl
|
|
167
|
+
from kailash_client.generated.models.rabbitmq_connection import RabbitmqConnection as RabbitmqConnection
|
|
168
|
+
from kailash_client.generated.models.rabbitmq_seed_spec import RabbitmqSeedSpec as RabbitmqSeedSpec
|
|
169
|
+
from kailash_client.generated.models.rabbitmq_slot_spec import RabbitmqSlotSpec as RabbitmqSlotSpec
|
|
170
|
+
from kailash_client.generated.models.redis_connection import RedisConnection as RedisConnection
|
|
171
|
+
from kailash_client.generated.models.redis_ns_connection import RedisNsConnection as RedisNsConnection
|
|
172
|
+
from kailash_client.generated.models.redis_ns_seed_spec import RedisNsSeedSpec as RedisNsSeedSpec
|
|
173
|
+
from kailash_client.generated.models.redis_ns_slot_spec import RedisNsSlotSpec as RedisNsSlotSpec
|
|
174
|
+
from kailash_client.generated.models.redis_pinned_connection import RedisPinnedConnection as RedisPinnedConnection
|
|
175
|
+
from kailash_client.generated.models.redis_pinned_seed_spec import RedisPinnedSeedSpec as RedisPinnedSeedSpec
|
|
176
|
+
from kailash_client.generated.models.redis_pinned_slot_spec import RedisPinnedSlotSpec as RedisPinnedSlotSpec
|
|
177
|
+
from kailash_client.generated.models.redis_seed_spec import RedisSeedSpec as RedisSeedSpec
|
|
178
|
+
from kailash_client.generated.models.redis_slot_spec import RedisSlotSpec as RedisSlotSpec
|
|
179
|
+
from kailash_client.generated.models.resource_connection import ResourceConnection as ResourceConnection
|
|
180
|
+
from kailash_client.generated.models.seed_entry import SeedEntry as SeedEntry
|
|
181
|
+
from kailash_client.generated.models.seed_spec import SeedSpec as SeedSpec
|
|
182
|
+
from kailash_client.generated.models.slot import Slot as Slot
|
|
183
|
+
from kailash_client.generated.models.slot_credentials import SlotCredentials as SlotCredentials
|
|
184
|
+
from kailash_client.generated.models.slot_spec import SlotSpec as SlotSpec
|
|
185
|
+
from kailash_client.generated.models.slot_view import SlotView as SlotView
|
|
186
|
+
from kailash_client.generated.models.snapshot import Snapshot as Snapshot
|
|
187
|
+
from kailash_client.generated.models.snapshot_create_request import SnapshotCreateRequest as SnapshotCreateRequest
|
|
188
|
+
from kailash_client.generated.models.spec_field_doc import SpecFieldDoc as SpecFieldDoc
|
|
189
|
+
from kailash_client.generated.models.stats_probe import StatsProbe as StatsProbe
|
|
190
|
+
from kailash_client.generated.models.tenant_response import TenantResponse as TenantResponse
|
|
191
|
+
from kailash_client.generated.models.update_own_profile_request import UpdateOwnProfileRequest as UpdateOwnProfileRequest
|
|
192
|
+
from kailash_client.generated.models.update_tenant_request import UpdateTenantRequest as UpdateTenantRequest
|
|
193
|
+
from kailash_client.generated.models.user_response import UserResponse as UserResponse
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from kailash_client.generated.api.audit_controller_api import AuditControllerApi
|
|
2
|
+
from kailash_client.generated.api.auth_controller_api import AuthControllerApi
|
|
3
|
+
from kailash_client.generated.api.category_controller_api import CategoryControllerApi
|
|
4
|
+
from kailash_client.generated.api.cdp_discovery_controller_api import CdpDiscoveryControllerApi
|
|
5
|
+
from kailash_client.generated.api.instance_controller_api import InstanceControllerApi
|
|
6
|
+
from kailash_client.generated.api.probe_controller_api import ProbeControllerApi
|
|
7
|
+
from kailash_client.generated.api.slot_controller_api import SlotControllerApi
|
|
8
|
+
from kailash_client.generated.api.slot_list_controller_api import SlotListControllerApi
|
|
9
|
+
from kailash_client.generated.api.snapshot_controller_api import SnapshotControllerApi
|
|
10
|
+
from kailash_client.generated.api.tenant_controller_api import TenantControllerApi
|
|
11
|
+
from kailash_client.generated.api.user_controller_api import UserControllerApi
|