blaxel 0.1.9rc37__py3-none-any.whl → 0.1.10__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.
Files changed (80) hide show
  1. blaxel/authentication/__init__.py +11 -2
  2. blaxel/client/api/compute/create_sandbox_preview.py +179 -0
  3. blaxel/client/api/compute/create_sandbox_preview_token.py +192 -0
  4. blaxel/client/api/compute/delete_sandbox_preview.py +167 -0
  5. blaxel/client/api/compute/delete_sandbox_preview_token.py +180 -0
  6. blaxel/client/api/compute/get_sandbox_preview.py +167 -0
  7. blaxel/client/api/compute/list_sandbox_preview_tokens.py +172 -0
  8. blaxel/client/api/compute/list_sandbox_previews.py +159 -0
  9. blaxel/client/api/compute/update_sandbox_preview.py +192 -0
  10. blaxel/client/api/integrations/get_integration.py +64 -7
  11. blaxel/client/api/workspaces/check_workspace_availability.py +165 -0
  12. blaxel/client/models/__init__.py +32 -2
  13. blaxel/client/models/check_workspace_availability_body.py +60 -0
  14. blaxel/client/models/delete_sandbox_preview_token_response_200.py +60 -0
  15. blaxel/client/models/integration.py +197 -0
  16. blaxel/client/models/integration_additional_infos.py +45 -0
  17. blaxel/client/models/integration_endpoint.py +143 -0
  18. blaxel/client/models/integration_endpoint_token.py +79 -0
  19. blaxel/client/models/integration_endpoints.py +61 -0
  20. blaxel/client/models/integration_headers.py +45 -0
  21. blaxel/client/models/integration_organization.py +88 -0
  22. blaxel/client/models/integration_query_params.py +45 -0
  23. blaxel/client/models/metrics.py +9 -0
  24. blaxel/client/models/preview.py +96 -0
  25. blaxel/client/models/preview_metadata.py +133 -0
  26. blaxel/client/models/preview_spec.py +79 -0
  27. blaxel/client/models/preview_token.py +96 -0
  28. blaxel/client/models/preview_token_metadata.py +97 -0
  29. blaxel/client/models/preview_token_spec.py +88 -0
  30. blaxel/common/autoload.py +1 -0
  31. blaxel/common/internal.py +5 -5
  32. blaxel/sandbox/base.py +68 -0
  33. blaxel/sandbox/client/__init__.py +8 -0
  34. blaxel/sandbox/client/api/__init__.py +1 -0
  35. blaxel/sandbox/client/api/filesystem/__init__.py +0 -0
  36. blaxel/sandbox/client/api/filesystem/delete_filesystem_path.py +184 -0
  37. blaxel/sandbox/client/api/filesystem/get_filesystem_path.py +184 -0
  38. blaxel/sandbox/client/api/filesystem/put_filesystem_path.py +189 -0
  39. blaxel/sandbox/client/api/network/__init__.py +0 -0
  40. blaxel/sandbox/client/api/network/delete_network_process_pid_monitor.py +169 -0
  41. blaxel/sandbox/client/api/network/get_network_process_pid_ports.py +169 -0
  42. blaxel/sandbox/client/api/network/post_network_process_pid_monitor.py +195 -0
  43. blaxel/sandbox/client/api/process/__init__.py +0 -0
  44. blaxel/sandbox/client/api/process/delete_process_identifier.py +163 -0
  45. blaxel/sandbox/client/api/process/delete_process_identifier_kill.py +189 -0
  46. blaxel/sandbox/client/api/process/get_process.py +135 -0
  47. blaxel/sandbox/client/api/process/get_process_identifier.py +159 -0
  48. blaxel/sandbox/client/api/process/get_process_identifier_logs.py +188 -0
  49. blaxel/sandbox/client/api/process/get_process_identifier_logs_stream.py +190 -0
  50. blaxel/sandbox/client/api/process/post_process.py +176 -0
  51. blaxel/sandbox/client/client.py +162 -0
  52. blaxel/sandbox/client/errors.py +16 -0
  53. blaxel/sandbox/client/models/__init__.py +41 -0
  54. blaxel/sandbox/client/models/delete_network_process_pid_monitor_response_200.py +45 -0
  55. blaxel/sandbox/client/models/directory.py +112 -0
  56. blaxel/sandbox/client/models/error_response.py +60 -0
  57. blaxel/sandbox/client/models/file.py +105 -0
  58. blaxel/sandbox/client/models/file_request.py +78 -0
  59. blaxel/sandbox/client/models/file_with_content.py +114 -0
  60. blaxel/sandbox/client/models/get_network_process_pid_ports_response_200.py +45 -0
  61. blaxel/sandbox/client/models/get_process_identifier_logs_response_200.py +45 -0
  62. blaxel/sandbox/client/models/get_process_identifier_logs_stream_response_200.py +45 -0
  63. blaxel/sandbox/client/models/port_monitor_request.py +60 -0
  64. blaxel/sandbox/client/models/post_network_process_pid_monitor_response_200.py +45 -0
  65. blaxel/sandbox/client/models/process_kill_request.py +60 -0
  66. blaxel/sandbox/client/models/process_request.py +118 -0
  67. blaxel/sandbox/client/models/process_response.py +123 -0
  68. blaxel/sandbox/client/models/subdirectory.py +60 -0
  69. blaxel/sandbox/client/models/success_response.py +69 -0
  70. blaxel/sandbox/client/py.typed +1 -0
  71. blaxel/sandbox/client/types.py +46 -0
  72. blaxel/sandbox/filesystem.py +104 -0
  73. blaxel/sandbox/process.py +57 -0
  74. blaxel/sandbox/sandbox.py +92 -0
  75. blaxel/tools/__init__.py +1 -1
  76. {blaxel-0.1.9rc37.dist-info → blaxel-0.1.10.dist-info}/METADATA +1 -1
  77. {blaxel-0.1.9rc37.dist-info → blaxel-0.1.10.dist-info}/RECORD +79 -12
  78. blaxel/client/models/sandboxes.py +0 -129
  79. {blaxel-0.1.9rc37.dist-info → blaxel-0.1.10.dist-info}/WHEEL +0 -0
  80. {blaxel-0.1.9rc37.dist-info → blaxel-0.1.10.dist-info}/licenses/LICENSE +0 -0
