intelion-cloud 0.2.2__tar.gz → 0.3.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.
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/PKG-INFO +1 -1
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/__init__.py +1 -1
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/models/servers.py +4 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/resources/cloud_servers.py +16 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud.egg-info/PKG-INFO +1 -1
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/pyproject.toml +1 -1
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/tests/test_cloud_servers.py +10 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/tests/test_models.py +10 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/LICENSE +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/README.md +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/_client.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/_pagination.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/_transport.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/constants.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/exceptions.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/models/__init__.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/models/_base.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/models/components.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/models/flavors.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/models/users.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/resources/__init__.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/resources/_base.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/resources/flavors.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/resources/os_images.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud/resources/users.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud.egg-info/SOURCES.txt +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud.egg-info/dependency_links.txt +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud.egg-info/requires.txt +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/intelion_cloud.egg-info/top_level.txt +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/setup.cfg +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/tests/test_client.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/tests/test_flavors.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/tests/test_transport.py +0 -0
- {intelion_cloud-0.2.2 → intelion_cloud-0.3.0}/tests/test_users.py +0 -0
|
@@ -44,6 +44,8 @@ class UsageAct:
|
|
|
44
44
|
cloud_server_uptime_seconds: int = 0
|
|
45
45
|
cloud_srv_price_rub_cents: int = 0
|
|
46
46
|
actual_cost_rub_cents: int = 0
|
|
47
|
+
spent_amount_rub_cents: int = 0
|
|
48
|
+
refund_amount_rub_cents: int = 0
|
|
47
49
|
next_payment: Optional[DebtInfo] = None
|
|
48
50
|
|
|
49
51
|
@classmethod
|
|
@@ -61,6 +63,8 @@ class UsageAct:
|
|
|
61
63
|
cloud_server_uptime_seconds=data.get("cloud_server_uptime_seconds", 0),
|
|
62
64
|
cloud_srv_price_rub_cents=data.get("cloud_srv_price_rub_cents", 0),
|
|
63
65
|
actual_cost_rub_cents=data.get("actual_cost_rub_cents", 0),
|
|
66
|
+
spent_amount_rub_cents=data.get("spent_amount_rub_cents", 0),
|
|
67
|
+
refund_amount_rub_cents=data.get("refund_amount_rub_cents", 0),
|
|
64
68
|
next_payment=_parse_nested(data, "next_payment", DebtInfo),
|
|
65
69
|
)
|
|
66
70
|
|
|
@@ -137,6 +137,17 @@ class CloudServers(SyncResource):
|
|
|
137
137
|
data = self._post(f"{_PATH}{server_id}/actions/", json={"status": -3})
|
|
138
138
|
return CloudServer.from_dict(data)
|
|
139
139
|
|
|
140
|
+
def reinstall_os(self, server_id: int) -> CloudServer:
|
|
141
|
+
"""Reinstall the OS on a server, wiping the boot disk.
|
|
142
|
+
|
|
143
|
+
All data on the boot disk is destroyed. The current monthly billing
|
|
144
|
+
cycle is preserved (the open UsageAct is reused). A new IP and root
|
|
145
|
+
password are generated and become available in the user panel a few
|
|
146
|
+
minutes after the call returns.
|
|
147
|
+
"""
|
|
148
|
+
data = self._post(f"{_PATH}{server_id}/reinstall-os/")
|
|
149
|
+
return CloudServer.from_dict(data)
|
|
150
|
+
|
|
140
151
|
# --- Info endpoints ---
|
|
141
152
|
|
|
142
153
|
def get_status(self, server_id: int) -> ServerStatus:
|
|
@@ -264,6 +275,11 @@ class AsyncCloudServers(AsyncResource):
|
|
|
264
275
|
data = await self._post(f"{_PATH}{server_id}/actions/", json={"status": -3})
|
|
265
276
|
return CloudServer.from_dict(data)
|
|
266
277
|
|
|
278
|
+
async def reinstall_os(self, server_id: int) -> CloudServer:
|
|
279
|
+
"""Reinstall the OS on a server, wiping the boot disk."""
|
|
280
|
+
data = await self._post(f"{_PATH}{server_id}/reinstall-os/")
|
|
281
|
+
return CloudServer.from_dict(data)
|
|
282
|
+
|
|
267
283
|
async def get_status(self, server_id: int) -> ServerStatus:
|
|
268
284
|
data = await self._get(f"{_PATH}{server_id}/status/")
|
|
269
285
|
return ServerStatus.from_dict(data)
|
|
@@ -190,6 +190,16 @@ class TestCloudServersActions:
|
|
|
190
190
|
assert server.status == -3
|
|
191
191
|
client.close()
|
|
192
192
|
|
|
193
|
+
@respx.mock(base_url=API_URL)
|
|
194
|
+
def test_reinstall_os(self, respx_mock):
|
|
195
|
+
respx_mock.post("cloud-servers/42/reinstall-os/").respond(
|
|
196
|
+
200, json=SAMPLE_CLOUD_SERVER
|
|
197
|
+
)
|
|
198
|
+
client = IntelionCloud(token="tok", base_url=BASE_URL)
|
|
199
|
+
server = client.cloud_servers.reinstall_os(42)
|
|
200
|
+
assert server.id == SAMPLE_CLOUD_SERVER["id"]
|
|
201
|
+
client.close()
|
|
202
|
+
|
|
193
203
|
@respx.mock(base_url=API_URL)
|
|
194
204
|
def test_start_with_auto_renewal(self, respx_mock):
|
|
195
205
|
respx_mock.post("cloud-servers/42/actions/").respond(
|
|
@@ -123,9 +123,19 @@ class TestUsageAct:
|
|
|
123
123
|
assert act.id == 100
|
|
124
124
|
assert act.user_config_id == 42
|
|
125
125
|
assert act.cloud_server_uptime_seconds == 3600
|
|
126
|
+
assert act.spent_amount_rub_cents == 16071
|
|
127
|
+
assert act.refund_amount_rub_cents == 0
|
|
126
128
|
assert act.next_payment is not None
|
|
127
129
|
assert act.next_payment.amount_rub_cents == 16071
|
|
128
130
|
|
|
131
|
+
def test_spent_refund_default_when_missing(self):
|
|
132
|
+
# Backward compat: older API responses don't include the new fields.
|
|
133
|
+
payload = {k: v for k, v in SAMPLE_USAGE_ACT.items()
|
|
134
|
+
if k not in ("spent_amount_rub_cents", "refund_amount_rub_cents")}
|
|
135
|
+
act = UsageAct.from_dict(payload)
|
|
136
|
+
assert act.spent_amount_rub_cents == 0
|
|
137
|
+
assert act.refund_amount_rub_cents == 0
|
|
138
|
+
|
|
129
139
|
|
|
130
140
|
class TestCloudServer:
|
|
131
141
|
def test_from_dict_full(self):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|