blaxel 0.1.9rc36__py3-none-any.whl → 0.1.10rc38__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.
- blaxel/agents/__init__.py +52 -15
- blaxel/authentication/__init__.py +11 -2
- blaxel/authentication/devicemode.py +1 -0
- blaxel/common/autoload.py +0 -2
- blaxel/common/internal.py +75 -0
- blaxel/common/settings.py +6 -1
- blaxel/mcp/server.py +2 -1
- blaxel/sandbox/base.py +68 -0
- blaxel/sandbox/client/__init__.py +8 -0
- blaxel/sandbox/client/api/__init__.py +1 -0
- blaxel/sandbox/client/api/filesystem/__init__.py +0 -0
- blaxel/sandbox/client/api/filesystem/delete_filesystem_path.py +184 -0
- blaxel/sandbox/client/api/filesystem/get_filesystem_path.py +184 -0
- blaxel/sandbox/client/api/filesystem/put_filesystem_path.py +189 -0
- blaxel/sandbox/client/api/network/__init__.py +0 -0
- blaxel/sandbox/client/api/network/delete_network_process_pid_monitor.py +169 -0
- blaxel/sandbox/client/api/network/get_network_process_pid_ports.py +169 -0
- blaxel/sandbox/client/api/network/post_network_process_pid_monitor.py +195 -0
- blaxel/sandbox/client/api/process/__init__.py +0 -0
- blaxel/sandbox/client/api/process/delete_process_identifier.py +163 -0
- blaxel/sandbox/client/api/process/delete_process_identifier_kill.py +189 -0
- blaxel/sandbox/client/api/process/get_process.py +135 -0
- blaxel/sandbox/client/api/process/get_process_identifier.py +159 -0
- blaxel/sandbox/client/api/process/get_process_identifier_logs.py +167 -0
- blaxel/sandbox/client/api/process/post_process.py +176 -0
- blaxel/sandbox/client/client.py +162 -0
- blaxel/sandbox/client/errors.py +16 -0
- blaxel/sandbox/client/models/__init__.py +35 -0
- blaxel/sandbox/client/models/delete_network_process_pid_monitor_response_200.py +45 -0
- blaxel/sandbox/client/models/directory.py +110 -0
- blaxel/sandbox/client/models/error_response.py +60 -0
- blaxel/sandbox/client/models/file.py +105 -0
- blaxel/sandbox/client/models/file_request.py +78 -0
- blaxel/sandbox/client/models/file_with_content.py +114 -0
- blaxel/sandbox/client/models/get_network_process_pid_ports_response_200.py +45 -0
- blaxel/sandbox/client/models/get_process_identifier_logs_response_200.py +45 -0
- blaxel/sandbox/client/models/port_monitor_request.py +60 -0
- blaxel/sandbox/client/models/post_network_process_pid_monitor_response_200.py +45 -0
- blaxel/sandbox/client/models/process_kill_request.py +60 -0
- blaxel/sandbox/client/models/process_request.py +118 -0
- blaxel/sandbox/client/models/process_response.py +123 -0
- blaxel/sandbox/client/models/success_response.py +69 -0
- blaxel/sandbox/client/py.typed +1 -0
- blaxel/sandbox/client/types.py +46 -0
- blaxel/sandbox/filesystem.py +102 -0
- blaxel/sandbox/process.py +57 -0
- blaxel/sandbox/sandbox.py +92 -0
- blaxel/tools/__init__.py +62 -21
- {blaxel-0.1.9rc36.dist-info → blaxel-0.1.10rc38.dist-info}/METADATA +1 -1
- {blaxel-0.1.9rc36.dist-info → blaxel-0.1.10rc38.dist-info}/RECORD +52 -11
- {blaxel-0.1.9rc36.dist-info → blaxel-0.1.10rc38.dist-info}/WHEEL +0 -0
- {blaxel-0.1.9rc36.dist-info → blaxel-0.1.10rc38.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,184 @@
|
|
1
|
+
from http import HTTPStatus
|
2
|
+
from typing import Any, Optional, Union
|
3
|
+
|
4
|
+
import httpx
|
5
|
+
|
6
|
+
from ... import errors
|
7
|
+
from ...client import Client
|
8
|
+
from ...models.directory import Directory
|
9
|
+
from ...models.error_response import ErrorResponse
|
10
|
+
from ...models.file_with_content import FileWithContent
|
11
|
+
from ...types import Response
|
12
|
+
|
13
|
+
|
14
|
+
def _get_kwargs(
|
15
|
+
path: str,
|
16
|
+
) -> dict[str, Any]:
|
17
|
+
_kwargs: dict[str, Any] = {
|
18
|
+
"method": "get",
|
19
|
+
"url": f"/filesystem/{path}",
|
20
|
+
}
|
21
|
+
|
22
|
+
return _kwargs
|
23
|
+
|
24
|
+
|
25
|
+
def _parse_response(
|
26
|
+
*, client: Client, response: httpx.Response
|
27
|
+
) -> Optional[Union[ErrorResponse, Union["Directory", "FileWithContent"]]]:
|
28
|
+
if response.status_code == 200:
|
29
|
+
|
30
|
+
def _parse_response_200(data: object) -> Union["Directory", "FileWithContent"]:
|
31
|
+
try:
|
32
|
+
if not isinstance(data, dict):
|
33
|
+
raise TypeError()
|
34
|
+
response_200_type_0 = Directory.from_dict(data)
|
35
|
+
|
36
|
+
return response_200_type_0
|
37
|
+
except: # noqa: E722
|
38
|
+
pass
|
39
|
+
if not isinstance(data, dict):
|
40
|
+
raise TypeError()
|
41
|
+
response_200_type_1 = FileWithContent.from_dict(data)
|
42
|
+
|
43
|
+
return response_200_type_1
|
44
|
+
|
45
|
+
response_200 = _parse_response_200(response.json())
|
46
|
+
|
47
|
+
return response_200
|
48
|
+
if response.status_code == 404:
|
49
|
+
response_404 = ErrorResponse.from_dict(response.json())
|
50
|
+
|
51
|
+
return response_404
|
52
|
+
if response.status_code == 500:
|
53
|
+
response_500 = ErrorResponse.from_dict(response.json())
|
54
|
+
|
55
|
+
return response_500
|
56
|
+
if client.raise_on_unexpected_status:
|
57
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
58
|
+
else:
|
59
|
+
return None
|
60
|
+
|
61
|
+
|
62
|
+
def _build_response(
|
63
|
+
*, client: Client, response: httpx.Response
|
64
|
+
) -> Response[Union[ErrorResponse, Union["Directory", "FileWithContent"]]]:
|
65
|
+
return Response(
|
66
|
+
status_code=HTTPStatus(response.status_code),
|
67
|
+
content=response.content,
|
68
|
+
headers=response.headers,
|
69
|
+
parsed=_parse_response(client=client, response=response),
|
70
|
+
)
|
71
|
+
|
72
|
+
|
73
|
+
def sync_detailed(
|
74
|
+
path: str,
|
75
|
+
*,
|
76
|
+
client: Union[Client],
|
77
|
+
) -> Response[Union[ErrorResponse, Union["Directory", "FileWithContent"]]]:
|
78
|
+
"""Get file or directory information
|
79
|
+
|
80
|
+
Get content of a file or listing of a directory
|
81
|
+
|
82
|
+
Args:
|
83
|
+
path (str):
|
84
|
+
|
85
|
+
Raises:
|
86
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
87
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
88
|
+
|
89
|
+
Returns:
|
90
|
+
Response[Union[ErrorResponse, Union['Directory', 'FileWithContent']]]
|
91
|
+
"""
|
92
|
+
|
93
|
+
kwargs = _get_kwargs(
|
94
|
+
path=path,
|
95
|
+
)
|
96
|
+
|
97
|
+
response = client.get_httpx_client().request(
|
98
|
+
**kwargs,
|
99
|
+
)
|
100
|
+
|
101
|
+
return _build_response(client=client, response=response)
|
102
|
+
|
103
|
+
|
104
|
+
def sync(
|
105
|
+
path: str,
|
106
|
+
*,
|
107
|
+
client: Union[Client],
|
108
|
+
) -> Optional[Union[ErrorResponse, Union["Directory", "FileWithContent"]]]:
|
109
|
+
"""Get file or directory information
|
110
|
+
|
111
|
+
Get content of a file or listing of a directory
|
112
|
+
|
113
|
+
Args:
|
114
|
+
path (str):
|
115
|
+
|
116
|
+
Raises:
|
117
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
118
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
119
|
+
|
120
|
+
Returns:
|
121
|
+
Union[ErrorResponse, Union['Directory', 'FileWithContent']]
|
122
|
+
"""
|
123
|
+
|
124
|
+
return sync_detailed(
|
125
|
+
path=path,
|
126
|
+
client=client,
|
127
|
+
).parsed
|
128
|
+
|
129
|
+
|
130
|
+
async def asyncio_detailed(
|
131
|
+
path: str,
|
132
|
+
*,
|
133
|
+
client: Union[Client],
|
134
|
+
) -> Response[Union[ErrorResponse, Union["Directory", "FileWithContent"]]]:
|
135
|
+
"""Get file or directory information
|
136
|
+
|
137
|
+
Get content of a file or listing of a directory
|
138
|
+
|
139
|
+
Args:
|
140
|
+
path (str):
|
141
|
+
|
142
|
+
Raises:
|
143
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
144
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
145
|
+
|
146
|
+
Returns:
|
147
|
+
Response[Union[ErrorResponse, Union['Directory', 'FileWithContent']]]
|
148
|
+
"""
|
149
|
+
|
150
|
+
kwargs = _get_kwargs(
|
151
|
+
path=path,
|
152
|
+
)
|
153
|
+
|
154
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
155
|
+
|
156
|
+
return _build_response(client=client, response=response)
|
157
|
+
|
158
|
+
|
159
|
+
async def asyncio(
|
160
|
+
path: str,
|
161
|
+
*,
|
162
|
+
client: Union[Client],
|
163
|
+
) -> Optional[Union[ErrorResponse, Union["Directory", "FileWithContent"]]]:
|
164
|
+
"""Get file or directory information
|
165
|
+
|
166
|
+
Get content of a file or listing of a directory
|
167
|
+
|
168
|
+
Args:
|
169
|
+
path (str):
|
170
|
+
|
171
|
+
Raises:
|
172
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
173
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
174
|
+
|
175
|
+
Returns:
|
176
|
+
Union[ErrorResponse, Union['Directory', 'FileWithContent']]
|
177
|
+
"""
|
178
|
+
|
179
|
+
return (
|
180
|
+
await asyncio_detailed(
|
181
|
+
path=path,
|
182
|
+
client=client,
|
183
|
+
)
|
184
|
+
).parsed
|
@@ -0,0 +1,189 @@
|
|
1
|
+
from http import HTTPStatus
|
2
|
+
from typing import Any, Optional, Union
|
3
|
+
|
4
|
+
import httpx
|
5
|
+
|
6
|
+
from ... import errors
|
7
|
+
from ...client import Client
|
8
|
+
from ...models.error_response import ErrorResponse
|
9
|
+
from ...models.file_request import FileRequest
|
10
|
+
from ...models.success_response import SuccessResponse
|
11
|
+
from ...types import Response
|
12
|
+
|
13
|
+
|
14
|
+
def _get_kwargs(
|
15
|
+
path: str,
|
16
|
+
*,
|
17
|
+
body: FileRequest,
|
18
|
+
) -> dict[str, Any]:
|
19
|
+
headers: dict[str, Any] = {}
|
20
|
+
|
21
|
+
_kwargs: dict[str, Any] = {
|
22
|
+
"method": "put",
|
23
|
+
"url": f"/filesystem/{path}",
|
24
|
+
}
|
25
|
+
|
26
|
+
if type(body) == dict:
|
27
|
+
_body = body
|
28
|
+
else:
|
29
|
+
_body = body.to_dict()
|
30
|
+
|
31
|
+
_kwargs["json"] = _body
|
32
|
+
headers["Content-Type"] = "application/json"
|
33
|
+
|
34
|
+
_kwargs["headers"] = headers
|
35
|
+
return _kwargs
|
36
|
+
|
37
|
+
|
38
|
+
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[ErrorResponse, SuccessResponse]]:
|
39
|
+
if response.status_code == 200:
|
40
|
+
response_200 = SuccessResponse.from_dict(response.json())
|
41
|
+
|
42
|
+
return response_200
|
43
|
+
if response.status_code == 400:
|
44
|
+
response_400 = ErrorResponse.from_dict(response.json())
|
45
|
+
|
46
|
+
return response_400
|
47
|
+
if response.status_code == 500:
|
48
|
+
response_500 = ErrorResponse.from_dict(response.json())
|
49
|
+
|
50
|
+
return response_500
|
51
|
+
if client.raise_on_unexpected_status:
|
52
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
53
|
+
else:
|
54
|
+
return None
|
55
|
+
|
56
|
+
|
57
|
+
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[ErrorResponse, SuccessResponse]]:
|
58
|
+
return Response(
|
59
|
+
status_code=HTTPStatus(response.status_code),
|
60
|
+
content=response.content,
|
61
|
+
headers=response.headers,
|
62
|
+
parsed=_parse_response(client=client, response=response),
|
63
|
+
)
|
64
|
+
|
65
|
+
|
66
|
+
def sync_detailed(
|
67
|
+
path: str,
|
68
|
+
*,
|
69
|
+
client: Union[Client],
|
70
|
+
body: FileRequest,
|
71
|
+
) -> Response[Union[ErrorResponse, SuccessResponse]]:
|
72
|
+
"""Create or update file or directory
|
73
|
+
|
74
|
+
Create or update a file or directory
|
75
|
+
|
76
|
+
Args:
|
77
|
+
path (str):
|
78
|
+
body (FileRequest):
|
79
|
+
|
80
|
+
Raises:
|
81
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
82
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
83
|
+
|
84
|
+
Returns:
|
85
|
+
Response[Union[ErrorResponse, SuccessResponse]]
|
86
|
+
"""
|
87
|
+
|
88
|
+
kwargs = _get_kwargs(
|
89
|
+
path=path,
|
90
|
+
body=body,
|
91
|
+
)
|
92
|
+
|
93
|
+
response = client.get_httpx_client().request(
|
94
|
+
**kwargs,
|
95
|
+
)
|
96
|
+
|
97
|
+
return _build_response(client=client, response=response)
|
98
|
+
|
99
|
+
|
100
|
+
def sync(
|
101
|
+
path: str,
|
102
|
+
*,
|
103
|
+
client: Union[Client],
|
104
|
+
body: FileRequest,
|
105
|
+
) -> Optional[Union[ErrorResponse, SuccessResponse]]:
|
106
|
+
"""Create or update file or directory
|
107
|
+
|
108
|
+
Create or update a file or directory
|
109
|
+
|
110
|
+
Args:
|
111
|
+
path (str):
|
112
|
+
body (FileRequest):
|
113
|
+
|
114
|
+
Raises:
|
115
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
116
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
117
|
+
|
118
|
+
Returns:
|
119
|
+
Union[ErrorResponse, SuccessResponse]
|
120
|
+
"""
|
121
|
+
|
122
|
+
return sync_detailed(
|
123
|
+
path=path,
|
124
|
+
client=client,
|
125
|
+
body=body,
|
126
|
+
).parsed
|
127
|
+
|
128
|
+
|
129
|
+
async def asyncio_detailed(
|
130
|
+
path: str,
|
131
|
+
*,
|
132
|
+
client: Union[Client],
|
133
|
+
body: FileRequest,
|
134
|
+
) -> Response[Union[ErrorResponse, SuccessResponse]]:
|
135
|
+
"""Create or update file or directory
|
136
|
+
|
137
|
+
Create or update a file or directory
|
138
|
+
|
139
|
+
Args:
|
140
|
+
path (str):
|
141
|
+
body (FileRequest):
|
142
|
+
|
143
|
+
Raises:
|
144
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
145
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
146
|
+
|
147
|
+
Returns:
|
148
|
+
Response[Union[ErrorResponse, SuccessResponse]]
|
149
|
+
"""
|
150
|
+
|
151
|
+
kwargs = _get_kwargs(
|
152
|
+
path=path,
|
153
|
+
body=body,
|
154
|
+
)
|
155
|
+
|
156
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
157
|
+
|
158
|
+
return _build_response(client=client, response=response)
|
159
|
+
|
160
|
+
|
161
|
+
async def asyncio(
|
162
|
+
path: str,
|
163
|
+
*,
|
164
|
+
client: Union[Client],
|
165
|
+
body: FileRequest,
|
166
|
+
) -> Optional[Union[ErrorResponse, SuccessResponse]]:
|
167
|
+
"""Create or update file or directory
|
168
|
+
|
169
|
+
Create or update a file or directory
|
170
|
+
|
171
|
+
Args:
|
172
|
+
path (str):
|
173
|
+
body (FileRequest):
|
174
|
+
|
175
|
+
Raises:
|
176
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
177
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
178
|
+
|
179
|
+
Returns:
|
180
|
+
Union[ErrorResponse, SuccessResponse]
|
181
|
+
"""
|
182
|
+
|
183
|
+
return (
|
184
|
+
await asyncio_detailed(
|
185
|
+
path=path,
|
186
|
+
client=client,
|
187
|
+
body=body,
|
188
|
+
)
|
189
|
+
).parsed
|
File without changes
|
@@ -0,0 +1,169 @@
|
|
1
|
+
from http import HTTPStatus
|
2
|
+
from typing import Any, Optional, Union
|
3
|
+
|
4
|
+
import httpx
|
5
|
+
|
6
|
+
from ... import errors
|
7
|
+
from ...client import Client
|
8
|
+
from ...models.delete_network_process_pid_monitor_response_200 import (
|
9
|
+
DeleteNetworkProcessPidMonitorResponse200,
|
10
|
+
)
|
11
|
+
from ...models.error_response import ErrorResponse
|
12
|
+
from ...types import Response
|
13
|
+
|
14
|
+
|
15
|
+
def _get_kwargs(
|
16
|
+
pid: int,
|
17
|
+
) -> dict[str, Any]:
|
18
|
+
_kwargs: dict[str, Any] = {
|
19
|
+
"method": "delete",
|
20
|
+
"url": f"/network/process/{pid}/monitor",
|
21
|
+
}
|
22
|
+
|
23
|
+
return _kwargs
|
24
|
+
|
25
|
+
|
26
|
+
def _parse_response(
|
27
|
+
*, client: Client, response: httpx.Response
|
28
|
+
) -> Optional[Union[DeleteNetworkProcessPidMonitorResponse200, ErrorResponse]]:
|
29
|
+
if response.status_code == 200:
|
30
|
+
response_200 = DeleteNetworkProcessPidMonitorResponse200.from_dict(response.json())
|
31
|
+
|
32
|
+
return response_200
|
33
|
+
if response.status_code == 400:
|
34
|
+
response_400 = ErrorResponse.from_dict(response.json())
|
35
|
+
|
36
|
+
return response_400
|
37
|
+
if response.status_code == 500:
|
38
|
+
response_500 = ErrorResponse.from_dict(response.json())
|
39
|
+
|
40
|
+
return response_500
|
41
|
+
if client.raise_on_unexpected_status:
|
42
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
43
|
+
else:
|
44
|
+
return None
|
45
|
+
|
46
|
+
|
47
|
+
def _build_response(
|
48
|
+
*, client: Client, response: httpx.Response
|
49
|
+
) -> Response[Union[DeleteNetworkProcessPidMonitorResponse200, ErrorResponse]]:
|
50
|
+
return Response(
|
51
|
+
status_code=HTTPStatus(response.status_code),
|
52
|
+
content=response.content,
|
53
|
+
headers=response.headers,
|
54
|
+
parsed=_parse_response(client=client, response=response),
|
55
|
+
)
|
56
|
+
|
57
|
+
|
58
|
+
def sync_detailed(
|
59
|
+
pid: int,
|
60
|
+
*,
|
61
|
+
client: Union[Client],
|
62
|
+
) -> Response[Union[DeleteNetworkProcessPidMonitorResponse200, ErrorResponse]]:
|
63
|
+
"""Stop monitoring ports for a process
|
64
|
+
|
65
|
+
Stop monitoring for new ports opened by a process
|
66
|
+
|
67
|
+
Args:
|
68
|
+
pid (int):
|
69
|
+
|
70
|
+
Raises:
|
71
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
72
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
73
|
+
|
74
|
+
Returns:
|
75
|
+
Response[Union[DeleteNetworkProcessPidMonitorResponse200, ErrorResponse]]
|
76
|
+
"""
|
77
|
+
|
78
|
+
kwargs = _get_kwargs(
|
79
|
+
pid=pid,
|
80
|
+
)
|
81
|
+
|
82
|
+
response = client.get_httpx_client().request(
|
83
|
+
**kwargs,
|
84
|
+
)
|
85
|
+
|
86
|
+
return _build_response(client=client, response=response)
|
87
|
+
|
88
|
+
|
89
|
+
def sync(
|
90
|
+
pid: int,
|
91
|
+
*,
|
92
|
+
client: Union[Client],
|
93
|
+
) -> Optional[Union[DeleteNetworkProcessPidMonitorResponse200, ErrorResponse]]:
|
94
|
+
"""Stop monitoring ports for a process
|
95
|
+
|
96
|
+
Stop monitoring for new ports opened by a process
|
97
|
+
|
98
|
+
Args:
|
99
|
+
pid (int):
|
100
|
+
|
101
|
+
Raises:
|
102
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
103
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
104
|
+
|
105
|
+
Returns:
|
106
|
+
Union[DeleteNetworkProcessPidMonitorResponse200, ErrorResponse]
|
107
|
+
"""
|
108
|
+
|
109
|
+
return sync_detailed(
|
110
|
+
pid=pid,
|
111
|
+
client=client,
|
112
|
+
).parsed
|
113
|
+
|
114
|
+
|
115
|
+
async def asyncio_detailed(
|
116
|
+
pid: int,
|
117
|
+
*,
|
118
|
+
client: Union[Client],
|
119
|
+
) -> Response[Union[DeleteNetworkProcessPidMonitorResponse200, ErrorResponse]]:
|
120
|
+
"""Stop monitoring ports for a process
|
121
|
+
|
122
|
+
Stop monitoring for new ports opened by a process
|
123
|
+
|
124
|
+
Args:
|
125
|
+
pid (int):
|
126
|
+
|
127
|
+
Raises:
|
128
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
129
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
130
|
+
|
131
|
+
Returns:
|
132
|
+
Response[Union[DeleteNetworkProcessPidMonitorResponse200, ErrorResponse]]
|
133
|
+
"""
|
134
|
+
|
135
|
+
kwargs = _get_kwargs(
|
136
|
+
pid=pid,
|
137
|
+
)
|
138
|
+
|
139
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
140
|
+
|
141
|
+
return _build_response(client=client, response=response)
|
142
|
+
|
143
|
+
|
144
|
+
async def asyncio(
|
145
|
+
pid: int,
|
146
|
+
*,
|
147
|
+
client: Union[Client],
|
148
|
+
) -> Optional[Union[DeleteNetworkProcessPidMonitorResponse200, ErrorResponse]]:
|
149
|
+
"""Stop monitoring ports for a process
|
150
|
+
|
151
|
+
Stop monitoring for new ports opened by a process
|
152
|
+
|
153
|
+
Args:
|
154
|
+
pid (int):
|
155
|
+
|
156
|
+
Raises:
|
157
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
158
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
159
|
+
|
160
|
+
Returns:
|
161
|
+
Union[DeleteNetworkProcessPidMonitorResponse200, ErrorResponse]
|
162
|
+
"""
|
163
|
+
|
164
|
+
return (
|
165
|
+
await asyncio_detailed(
|
166
|
+
pid=pid,
|
167
|
+
client=client,
|
168
|
+
)
|
169
|
+
).parsed
|
@@ -0,0 +1,169 @@
|
|
1
|
+
from http import HTTPStatus
|
2
|
+
from typing import Any, Optional, Union
|
3
|
+
|
4
|
+
import httpx
|
5
|
+
|
6
|
+
from ... import errors
|
7
|
+
from ...client import Client
|
8
|
+
from ...models.error_response import ErrorResponse
|
9
|
+
from ...models.get_network_process_pid_ports_response_200 import (
|
10
|
+
GetNetworkProcessPidPortsResponse200,
|
11
|
+
)
|
12
|
+
from ...types import Response
|
13
|
+
|
14
|
+
|
15
|
+
def _get_kwargs(
|
16
|
+
pid: int,
|
17
|
+
) -> dict[str, Any]:
|
18
|
+
_kwargs: dict[str, Any] = {
|
19
|
+
"method": "get",
|
20
|
+
"url": f"/network/process/{pid}/ports",
|
21
|
+
}
|
22
|
+
|
23
|
+
return _kwargs
|
24
|
+
|
25
|
+
|
26
|
+
def _parse_response(
|
27
|
+
*, client: Client, response: httpx.Response
|
28
|
+
) -> Optional[Union[ErrorResponse, GetNetworkProcessPidPortsResponse200]]:
|
29
|
+
if response.status_code == 200:
|
30
|
+
response_200 = GetNetworkProcessPidPortsResponse200.from_dict(response.json())
|
31
|
+
|
32
|
+
return response_200
|
33
|
+
if response.status_code == 400:
|
34
|
+
response_400 = ErrorResponse.from_dict(response.json())
|
35
|
+
|
36
|
+
return response_400
|
37
|
+
if response.status_code == 500:
|
38
|
+
response_500 = ErrorResponse.from_dict(response.json())
|
39
|
+
|
40
|
+
return response_500
|
41
|
+
if client.raise_on_unexpected_status:
|
42
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
43
|
+
else:
|
44
|
+
return None
|
45
|
+
|
46
|
+
|
47
|
+
def _build_response(
|
48
|
+
*, client: Client, response: httpx.Response
|
49
|
+
) -> Response[Union[ErrorResponse, GetNetworkProcessPidPortsResponse200]]:
|
50
|
+
return Response(
|
51
|
+
status_code=HTTPStatus(response.status_code),
|
52
|
+
content=response.content,
|
53
|
+
headers=response.headers,
|
54
|
+
parsed=_parse_response(client=client, response=response),
|
55
|
+
)
|
56
|
+
|
57
|
+
|
58
|
+
def sync_detailed(
|
59
|
+
pid: int,
|
60
|
+
*,
|
61
|
+
client: Union[Client],
|
62
|
+
) -> Response[Union[ErrorResponse, GetNetworkProcessPidPortsResponse200]]:
|
63
|
+
"""Get open ports for a process
|
64
|
+
|
65
|
+
Get a list of all open ports for a process
|
66
|
+
|
67
|
+
Args:
|
68
|
+
pid (int):
|
69
|
+
|
70
|
+
Raises:
|
71
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
72
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
73
|
+
|
74
|
+
Returns:
|
75
|
+
Response[Union[ErrorResponse, GetNetworkProcessPidPortsResponse200]]
|
76
|
+
"""
|
77
|
+
|
78
|
+
kwargs = _get_kwargs(
|
79
|
+
pid=pid,
|
80
|
+
)
|
81
|
+
|
82
|
+
response = client.get_httpx_client().request(
|
83
|
+
**kwargs,
|
84
|
+
)
|
85
|
+
|
86
|
+
return _build_response(client=client, response=response)
|
87
|
+
|
88
|
+
|
89
|
+
def sync(
|
90
|
+
pid: int,
|
91
|
+
*,
|
92
|
+
client: Union[Client],
|
93
|
+
) -> Optional[Union[ErrorResponse, GetNetworkProcessPidPortsResponse200]]:
|
94
|
+
"""Get open ports for a process
|
95
|
+
|
96
|
+
Get a list of all open ports for a process
|
97
|
+
|
98
|
+
Args:
|
99
|
+
pid (int):
|
100
|
+
|
101
|
+
Raises:
|
102
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
103
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
104
|
+
|
105
|
+
Returns:
|
106
|
+
Union[ErrorResponse, GetNetworkProcessPidPortsResponse200]
|
107
|
+
"""
|
108
|
+
|
109
|
+
return sync_detailed(
|
110
|
+
pid=pid,
|
111
|
+
client=client,
|
112
|
+
).parsed
|
113
|
+
|
114
|
+
|
115
|
+
async def asyncio_detailed(
|
116
|
+
pid: int,
|
117
|
+
*,
|
118
|
+
client: Union[Client],
|
119
|
+
) -> Response[Union[ErrorResponse, GetNetworkProcessPidPortsResponse200]]:
|
120
|
+
"""Get open ports for a process
|
121
|
+
|
122
|
+
Get a list of all open ports for a process
|
123
|
+
|
124
|
+
Args:
|
125
|
+
pid (int):
|
126
|
+
|
127
|
+
Raises:
|
128
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
129
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
130
|
+
|
131
|
+
Returns:
|
132
|
+
Response[Union[ErrorResponse, GetNetworkProcessPidPortsResponse200]]
|
133
|
+
"""
|
134
|
+
|
135
|
+
kwargs = _get_kwargs(
|
136
|
+
pid=pid,
|
137
|
+
)
|
138
|
+
|
139
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
140
|
+
|
141
|
+
return _build_response(client=client, response=response)
|
142
|
+
|
143
|
+
|
144
|
+
async def asyncio(
|
145
|
+
pid: int,
|
146
|
+
*,
|
147
|
+
client: Union[Client],
|
148
|
+
) -> Optional[Union[ErrorResponse, GetNetworkProcessPidPortsResponse200]]:
|
149
|
+
"""Get open ports for a process
|
150
|
+
|
151
|
+
Get a list of all open ports for a process
|
152
|
+
|
153
|
+
Args:
|
154
|
+
pid (int):
|
155
|
+
|
156
|
+
Raises:
|
157
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
158
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
159
|
+
|
160
|
+
Returns:
|
161
|
+
Union[ErrorResponse, GetNetworkProcessPidPortsResponse200]
|
162
|
+
"""
|
163
|
+
|
164
|
+
return (
|
165
|
+
await asyncio_detailed(
|
166
|
+
pid=pid,
|
167
|
+
client=client,
|
168
|
+
)
|
169
|
+
).parsed
|