@@ -19,16 +19,25 @@ def get_credentials() -> Optional[CredentialsType]:
19
19
  Returns:
20
20
  Optional[CredentialsType]: The credentials or None if not found
21
21
  """
22
+ def get_workspace():
23
+ if os.environ.get("BL_WORKSPACE"):
24
+ return os.environ.get("BL_WORKSPACE")
25
+ home_dir = Path.home()
26
+ config_path = home_dir / '.blaxel' / 'config.yaml'
27
+ with open(config_path, encoding='utf-8') as f:
28
+ config_json = yaml.safe_load(f)
29
+ return config_json.get("context", {}).get("workspace")
30
+
22
31
  if os.environ.get("BL_API_KEY"):
23
32
  return CredentialsType(
24
33
  api_key=os.environ.get("BL_API_KEY"),
25
- workspace=os.environ.get("BL_WORKSPACE")
34
+ workspace=get_workspace()
26
35
  )
27
36
 
28
37
  if os.environ.get("BL_CLIENT_CREDENTIALS"):
29
38
  return CredentialsType(
30
39
  client_credentials=os.environ.get("BL_CLIENT_CREDENTIALS"),
31
- workspace=os.environ.get("BL_WORKSPACE")
40
+ workspace=get_workspace()
32
41
  )
33
42
 
34
43
  try:
@@ -0,0 +1,179 @@
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.preview import Preview
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs(
13
+ sandbox_name: str,
14
+ *,
15
+ body: Preview,
16
+ ) -> dict[str, Any]:
17
+ headers: dict[str, Any] = {}
18
+
19
+ _kwargs: dict[str, Any] = {
20
+ "method": "post",
21
+ "url": f"/sandboxes/{sandbox_name}/previews",
22
+ }
23
+
24
+ if type(body) == dict:
25
+ _body = body
26
+ else:
27
+ _body = body.to_dict()
28
+
29
+ _kwargs["json"] = _body
30
+ headers["Content-Type"] = "application/json"
31
+
32
+ _kwargs["headers"] = headers
33
+ return _kwargs
34
+
35
+
36
+ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Preview]:
37
+ if response.status_code == 200:
38
+ response_200 = Preview.from_dict(response.json())
39
+
40
+ return response_200
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(*, client: Client, response: httpx.Response) -> Response[Preview]:
48
+ return Response(
49
+ status_code=HTTPStatus(response.status_code),
50
+ content=response.content,
51
+ headers=response.headers,
52
+ parsed=_parse_response(client=client, response=response),
53
+ )
54
+
55
+
56
+ def sync_detailed(
57
+ sandbox_name: str,
58
+ *,
59
+ client: Union[Client],
60
+ body: Preview,
61
+ ) -> Response[Preview]:
62
+ """Create Sandbox Preview
63
+
64
+ Create a preview
65
+
66
+ Args:
67
+ sandbox_name (str):
68
+ body (Preview): Preview of a Resource
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[Preview]
76
+ """
77
+
78
+ kwargs = _get_kwargs(
79
+ sandbox_name=sandbox_name,
80
+ body=body,
81
+ )
82
+
83
+ response = client.get_httpx_client().request(
84
+ **kwargs,
85
+ )
86
+
87
+ return _build_response(client=client, response=response)
88
+
89
+
90
+ def sync(
91
+ sandbox_name: str,
92
+ *,
93
+ client: Union[Client],
94
+ body: Preview,
95
+ ) -> Optional[Preview]:
96
+ """Create Sandbox Preview
97
+
98
+ Create a preview
99
+
100
+ Args:
101
+ sandbox_name (str):
102
+ body (Preview): Preview of a Resource
103
+
104
+ Raises:
105
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
106
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
107
+
108
+ Returns:
109
+ Preview
110
+ """
111
+
112
+ return sync_detailed(
113
+ sandbox_name=sandbox_name,
114
+ client=client,
115
+ body=body,
116
+ ).parsed
117
+
118
+
119
+ async def asyncio_detailed(
120
+ sandbox_name: str,
121
+ *,
122
+ client: Union[Client],
123
+ body: Preview,
124
+ ) -> Response[Preview]:
125
+ """Create Sandbox Preview
126
+
127
+ Create a preview
128
+
129
+ Args:
130
+ sandbox_name (str):
131
+ body (Preview): Preview of a Resource
132
+
133
+ Raises:
134
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
135
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
136
+
137
+ Returns:
138
+ Response[Preview]
139
+ """
140
+
141
+ kwargs = _get_kwargs(
142
+ sandbox_name=sandbox_name,
143
+ body=body,
144
+ )
145
+
146
+ response = await client.get_async_httpx_client().request(**kwargs)
147
+
148
+ return _build_response(client=client, response=response)
149
+
150
+
151
+ async def asyncio(
152
+ sandbox_name: str,
153
+ *,
154
+ client: Union[Client],
155
+ body: Preview,
156
+ ) -> Optional[Preview]:
157
+ """Create Sandbox Preview
158
+
159
+ Create a preview
160
+
161
+ Args:
162
+ sandbox_name (str):
163
+ body (Preview): Preview of a Resource
164
+
165
+ Raises:
166
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
167
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
168
+
169
+ Returns:
170
+ Preview
171
+ """
172
+
173
+ return (
174
+ await asyncio_detailed(
175
+ sandbox_name=sandbox_name,
176
+ client=client,
177
+ body=body,
178
+ )
179
+ ).parsed
@@ -0,0 +1,192 @@
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.preview_token import PreviewToken
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs(
13
+ sandbox_name: str,
14
+ preview_name: str,
15
+ *,
16
+ body: PreviewToken,
17
+ ) -> dict[str, Any]:
18
+ headers: dict[str, Any] = {}
19
+
20
+ _kwargs: dict[str, Any] = {
21
+ "method": "post",
22
+ "url": f"/sandboxes/{sandbox_name}/previews/{preview_name}/tokens",
23
+ }
24
+
25
+ if type(body) == dict:
26
+ _body = body
27
+ else:
28
+ _body = body.to_dict()
29
+
30
+ _kwargs["json"] = _body
31
+ headers["Content-Type"] = "application/json"
32
+
33
+ _kwargs["headers"] = headers
34
+ return _kwargs
35
+
36
+
37
+ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[PreviewToken]:
38
+ if response.status_code == 200:
39
+ response_200 = PreviewToken.from_dict(response.json())
40
+
41
+ return response_200
42
+ if client.raise_on_unexpected_status:
43
+ raise errors.UnexpectedStatus(response.status_code, response.content)
44
+ else:
45
+ return None
46
+
47
+
48
+ def _build_response(*, client: Client, response: httpx.Response) -> Response[PreviewToken]:
49
+ return Response(
50
+ status_code=HTTPStatus(response.status_code),
51
+ content=response.content,
52
+ headers=response.headers,
53
+ parsed=_parse_response(client=client, response=response),
54
+ )
55
+
56
+
57
+ def sync_detailed(
58
+ sandbox_name: str,
59
+ preview_name: str,
60
+ *,
61
+ client: Union[Client],
62
+ body: PreviewToken,
63
+ ) -> Response[PreviewToken]:
64
+ """Create token for Sandbox Preview
65
+
66
+ Creates a token for a Sandbox Preview.
67
+
68
+ Args:
69
+ sandbox_name (str):
70
+ preview_name (str):
71
+ body (PreviewToken): Token for a Preview
72
+
73
+ Raises:
74
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
75
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
76
+
77
+ Returns:
78
+ Response[PreviewToken]
79
+ """
80
+
81
+ kwargs = _get_kwargs(
82
+ sandbox_name=sandbox_name,
83
+ preview_name=preview_name,
84
+ body=body,
85
+ )
86
+
87
+ response = client.get_httpx_client().request(
88
+ **kwargs,
89
+ )
90
+
91
+ return _build_response(client=client, response=response)
92
+
93
+
94
+ def sync(
95
+ sandbox_name: str,
96
+ preview_name: str,
97
+ *,
98
+ client: Union[Client],
99
+ body: PreviewToken,
100
+ ) -> Optional[PreviewToken]:
101
+ """Create token for Sandbox Preview
102
+
103
+ Creates a token for a Sandbox Preview.
104
+
105
+ Args:
106
+ sandbox_name (str):
107
+ preview_name (str):
108
+ body (PreviewToken): Token for a Preview
109
+
110
+ Raises:
111
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
112
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
113
+
114
+ Returns:
115
+ PreviewToken
116
+ """
117
+
118
+ return sync_detailed(
119
+ sandbox_name=sandbox_name,
120
+ preview_name=preview_name,
121
+ client=client,
122
+ body=body,
123
+ ).parsed
124
+
125
+
126
+ async def asyncio_detailed(
127
+ sandbox_name: str,
128
+ preview_name: str,
129
+ *,
130
+ client: Union[Client],
131
+ body: PreviewToken,
132
+ ) -> Response[PreviewToken]:
133
+ """Create token for Sandbox Preview
134
+
135
+ Creates a token for a Sandbox Preview.
136
+
137
+ Args:
138
+ sandbox_name (str):
139
+ preview_name (str):
140
+ body (PreviewToken): Token for a Preview
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[PreviewToken]
148
+ """
149
+
150
+ kwargs = _get_kwargs(
151
+ sandbox_name=sandbox_name,
152
+ preview_name=preview_name,
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
+ sandbox_name: str,
163
+ preview_name: str,
164
+ *,
165
+ client: Union[Client],
166
+ body: PreviewToken,
167
+ ) -> Optional[PreviewToken]:
168
+ """Create token for Sandbox Preview
169
+
170
+ Creates a token for a Sandbox Preview.
171
+
172
+ Args:
173
+ sandbox_name (str):
174
+ preview_name (str):
175
+ body (PreviewToken): Token for a Preview
176
+
177
+ Raises:
178
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
179
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
180
+
181
+ Returns:
182
+ PreviewToken
183
+ """
184
+
185
+ return (
186
+ await asyncio_detailed(
187
+ sandbox_name=sandbox_name,
188
+ preview_name=preview_name,
189
+ client=client,
190
+ body=body,
191
+ )
192
+ ).parsed
@@ -0,0 +1,167 @@
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.preview import Preview
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs(
13
+ sandbox_name: str,
14
+ preview_name: str,
15
+ ) -> dict[str, Any]:
16
+ _kwargs: dict[str, Any] = {
17
+ "method": "delete",
18
+ "url": f"/sandboxes/{sandbox_name}/previews/{preview_name}",
19
+ }
20
+
21
+ return _kwargs
22
+
23
+
24
+ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Preview]:
25
+ if response.status_code == 200:
26
+ response_200 = Preview.from_dict(response.json())
27
+
28
+ return response_200
29
+ if client.raise_on_unexpected_status:
30
+ raise errors.UnexpectedStatus(response.status_code, response.content)
31
+ else:
32
+ return None
33
+
34
+
35
+ def _build_response(*, client: Client, response: httpx.Response) -> Response[Preview]:
36
+ return Response(
37
+ status_code=HTTPStatus(response.status_code),
38
+ content=response.content,
39
+ headers=response.headers,
40
+ parsed=_parse_response(client=client, response=response),
41
+ )
42
+
43
+
44
+ def sync_detailed(
45
+ sandbox_name: str,
46
+ preview_name: str,
47
+ *,
48
+ client: Union[Client],
49
+ ) -> Response[Preview]:
50
+ """Delete Sandbox Preview
51
+
52
+ Deletes a Sandbox Preview by name.
53
+
54
+ Args:
55
+ sandbox_name (str):
56
+ preview_name (str):
57
+
58
+ Raises:
59
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
60
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
61
+
62
+ Returns:
63
+ Response[Preview]
64
+ """
65
+
66
+ kwargs = _get_kwargs(
67
+ sandbox_name=sandbox_name,
68
+ preview_name=preview_name,
69
+ )
70
+
71
+ response = client.get_httpx_client().request(
72
+ **kwargs,
73
+ )
74
+
75
+ return _build_response(client=client, response=response)
76
+
77
+
78
+ def sync(
79
+ sandbox_name: str,
80
+ preview_name: str,
81
+ *,
82
+ client: Union[Client],
83
+ ) -> Optional[Preview]:
84
+ """Delete Sandbox Preview
85
+
86
+ Deletes a Sandbox Preview by name.
87
+
88
+ Args:
89
+ sandbox_name (str):
90
+ preview_name (str):
91
+
92
+ Raises:
93
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
94
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
95
+
96
+ Returns:
97
+ Preview
98
+ """
99
+
100
+ return sync_detailed(
101
+ sandbox_name=sandbox_name,
102
+ preview_name=preview_name,
103
+ client=client,
104
+ ).parsed
105
+
106
+
107
+ async def asyncio_detailed(
108
+ sandbox_name: str,
109
+ preview_name: str,
110
+ *,
111
+ client: Union[Client],
112
+ ) -> Response[Preview]:
113
+ """Delete Sandbox Preview
114
+
115
+ Deletes a Sandbox Preview by name.
116
+
117
+ Args:
118
+ sandbox_name (str):
119
+ preview_name (str):
120
+
121
+ Raises:
122
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
123
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
124
+
125
+ Returns:
126
+ Response[Preview]
127
+ """
128
+
129
+ kwargs = _get_kwargs(
130
+ sandbox_name=sandbox_name,
131
+ preview_name=preview_name,
132
+ )
133
+
134
+ response = await client.get_async_httpx_client().request(**kwargs)
135
+
136
+ return _build_response(client=client, response=response)
137
+
138
+
139
+ async def asyncio(
140
+ sandbox_name: str,
141
+ preview_name: str,
142
+ *,
143
+ client: Union[Client],
144
+ ) -> Optional[Preview]:
145
+ """Delete Sandbox Preview
146
+
147
+ Deletes a Sandbox Preview by name.
148
+
149
+ Args:
150
+ sandbox_name (str):
151
+ preview_name (str):
152
+
153
+ Raises:
154
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
155
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
156
+
157
+ Returns:
158
+ Preview
159
+ """
160
+
161
+ return (
162
+ await asyncio_detailed(
163
+ sandbox_name=sandbox_name,
164
+ preview_name=preview_name,
165
+ client=client,
166
+ )
167
+ ).parsed