plato-sdk-v2 2.6.2__py3-none-any.whl → 2.7.1__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.
- plato/_generated/__init__.py +1 -1
- plato/_generated/api/v2/__init__.py +2 -1
- plato/_generated/api/v2/networks/__init__.py +23 -0
- plato/_generated/api/v2/networks/add_member.py +75 -0
- plato/_generated/api/v2/networks/create_network.py +70 -0
- plato/_generated/api/v2/networks/delete_network.py +68 -0
- plato/_generated/api/v2/networks/get_network.py +69 -0
- plato/_generated/api/v2/networks/list_members.py +69 -0
- plato/_generated/api/v2/networks/list_networks.py +74 -0
- plato/_generated/api/v2/networks/remove_member.py +73 -0
- plato/_generated/api/v2/networks/update_member.py +80 -0
- plato/_generated/api/v2/sessions/__init__.py +4 -0
- plato/_generated/api/v2/sessions/add_ssh_key.py +81 -0
- plato/_generated/api/v2/sessions/connect_network.py +89 -0
- plato/_generated/models/__init__.py +145 -24
- plato/v1/cli/agent.py +45 -52
- plato/v1/cli/chronos.py +46 -58
- plato/v1/cli/main.py +14 -25
- plato/v1/cli/pm.py +129 -98
- plato/v1/cli/proxy.py +343 -0
- plato/v1/cli/sandbox.py +421 -425
- plato/v1/cli/ssh.py +12 -167
- plato/v1/cli/verify.py +79 -55
- plato/v1/cli/world.py +13 -12
- plato/v2/async_/client.py +24 -2
- plato/v2/async_/session.py +48 -0
- plato/v2/sync/client.py +24 -2
- plato/v2/sync/session.py +48 -0
- {plato_sdk_v2-2.6.2.dist-info → plato_sdk_v2-2.7.1.dist-info}/METADATA +1 -1
- {plato_sdk_v2-2.6.2.dist-info → plato_sdk_v2-2.7.1.dist-info}/RECORD +32 -20
- {plato_sdk_v2-2.6.2.dist-info → plato_sdk_v2-2.7.1.dist-info}/WHEEL +0 -0
- {plato_sdk_v2-2.6.2.dist-info → plato_sdk_v2-2.7.1.dist-info}/entry_points.txt +0 -0
plato/_generated/__init__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""API version module."""
|
|
2
2
|
|
|
3
|
-
from . import agents, artifacts, chronos, chronos_packages, cluster, jobs, pypi, releases, sessions, user
|
|
3
|
+
from . import agents, artifacts, chronos, chronos_packages, cluster, jobs, networks, pypi, releases, sessions, user
|
|
4
4
|
|
|
5
5
|
__all__ = [
|
|
6
6
|
"agents",
|
|
@@ -9,6 +9,7 @@ __all__ = [
|
|
|
9
9
|
"chronos_packages",
|
|
10
10
|
"cluster",
|
|
11
11
|
"jobs",
|
|
12
|
+
"networks",
|
|
12
13
|
"pypi",
|
|
13
14
|
"releases",
|
|
14
15
|
"sessions",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""API endpoints."""
|
|
2
|
+
|
|
3
|
+
from . import (
|
|
4
|
+
add_member,
|
|
5
|
+
create_network,
|
|
6
|
+
delete_network,
|
|
7
|
+
get_network,
|
|
8
|
+
list_members,
|
|
9
|
+
list_networks,
|
|
10
|
+
remove_member,
|
|
11
|
+
update_member,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"list_networks",
|
|
16
|
+
"create_network",
|
|
17
|
+
"get_network",
|
|
18
|
+
"delete_network",
|
|
19
|
+
"list_members",
|
|
20
|
+
"add_member",
|
|
21
|
+
"update_member",
|
|
22
|
+
"remove_member",
|
|
23
|
+
]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Add Member"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
from plato._generated.models import AddMemberRequest, NetworkMemberResponse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _build_request_args(
|
|
14
|
+
session_id: str,
|
|
15
|
+
body: AddMemberRequest,
|
|
16
|
+
authorization: str | None = None,
|
|
17
|
+
x_api_key: str | None = None,
|
|
18
|
+
) -> dict[str, Any]:
|
|
19
|
+
"""Build request arguments."""
|
|
20
|
+
url = f"/api/v2/networks/{session_id}/members"
|
|
21
|
+
|
|
22
|
+
headers: dict[str, str] = {}
|
|
23
|
+
if authorization is not None:
|
|
24
|
+
headers["authorization"] = authorization
|
|
25
|
+
if x_api_key is not None:
|
|
26
|
+
headers["X-API-Key"] = x_api_key
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
"method": "POST",
|
|
30
|
+
"url": url,
|
|
31
|
+
"json": body.model_dump(mode="json", exclude_none=True),
|
|
32
|
+
"headers": headers,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def sync(
|
|
37
|
+
client: httpx.Client,
|
|
38
|
+
session_id: str,
|
|
39
|
+
body: AddMemberRequest,
|
|
40
|
+
authorization: str | None = None,
|
|
41
|
+
x_api_key: str | None = None,
|
|
42
|
+
) -> NetworkMemberResponse:
|
|
43
|
+
"""Add a member (job/VM) to a network."""
|
|
44
|
+
|
|
45
|
+
request_args = _build_request_args(
|
|
46
|
+
session_id=session_id,
|
|
47
|
+
body=body,
|
|
48
|
+
authorization=authorization,
|
|
49
|
+
x_api_key=x_api_key,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
response = client.request(**request_args)
|
|
53
|
+
raise_for_status(response)
|
|
54
|
+
return NetworkMemberResponse.model_validate(response.json())
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
async def asyncio(
|
|
58
|
+
client: httpx.AsyncClient,
|
|
59
|
+
session_id: str,
|
|
60
|
+
body: AddMemberRequest,
|
|
61
|
+
authorization: str | None = None,
|
|
62
|
+
x_api_key: str | None = None,
|
|
63
|
+
) -> NetworkMemberResponse:
|
|
64
|
+
"""Add a member (job/VM) to a network."""
|
|
65
|
+
|
|
66
|
+
request_args = _build_request_args(
|
|
67
|
+
session_id=session_id,
|
|
68
|
+
body=body,
|
|
69
|
+
authorization=authorization,
|
|
70
|
+
x_api_key=x_api_key,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
response = await client.request(**request_args)
|
|
74
|
+
raise_for_status(response)
|
|
75
|
+
return NetworkMemberResponse.model_validate(response.json())
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Create Network"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
from plato._generated.models import CreateNetworkRequest, CreateNetworkResponse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _build_request_args(
|
|
14
|
+
body: CreateNetworkRequest,
|
|
15
|
+
authorization: str | None = None,
|
|
16
|
+
x_api_key: str | None = None,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
"""Build request arguments."""
|
|
19
|
+
url = "/api/v2/networks/"
|
|
20
|
+
|
|
21
|
+
headers: dict[str, str] = {}
|
|
22
|
+
if authorization is not None:
|
|
23
|
+
headers["authorization"] = authorization
|
|
24
|
+
if x_api_key is not None:
|
|
25
|
+
headers["X-API-Key"] = x_api_key
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
"method": "POST",
|
|
29
|
+
"url": url,
|
|
30
|
+
"json": body.model_dump(mode="json", exclude_none=True),
|
|
31
|
+
"headers": headers,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def sync(
|
|
36
|
+
client: httpx.Client,
|
|
37
|
+
body: CreateNetworkRequest,
|
|
38
|
+
authorization: str | None = None,
|
|
39
|
+
x_api_key: str | None = None,
|
|
40
|
+
) -> CreateNetworkResponse:
|
|
41
|
+
"""Create a new isolated network for a session."""
|
|
42
|
+
|
|
43
|
+
request_args = _build_request_args(
|
|
44
|
+
body=body,
|
|
45
|
+
authorization=authorization,
|
|
46
|
+
x_api_key=x_api_key,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
response = client.request(**request_args)
|
|
50
|
+
raise_for_status(response)
|
|
51
|
+
return CreateNetworkResponse.model_validate(response.json())
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
async def asyncio(
|
|
55
|
+
client: httpx.AsyncClient,
|
|
56
|
+
body: CreateNetworkRequest,
|
|
57
|
+
authorization: str | None = None,
|
|
58
|
+
x_api_key: str | None = None,
|
|
59
|
+
) -> CreateNetworkResponse:
|
|
60
|
+
"""Create a new isolated network for a session."""
|
|
61
|
+
|
|
62
|
+
request_args = _build_request_args(
|
|
63
|
+
body=body,
|
|
64
|
+
authorization=authorization,
|
|
65
|
+
x_api_key=x_api_key,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
response = await client.request(**request_args)
|
|
69
|
+
raise_for_status(response)
|
|
70
|
+
return CreateNetworkResponse.model_validate(response.json())
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"""Delete Network"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _build_request_args(
|
|
13
|
+
session_id: str,
|
|
14
|
+
authorization: str | None = None,
|
|
15
|
+
x_api_key: str | None = None,
|
|
16
|
+
) -> dict[str, Any]:
|
|
17
|
+
"""Build request arguments."""
|
|
18
|
+
url = f"/api/v2/networks/{session_id}"
|
|
19
|
+
|
|
20
|
+
headers: dict[str, str] = {}
|
|
21
|
+
if authorization is not None:
|
|
22
|
+
headers["authorization"] = authorization
|
|
23
|
+
if x_api_key is not None:
|
|
24
|
+
headers["X-API-Key"] = x_api_key
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
"method": "DELETE",
|
|
28
|
+
"url": url,
|
|
29
|
+
"headers": headers,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def sync(
|
|
34
|
+
client: httpx.Client,
|
|
35
|
+
session_id: str,
|
|
36
|
+
authorization: str | None = None,
|
|
37
|
+
x_api_key: str | None = None,
|
|
38
|
+
) -> dict[str, Any]:
|
|
39
|
+
"""Delete/terminate a network."""
|
|
40
|
+
|
|
41
|
+
request_args = _build_request_args(
|
|
42
|
+
session_id=session_id,
|
|
43
|
+
authorization=authorization,
|
|
44
|
+
x_api_key=x_api_key,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
response = client.request(**request_args)
|
|
48
|
+
raise_for_status(response)
|
|
49
|
+
return response.json()
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
async def asyncio(
|
|
53
|
+
client: httpx.AsyncClient,
|
|
54
|
+
session_id: str,
|
|
55
|
+
authorization: str | None = None,
|
|
56
|
+
x_api_key: str | None = None,
|
|
57
|
+
) -> dict[str, Any]:
|
|
58
|
+
"""Delete/terminate a network."""
|
|
59
|
+
|
|
60
|
+
request_args = _build_request_args(
|
|
61
|
+
session_id=session_id,
|
|
62
|
+
authorization=authorization,
|
|
63
|
+
x_api_key=x_api_key,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
response = await client.request(**request_args)
|
|
67
|
+
raise_for_status(response)
|
|
68
|
+
return response.json()
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Get Network"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
from plato._generated.models import NetworkResponse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _build_request_args(
|
|
14
|
+
session_id: str,
|
|
15
|
+
authorization: str | None = None,
|
|
16
|
+
x_api_key: str | None = None,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
"""Build request arguments."""
|
|
19
|
+
url = f"/api/v2/networks/{session_id}"
|
|
20
|
+
|
|
21
|
+
headers: dict[str, str] = {}
|
|
22
|
+
if authorization is not None:
|
|
23
|
+
headers["authorization"] = authorization
|
|
24
|
+
if x_api_key is not None:
|
|
25
|
+
headers["X-API-Key"] = x_api_key
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
"method": "GET",
|
|
29
|
+
"url": url,
|
|
30
|
+
"headers": headers,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def sync(
|
|
35
|
+
client: httpx.Client,
|
|
36
|
+
session_id: str,
|
|
37
|
+
authorization: str | None = None,
|
|
38
|
+
x_api_key: str | None = None,
|
|
39
|
+
) -> NetworkResponse:
|
|
40
|
+
"""Get network details by session ID."""
|
|
41
|
+
|
|
42
|
+
request_args = _build_request_args(
|
|
43
|
+
session_id=session_id,
|
|
44
|
+
authorization=authorization,
|
|
45
|
+
x_api_key=x_api_key,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
response = client.request(**request_args)
|
|
49
|
+
raise_for_status(response)
|
|
50
|
+
return NetworkResponse.model_validate(response.json())
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
async def asyncio(
|
|
54
|
+
client: httpx.AsyncClient,
|
|
55
|
+
session_id: str,
|
|
56
|
+
authorization: str | None = None,
|
|
57
|
+
x_api_key: str | None = None,
|
|
58
|
+
) -> NetworkResponse:
|
|
59
|
+
"""Get network details by session ID."""
|
|
60
|
+
|
|
61
|
+
request_args = _build_request_args(
|
|
62
|
+
session_id=session_id,
|
|
63
|
+
authorization=authorization,
|
|
64
|
+
x_api_key=x_api_key,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
response = await client.request(**request_args)
|
|
68
|
+
raise_for_status(response)
|
|
69
|
+
return NetworkResponse.model_validate(response.json())
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""List Members"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
from plato._generated.models import NetworkMemberResponse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _build_request_args(
|
|
14
|
+
session_id: str,
|
|
15
|
+
authorization: str | None = None,
|
|
16
|
+
x_api_key: str | None = None,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
"""Build request arguments."""
|
|
19
|
+
url = f"/api/v2/networks/{session_id}/members"
|
|
20
|
+
|
|
21
|
+
headers: dict[str, str] = {}
|
|
22
|
+
if authorization is not None:
|
|
23
|
+
headers["authorization"] = authorization
|
|
24
|
+
if x_api_key is not None:
|
|
25
|
+
headers["X-API-Key"] = x_api_key
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
"method": "GET",
|
|
29
|
+
"url": url,
|
|
30
|
+
"headers": headers,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def sync(
|
|
35
|
+
client: httpx.Client,
|
|
36
|
+
session_id: str,
|
|
37
|
+
authorization: str | None = None,
|
|
38
|
+
x_api_key: str | None = None,
|
|
39
|
+
) -> list[NetworkMemberResponse]:
|
|
40
|
+
"""List all members in a network."""
|
|
41
|
+
|
|
42
|
+
request_args = _build_request_args(
|
|
43
|
+
session_id=session_id,
|
|
44
|
+
authorization=authorization,
|
|
45
|
+
x_api_key=x_api_key,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
response = client.request(**request_args)
|
|
49
|
+
raise_for_status(response)
|
|
50
|
+
return response.json()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
async def asyncio(
|
|
54
|
+
client: httpx.AsyncClient,
|
|
55
|
+
session_id: str,
|
|
56
|
+
authorization: str | None = None,
|
|
57
|
+
x_api_key: str | None = None,
|
|
58
|
+
) -> list[NetworkMemberResponse]:
|
|
59
|
+
"""List all members in a network."""
|
|
60
|
+
|
|
61
|
+
request_args = _build_request_args(
|
|
62
|
+
session_id=session_id,
|
|
63
|
+
authorization=authorization,
|
|
64
|
+
x_api_key=x_api_key,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
response = await client.request(**request_args)
|
|
68
|
+
raise_for_status(response)
|
|
69
|
+
return response.json()
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""List Networks"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
from plato._generated.models import NetworkResponse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _build_request_args(
|
|
14
|
+
session_id: str | None = None,
|
|
15
|
+
authorization: str | None = None,
|
|
16
|
+
x_api_key: str | None = None,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
"""Build request arguments."""
|
|
19
|
+
url = "/api/v2/networks/"
|
|
20
|
+
|
|
21
|
+
params: dict[str, Any] = {}
|
|
22
|
+
if session_id is not None:
|
|
23
|
+
params["session_id"] = session_id
|
|
24
|
+
|
|
25
|
+
headers: dict[str, str] = {}
|
|
26
|
+
if authorization is not None:
|
|
27
|
+
headers["authorization"] = authorization
|
|
28
|
+
if x_api_key is not None:
|
|
29
|
+
headers["X-API-Key"] = x_api_key
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
"method": "GET",
|
|
33
|
+
"url": url,
|
|
34
|
+
"params": params,
|
|
35
|
+
"headers": headers,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def sync(
|
|
40
|
+
client: httpx.Client,
|
|
41
|
+
session_id: str | None = None,
|
|
42
|
+
authorization: str | None = None,
|
|
43
|
+
x_api_key: str | None = None,
|
|
44
|
+
) -> list[NetworkResponse]:
|
|
45
|
+
"""List all networks for the organization."""
|
|
46
|
+
|
|
47
|
+
request_args = _build_request_args(
|
|
48
|
+
session_id=session_id,
|
|
49
|
+
authorization=authorization,
|
|
50
|
+
x_api_key=x_api_key,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
response = client.request(**request_args)
|
|
54
|
+
raise_for_status(response)
|
|
55
|
+
return response.json()
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
async def asyncio(
|
|
59
|
+
client: httpx.AsyncClient,
|
|
60
|
+
session_id: str | None = None,
|
|
61
|
+
authorization: str | None = None,
|
|
62
|
+
x_api_key: str | None = None,
|
|
63
|
+
) -> list[NetworkResponse]:
|
|
64
|
+
"""List all networks for the organization."""
|
|
65
|
+
|
|
66
|
+
request_args = _build_request_args(
|
|
67
|
+
session_id=session_id,
|
|
68
|
+
authorization=authorization,
|
|
69
|
+
x_api_key=x_api_key,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
response = await client.request(**request_args)
|
|
73
|
+
raise_for_status(response)
|
|
74
|
+
return response.json()
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""Remove Member"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _build_request_args(
|
|
13
|
+
session_id: str,
|
|
14
|
+
job_id: str,
|
|
15
|
+
authorization: str | None = None,
|
|
16
|
+
x_api_key: str | None = None,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
"""Build request arguments."""
|
|
19
|
+
url = f"/api/v2/networks/{session_id}/members/{job_id}"
|
|
20
|
+
|
|
21
|
+
headers: dict[str, str] = {}
|
|
22
|
+
if authorization is not None:
|
|
23
|
+
headers["authorization"] = authorization
|
|
24
|
+
if x_api_key is not None:
|
|
25
|
+
headers["X-API-Key"] = x_api_key
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
"method": "DELETE",
|
|
29
|
+
"url": url,
|
|
30
|
+
"headers": headers,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def sync(
|
|
35
|
+
client: httpx.Client,
|
|
36
|
+
session_id: str,
|
|
37
|
+
job_id: str,
|
|
38
|
+
authorization: str | None = None,
|
|
39
|
+
x_api_key: str | None = None,
|
|
40
|
+
) -> dict[str, Any]:
|
|
41
|
+
"""Remove a member from a network."""
|
|
42
|
+
|
|
43
|
+
request_args = _build_request_args(
|
|
44
|
+
session_id=session_id,
|
|
45
|
+
job_id=job_id,
|
|
46
|
+
authorization=authorization,
|
|
47
|
+
x_api_key=x_api_key,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
response = client.request(**request_args)
|
|
51
|
+
raise_for_status(response)
|
|
52
|
+
return response.json()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
async def asyncio(
|
|
56
|
+
client: httpx.AsyncClient,
|
|
57
|
+
session_id: str,
|
|
58
|
+
job_id: str,
|
|
59
|
+
authorization: str | None = None,
|
|
60
|
+
x_api_key: str | None = None,
|
|
61
|
+
) -> dict[str, Any]:
|
|
62
|
+
"""Remove a member from a network."""
|
|
63
|
+
|
|
64
|
+
request_args = _build_request_args(
|
|
65
|
+
session_id=session_id,
|
|
66
|
+
job_id=job_id,
|
|
67
|
+
authorization=authorization,
|
|
68
|
+
x_api_key=x_api_key,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
response = await client.request(**request_args)
|
|
72
|
+
raise_for_status(response)
|
|
73
|
+
return response.json()
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""Update Member"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
from plato._generated.models import NetworkMemberResponse, UpdateMemberRequest
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _build_request_args(
|
|
14
|
+
session_id: str,
|
|
15
|
+
job_id: str,
|
|
16
|
+
body: UpdateMemberRequest,
|
|
17
|
+
authorization: str | None = None,
|
|
18
|
+
x_api_key: str | None = None,
|
|
19
|
+
) -> dict[str, Any]:
|
|
20
|
+
"""Build request arguments."""
|
|
21
|
+
url = f"/api/v2/networks/{session_id}/members/{job_id}"
|
|
22
|
+
|
|
23
|
+
headers: dict[str, str] = {}
|
|
24
|
+
if authorization is not None:
|
|
25
|
+
headers["authorization"] = authorization
|
|
26
|
+
if x_api_key is not None:
|
|
27
|
+
headers["X-API-Key"] = x_api_key
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
"method": "PUT",
|
|
31
|
+
"url": url,
|
|
32
|
+
"json": body.model_dump(mode="json", exclude_none=True),
|
|
33
|
+
"headers": headers,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def sync(
|
|
38
|
+
client: httpx.Client,
|
|
39
|
+
session_id: str,
|
|
40
|
+
job_id: str,
|
|
41
|
+
body: UpdateMemberRequest,
|
|
42
|
+
authorization: str | None = None,
|
|
43
|
+
x_api_key: str | None = None,
|
|
44
|
+
) -> NetworkMemberResponse:
|
|
45
|
+
"""Update a network member (e.g., after VM joins with WireGuard info)."""
|
|
46
|
+
|
|
47
|
+
request_args = _build_request_args(
|
|
48
|
+
session_id=session_id,
|
|
49
|
+
job_id=job_id,
|
|
50
|
+
body=body,
|
|
51
|
+
authorization=authorization,
|
|
52
|
+
x_api_key=x_api_key,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
response = client.request(**request_args)
|
|
56
|
+
raise_for_status(response)
|
|
57
|
+
return NetworkMemberResponse.model_validate(response.json())
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
async def asyncio(
|
|
61
|
+
client: httpx.AsyncClient,
|
|
62
|
+
session_id: str,
|
|
63
|
+
job_id: str,
|
|
64
|
+
body: UpdateMemberRequest,
|
|
65
|
+
authorization: str | None = None,
|
|
66
|
+
x_api_key: str | None = None,
|
|
67
|
+
) -> NetworkMemberResponse:
|
|
68
|
+
"""Update a network member (e.g., after VM joins with WireGuard info)."""
|
|
69
|
+
|
|
70
|
+
request_args = _build_request_args(
|
|
71
|
+
session_id=session_id,
|
|
72
|
+
job_id=job_id,
|
|
73
|
+
body=body,
|
|
74
|
+
authorization=authorization,
|
|
75
|
+
x_api_key=x_api_key,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
response = await client.request(**request_args)
|
|
79
|
+
raise_for_status(response)
|
|
80
|
+
return NetworkMemberResponse.model_validate(response.json())
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"""API endpoints."""
|
|
2
2
|
|
|
3
3
|
from . import (
|
|
4
|
+
add_ssh_key,
|
|
4
5
|
checkpoint,
|
|
5
6
|
close,
|
|
7
|
+
connect_network,
|
|
6
8
|
disk_snapshot,
|
|
7
9
|
evaluate,
|
|
8
10
|
execute,
|
|
@@ -34,6 +36,8 @@ __all__ = [
|
|
|
34
36
|
"make",
|
|
35
37
|
"reset",
|
|
36
38
|
"heartbeat",
|
|
39
|
+
"connect_network",
|
|
40
|
+
"add_ssh_key",
|
|
37
41
|
"close",
|
|
38
42
|
"upload_session_documents",
|
|
39
43
|
"log_job_mutation",
|