intelion-cloud 0.2.0__py3-none-any.whl
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.
- intelion_cloud/__init__.py +82 -0
- intelion_cloud/_client.py +108 -0
- intelion_cloud/_pagination.py +66 -0
- intelion_cloud/_transport.py +342 -0
- intelion_cloud/constants.py +74 -0
- intelion_cloud/exceptions.py +92 -0
- intelion_cloud/models/__init__.py +33 -0
- intelion_cloud/models/_base.py +39 -0
- intelion_cloud/models/components.py +218 -0
- intelion_cloud/models/flavors.py +44 -0
- intelion_cloud/models/servers.py +247 -0
- intelion_cloud/models/users.py +73 -0
- intelion_cloud/resources/__init__.py +17 -0
- intelion_cloud/resources/_base.py +152 -0
- intelion_cloud/resources/cloud_servers.py +293 -0
- intelion_cloud/resources/flavors.py +42 -0
- intelion_cloud/resources/os_images.py +66 -0
- intelion_cloud/resources/users.py +100 -0
- intelion_cloud-0.2.0.dist-info/METADATA +134 -0
- intelion_cloud-0.2.0.dist-info/RECORD +23 -0
- intelion_cloud-0.2.0.dist-info/WHEEL +5 -0
- intelion_cloud-0.2.0.dist-info/licenses/LICENSE +21 -0
- intelion_cloud-0.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""User resource — current user info and profile update."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Optional
|
|
6
|
+
|
|
7
|
+
from ..models.users import User
|
|
8
|
+
from ._base import AsyncResource, SyncResource
|
|
9
|
+
|
|
10
|
+
_PATH = "users/"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Users(SyncResource):
|
|
14
|
+
"""Synchronous user operations."""
|
|
15
|
+
|
|
16
|
+
def me(self) -> User:
|
|
17
|
+
"""Get the current authenticated user's profile.
|
|
18
|
+
|
|
19
|
+
The API requires user ID in the URL. We first list users (returns only
|
|
20
|
+
the current user) then fetch by ID.
|
|
21
|
+
"""
|
|
22
|
+
data = self._get(_PATH)
|
|
23
|
+
# The users endpoint returns a paginated list with only the current user
|
|
24
|
+
results = data.get("results", [data]) if isinstance(data, dict) else data
|
|
25
|
+
if not results:
|
|
26
|
+
raise ValueError("No user returned by the API")
|
|
27
|
+
user_data = results[0]
|
|
28
|
+
return User.from_dict(user_data)
|
|
29
|
+
|
|
30
|
+
def get(self, user_id: int) -> User:
|
|
31
|
+
"""Get a user by ID (typically your own)."""
|
|
32
|
+
data = self._get(f"{_PATH}{user_id}/")
|
|
33
|
+
return User.from_dict(data)
|
|
34
|
+
|
|
35
|
+
def update(
|
|
36
|
+
self,
|
|
37
|
+
user_id: int,
|
|
38
|
+
*,
|
|
39
|
+
first_name: Optional[str] = None,
|
|
40
|
+
last_name: Optional[str] = None,
|
|
41
|
+
company_name: Optional[str] = None,
|
|
42
|
+
last_viewed_event: Optional[str] = None,
|
|
43
|
+
default_payment_type: Optional[str] = None,
|
|
44
|
+
) -> User:
|
|
45
|
+
"""Update user profile fields."""
|
|
46
|
+
payload: Dict[str, Any] = {}
|
|
47
|
+
if first_name is not None:
|
|
48
|
+
payload["first_name"] = first_name
|
|
49
|
+
if last_name is not None:
|
|
50
|
+
payload["last_name"] = last_name
|
|
51
|
+
if company_name is not None:
|
|
52
|
+
payload["company_name"] = company_name
|
|
53
|
+
if last_viewed_event is not None:
|
|
54
|
+
payload["last_viewed_event"] = last_viewed_event
|
|
55
|
+
if default_payment_type is not None:
|
|
56
|
+
payload["default_payment_type"] = default_payment_type
|
|
57
|
+
|
|
58
|
+
data = self._patch(f"{_PATH}{user_id}/", json=payload)
|
|
59
|
+
return User.from_dict(data)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class AsyncUsers(AsyncResource):
|
|
63
|
+
"""Asynchronous user operations."""
|
|
64
|
+
|
|
65
|
+
async def me(self) -> User:
|
|
66
|
+
data = await self._get(_PATH)
|
|
67
|
+
results = data.get("results", [data]) if isinstance(data, dict) else data
|
|
68
|
+
if not results:
|
|
69
|
+
raise ValueError("No user returned by the API")
|
|
70
|
+
user_data = results[0]
|
|
71
|
+
return User.from_dict(user_data)
|
|
72
|
+
|
|
73
|
+
async def get(self, user_id: int) -> User:
|
|
74
|
+
data = await self._get(f"{_PATH}{user_id}/")
|
|
75
|
+
return User.from_dict(data)
|
|
76
|
+
|
|
77
|
+
async def update(
|
|
78
|
+
self,
|
|
79
|
+
user_id: int,
|
|
80
|
+
*,
|
|
81
|
+
first_name: Optional[str] = None,
|
|
82
|
+
last_name: Optional[str] = None,
|
|
83
|
+
company_name: Optional[str] = None,
|
|
84
|
+
last_viewed_event: Optional[str] = None,
|
|
85
|
+
default_payment_type: Optional[str] = None,
|
|
86
|
+
) -> User:
|
|
87
|
+
payload: Dict[str, Any] = {}
|
|
88
|
+
if first_name is not None:
|
|
89
|
+
payload["first_name"] = first_name
|
|
90
|
+
if last_name is not None:
|
|
91
|
+
payload["last_name"] = last_name
|
|
92
|
+
if company_name is not None:
|
|
93
|
+
payload["company_name"] = company_name
|
|
94
|
+
if last_viewed_event is not None:
|
|
95
|
+
payload["last_viewed_event"] = last_viewed_event
|
|
96
|
+
if default_payment_type is not None:
|
|
97
|
+
payload["default_payment_type"] = default_payment_type
|
|
98
|
+
|
|
99
|
+
data = await self._patch(f"{_PATH}{user_id}/", json=payload)
|
|
100
|
+
return User.from_dict(data)
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: intelion-cloud
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Python client for the Intelion Cloud API
|
|
5
|
+
Author-email: Intelion Cloud <support@intelion.cloud>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://intelion.cloud
|
|
8
|
+
Project-URL: Documentation, https://intelion.cloud/swagger/
|
|
9
|
+
Project-URL: Repository, https://github.com/IntelionCloud/ic_python_client
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
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.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: httpx>=0.24
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
26
|
+
Requires-Dist: respx>=0.20; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# Intelion Cloud Python Client
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/intelion-cloud/)
|
|
32
|
+
[](https://pypi.org/project/intelion-cloud/)
|
|
33
|
+
[](https://github.com/IntelionCloud/ic_python_client/blob/main/LICENSE)
|
|
34
|
+
|
|
35
|
+
Official Python SDK for the [Intelion Cloud](https://intelion.cloud) GPU cloud API (`/api/v2/`).
|
|
36
|
+
|
|
37
|
+
Pure `httpx` — no Django dependency. Sync and async clients, typed dataclass models, automatic pagination, retries with exponential backoff.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install intelion-cloud
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Requires Python 3.9+.
|
|
46
|
+
|
|
47
|
+
## Quickstart
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from intelion_cloud import IntelionCloud
|
|
51
|
+
|
|
52
|
+
client = IntelionCloud(token="your_api_token")
|
|
53
|
+
|
|
54
|
+
# List your cloud servers
|
|
55
|
+
for server in client.cloud_servers.list():
|
|
56
|
+
print(server.id, server.name, server.status)
|
|
57
|
+
|
|
58
|
+
# Start / stop a server
|
|
59
|
+
client.cloud_servers.start(server_id=42)
|
|
60
|
+
client.cloud_servers.stop(server_id=42)
|
|
61
|
+
|
|
62
|
+
# Create a new server
|
|
63
|
+
new_server = client.cloud_servers.create(
|
|
64
|
+
name="my-h100-box",
|
|
65
|
+
flavor_id=1, # FlavorConfig PK
|
|
66
|
+
ssd_count=100, # network disk size, GB (min 30)
|
|
67
|
+
os_id=1, # OperationalSystemImage PK
|
|
68
|
+
price_plan=0, # 0 = hourly, 1 = monthly, ...
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
client.close()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Async client
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import asyncio
|
|
78
|
+
from intelion_cloud import AsyncIntelionCloud
|
|
79
|
+
|
|
80
|
+
async def main():
|
|
81
|
+
async with AsyncIntelionCloud(token="your_api_token") as client:
|
|
82
|
+
me = await client.users.me()
|
|
83
|
+
print(me.username, me.current_balance_rub_cents)
|
|
84
|
+
|
|
85
|
+
asyncio.run(main())
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Context manager
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
with IntelionCloud(token="...") as client:
|
|
92
|
+
servers = client.cloud_servers.list()
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Available resources
|
|
96
|
+
|
|
97
|
+
| Resource | Methods |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `client.cloud_servers` | `list()`, `get()`, `create()`, `update()`, `start()`, `stop()`, `reboot()`, `delete()`, `get_status()`, `get_password()`, `clone()`, `migrate()` |
|
|
100
|
+
| `client.flavors` | `list()` |
|
|
101
|
+
| `client.os_images` | `list(flavor_id=, gpu_id=)` |
|
|
102
|
+
| `client.users` | `me()`, `get()`, `update()` |
|
|
103
|
+
|
|
104
|
+
## Authentication
|
|
105
|
+
|
|
106
|
+
Get your API token from the [Intelion Cloud dashboard](https://intelion.cloud). The client sends it as `Authorization: Token {token}`.
|
|
107
|
+
|
|
108
|
+
## Error handling
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from intelion_cloud import (
|
|
112
|
+
AuthenticationError, NotFoundError, ConflictError,
|
|
113
|
+
RateLimitError, ValidationError, ServerError,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
server = client.cloud_servers.get(999)
|
|
118
|
+
except NotFoundError:
|
|
119
|
+
print("Server not found")
|
|
120
|
+
except AuthenticationError:
|
|
121
|
+
print("Invalid token")
|
|
122
|
+
except ValidationError as e:
|
|
123
|
+
print("Field errors:", e.field_errors)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Links
|
|
127
|
+
|
|
128
|
+
- **Homepage:** https://intelion.cloud
|
|
129
|
+
- **API docs (Swagger):** https://intelion.cloud/api/
|
|
130
|
+
- **Source:** https://github.com/IntelionCloud/ic_python_client
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
intelion_cloud/__init__.py,sha256=0cSX6roXX7Esjnn36qRB9YHJS5WxjnsD4wQg3lr42K4,1505
|
|
2
|
+
intelion_cloud/_client.py,sha256=WmRj9xe6QcyxDavPkyV9VN02Gk0XBr7piGs6kilGaPw,3421
|
|
3
|
+
intelion_cloud/_pagination.py,sha256=4nhZlYlHoTcFXN4wjNCPz9heKoC8XQFJvKbSGiDqe7s,1867
|
|
4
|
+
intelion_cloud/_transport.py,sha256=PTKZBERA24XGZiLmWfuwD1G5AQ9gsLofMcQweXmKORQ,11493
|
|
5
|
+
intelion_cloud/constants.py,sha256=aattjLdN0bRpzOoPcMFZ7ETteiH64Dy-qOjMMRwp-2E,1398
|
|
6
|
+
intelion_cloud/exceptions.py,sha256=-_FrIWVkjwfxWIsAXggFqSTLqQo3v8_-8fHUbZk4xDM,2357
|
|
7
|
+
intelion_cloud/models/__init__.py,sha256=6OfyYu0dYQptJph0mrLQ5Z8yHb1aqvTISpERJpW13yk,568
|
|
8
|
+
intelion_cloud/models/_base.py,sha256=m42hsJQd6zJzxp6HG0zSr2gSAfBSdaXAR6OP_GzZXQA,1034
|
|
9
|
+
intelion_cloud/models/components.py,sha256=a4cGKqhlCIx9vUENk69FdyAuu_kK3oKtD7tuoGV_HgE,7624
|
|
10
|
+
intelion_cloud/models/flavors.py,sha256=ekbpTqIkGc_hKEUSQnDog3JA26FlOQCLKBeCVlS__LA,1466
|
|
11
|
+
intelion_cloud/models/servers.py,sha256=lB8LxYj1NcOaZsjcwPtoq5nD_e23-o3uywywvc6kBCE,8852
|
|
12
|
+
intelion_cloud/models/users.py,sha256=acz2I0zo53YM0is0gggVjKGas_X5neLLDENhK0VDJgo,2853
|
|
13
|
+
intelion_cloud/resources/__init__.py,sha256=N7ZsKw0Pgcq7hRTTwtZHq34C1YGXkumXUV_em02Ymoc,378
|
|
14
|
+
intelion_cloud/resources/_base.py,sha256=Q6kFofrLc4nzEhHHeN07XZ0zDtwdtc6B3x1EGIUabHs,4953
|
|
15
|
+
intelion_cloud/resources/cloud_servers.py,sha256=1ZMB8bByBT5YQuBq3Q9G8AuH5peYux8j8HKd-V7oTKw,10019
|
|
16
|
+
intelion_cloud/resources/flavors.py,sha256=RjfxKXQamVjvr9v7cNI6d-EpAG5J5AW8qenUddjTxlI,1217
|
|
17
|
+
intelion_cloud/resources/os_images.py,sha256=PGH1oEo7uVR6iNS8zPndKwBAGIIUcDPGwAEUiIegtE0,2192
|
|
18
|
+
intelion_cloud/resources/users.py,sha256=KAGFvtiadJ9COYgwO0rGKlRzzd27hxqbAiO3v4jTvqI,3444
|
|
19
|
+
intelion_cloud-0.2.0.dist-info/licenses/LICENSE,sha256=CXsRz8NvBKtwLJcPLBMuc_VbYgDSZvgLzIuQEMmGzvA,1071
|
|
20
|
+
intelion_cloud-0.2.0.dist-info/METADATA,sha256=vt8W21OAZyQ_U8q7GKUEH4HxNt0azgIaWv-yUw_F2Fo,3961
|
|
21
|
+
intelion_cloud-0.2.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
22
|
+
intelion_cloud-0.2.0.dist-info/top_level.txt,sha256=O4ipYIBpbm0IVBYIc0NXiFi_5AXO2ou_i4FRK5-pdKM,15
|
|
23
|
+
intelion_cloud-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Intelion.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 @@
|
|
|
1
|
+
intelion_cloud
|