moru 0.1.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.
Files changed (152) hide show
  1. moru/__init__.py +174 -0
  2. moru/api/__init__.py +164 -0
  3. moru/api/client/__init__.py +8 -0
  4. moru/api/client/api/__init__.py +1 -0
  5. moru/api/client/api/sandboxes/__init__.py +1 -0
  6. moru/api/client/api/sandboxes/delete_sandboxes_sandbox_id.py +161 -0
  7. moru/api/client/api/sandboxes/get_sandboxes.py +176 -0
  8. moru/api/client/api/sandboxes/get_sandboxes_metrics.py +173 -0
  9. moru/api/client/api/sandboxes/get_sandboxes_sandbox_id.py +163 -0
  10. moru/api/client/api/sandboxes/get_sandboxes_sandbox_id_logs.py +199 -0
  11. moru/api/client/api/sandboxes/get_sandboxes_sandbox_id_metrics.py +212 -0
  12. moru/api/client/api/sandboxes/get_v2_sandboxes.py +230 -0
  13. moru/api/client/api/sandboxes/post_sandboxes.py +172 -0
  14. moru/api/client/api/sandboxes/post_sandboxes_sandbox_id_connect.py +193 -0
  15. moru/api/client/api/sandboxes/post_sandboxes_sandbox_id_pause.py +165 -0
  16. moru/api/client/api/sandboxes/post_sandboxes_sandbox_id_refreshes.py +181 -0
  17. moru/api/client/api/sandboxes/post_sandboxes_sandbox_id_resume.py +189 -0
  18. moru/api/client/api/sandboxes/post_sandboxes_sandbox_id_timeout.py +193 -0
  19. moru/api/client/api/templates/__init__.py +1 -0
  20. moru/api/client/api/templates/delete_templates_template_id.py +157 -0
  21. moru/api/client/api/templates/get_templates.py +172 -0
  22. moru/api/client/api/templates/get_templates_template_id.py +195 -0
  23. moru/api/client/api/templates/get_templates_template_id_builds_build_id_status.py +217 -0
  24. moru/api/client/api/templates/get_templates_template_id_files_hash.py +180 -0
  25. moru/api/client/api/templates/patch_templates_template_id.py +183 -0
  26. moru/api/client/api/templates/post_templates.py +172 -0
  27. moru/api/client/api/templates/post_templates_template_id.py +181 -0
  28. moru/api/client/api/templates/post_templates_template_id_builds_build_id.py +170 -0
  29. moru/api/client/api/templates/post_v2_templates.py +172 -0
  30. moru/api/client/api/templates/post_v3_templates.py +172 -0
  31. moru/api/client/api/templates/post_v_2_templates_template_id_builds_build_id.py +192 -0
  32. moru/api/client/client.py +286 -0
  33. moru/api/client/errors.py +16 -0
  34. moru/api/client/models/__init__.py +123 -0
  35. moru/api/client/models/aws_registry.py +85 -0
  36. moru/api/client/models/aws_registry_type.py +8 -0
  37. moru/api/client/models/build_log_entry.py +89 -0
  38. moru/api/client/models/build_status_reason.py +95 -0
  39. moru/api/client/models/connect_sandbox.py +59 -0
  40. moru/api/client/models/created_access_token.py +100 -0
  41. moru/api/client/models/created_team_api_key.py +166 -0
  42. moru/api/client/models/disk_metrics.py +91 -0
  43. moru/api/client/models/error.py +67 -0
  44. moru/api/client/models/gcp_registry.py +69 -0
  45. moru/api/client/models/gcp_registry_type.py +8 -0
  46. moru/api/client/models/general_registry.py +77 -0
  47. moru/api/client/models/general_registry_type.py +8 -0
  48. moru/api/client/models/identifier_masking_details.py +83 -0
  49. moru/api/client/models/listed_sandbox.py +154 -0
  50. moru/api/client/models/log_level.py +11 -0
  51. moru/api/client/models/max_team_metric.py +78 -0
  52. moru/api/client/models/mcp_type_0.py +44 -0
  53. moru/api/client/models/new_access_token.py +59 -0
  54. moru/api/client/models/new_sandbox.py +172 -0
  55. moru/api/client/models/new_team_api_key.py +59 -0
  56. moru/api/client/models/node.py +155 -0
  57. moru/api/client/models/node_detail.py +165 -0
  58. moru/api/client/models/node_metrics.py +122 -0
  59. moru/api/client/models/node_status.py +11 -0
  60. moru/api/client/models/node_status_change.py +79 -0
  61. moru/api/client/models/post_sandboxes_sandbox_id_refreshes_body.py +59 -0
  62. moru/api/client/models/post_sandboxes_sandbox_id_timeout_body.py +59 -0
  63. moru/api/client/models/resumed_sandbox.py +68 -0
  64. moru/api/client/models/sandbox.py +145 -0
  65. moru/api/client/models/sandbox_detail.py +183 -0
  66. moru/api/client/models/sandbox_log.py +70 -0
  67. moru/api/client/models/sandbox_log_entry.py +93 -0
  68. moru/api/client/models/sandbox_log_entry_fields.py +44 -0
  69. moru/api/client/models/sandbox_logs.py +91 -0
  70. moru/api/client/models/sandbox_metric.py +118 -0
  71. moru/api/client/models/sandbox_network_config.py +92 -0
  72. moru/api/client/models/sandbox_state.py +9 -0
  73. moru/api/client/models/sandboxes_with_metrics.py +59 -0
  74. moru/api/client/models/team.py +83 -0
  75. moru/api/client/models/team_api_key.py +158 -0
  76. moru/api/client/models/team_metric.py +86 -0
  77. moru/api/client/models/team_user.py +68 -0
  78. moru/api/client/models/template.py +217 -0
  79. moru/api/client/models/template_build.py +139 -0
  80. moru/api/client/models/template_build_file_upload.py +70 -0
  81. moru/api/client/models/template_build_info.py +126 -0
  82. moru/api/client/models/template_build_request.py +115 -0
  83. moru/api/client/models/template_build_request_v2.py +88 -0
  84. moru/api/client/models/template_build_request_v3.py +88 -0
  85. moru/api/client/models/template_build_start_v2.py +184 -0
  86. moru/api/client/models/template_build_status.py +11 -0
  87. moru/api/client/models/template_legacy.py +207 -0
  88. moru/api/client/models/template_request_response_v3.py +83 -0
  89. moru/api/client/models/template_step.py +91 -0
  90. moru/api/client/models/template_update_request.py +59 -0
  91. moru/api/client/models/template_with_builds.py +148 -0
  92. moru/api/client/models/update_team_api_key.py +59 -0
  93. moru/api/client/py.typed +1 -0
  94. moru/api/client/types.py +54 -0
  95. moru/api/client_async/__init__.py +50 -0
  96. moru/api/client_sync/__init__.py +52 -0
  97. moru/api/metadata.py +14 -0
  98. moru/connection_config.py +217 -0
  99. moru/envd/api.py +59 -0
  100. moru/envd/filesystem/filesystem_connect.py +193 -0
  101. moru/envd/filesystem/filesystem_pb2.py +76 -0
  102. moru/envd/filesystem/filesystem_pb2.pyi +233 -0
  103. moru/envd/process/process_connect.py +155 -0
  104. moru/envd/process/process_pb2.py +92 -0
  105. moru/envd/process/process_pb2.pyi +304 -0
  106. moru/envd/rpc.py +61 -0
  107. moru/envd/versions.py +6 -0
  108. moru/exceptions.py +95 -0
  109. moru/sandbox/commands/command_handle.py +69 -0
  110. moru/sandbox/commands/main.py +39 -0
  111. moru/sandbox/filesystem/filesystem.py +94 -0
  112. moru/sandbox/filesystem/watch_handle.py +60 -0
  113. moru/sandbox/main.py +210 -0
  114. moru/sandbox/mcp.py +1120 -0
  115. moru/sandbox/network.py +8 -0
  116. moru/sandbox/sandbox_api.py +210 -0
  117. moru/sandbox/signature.py +45 -0
  118. moru/sandbox/utils.py +34 -0
  119. moru/sandbox_async/commands/command.py +336 -0
  120. moru/sandbox_async/commands/command_handle.py +196 -0
  121. moru/sandbox_async/commands/pty.py +240 -0
  122. moru/sandbox_async/filesystem/filesystem.py +531 -0
  123. moru/sandbox_async/filesystem/watch_handle.py +62 -0
  124. moru/sandbox_async/main.py +734 -0
  125. moru/sandbox_async/paginator.py +69 -0
  126. moru/sandbox_async/sandbox_api.py +325 -0
  127. moru/sandbox_async/utils.py +7 -0
  128. moru/sandbox_sync/commands/command.py +328 -0
  129. moru/sandbox_sync/commands/command_handle.py +150 -0
  130. moru/sandbox_sync/commands/pty.py +230 -0
  131. moru/sandbox_sync/filesystem/filesystem.py +518 -0
  132. moru/sandbox_sync/filesystem/watch_handle.py +69 -0
  133. moru/sandbox_sync/main.py +726 -0
  134. moru/sandbox_sync/paginator.py +69 -0
  135. moru/sandbox_sync/sandbox_api.py +308 -0
  136. moru/template/consts.py +30 -0
  137. moru/template/dockerfile_parser.py +275 -0
  138. moru/template/logger.py +232 -0
  139. moru/template/main.py +1360 -0
  140. moru/template/readycmd.py +138 -0
  141. moru/template/types.py +105 -0
  142. moru/template/utils.py +320 -0
  143. moru/template_async/build_api.py +202 -0
  144. moru/template_async/main.py +366 -0
  145. moru/template_sync/build_api.py +199 -0
  146. moru/template_sync/main.py +371 -0
  147. moru-0.1.0.dist-info/METADATA +63 -0
  148. moru-0.1.0.dist-info/RECORD +152 -0
  149. moru-0.1.0.dist-info/WHEEL +4 -0
  150. moru-0.1.0.dist-info/licenses/LICENSE +9 -0
  151. moru_connect/__init__.py +1 -0
  152. moru_connect/client.py +493 -0
@@ -0,0 +1,212 @@
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 AuthenticatedClient, Client
8
+ from ...models.error import Error
9
+ from ...models.sandbox_metric import SandboxMetric
10
+ from ...types import UNSET, Response, Unset
11
+
12
+
13
+ def _get_kwargs(
14
+ sandbox_id: str,
15
+ *,
16
+ start: Union[Unset, int] = UNSET,
17
+ end: Union[Unset, int] = UNSET,
18
+ ) -> dict[str, Any]:
19
+ params: dict[str, Any] = {}
20
+
21
+ params["start"] = start
22
+
23
+ params["end"] = end
24
+
25
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
26
+
27
+ _kwargs: dict[str, Any] = {
28
+ "method": "get",
29
+ "url": f"/sandboxes/{sandbox_id}/metrics",
30
+ "params": params,
31
+ }
32
+
33
+ return _kwargs
34
+
35
+
36
+ def _parse_response(
37
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
38
+ ) -> Optional[Union[Error, list["SandboxMetric"]]]:
39
+ if response.status_code == 200:
40
+ response_200 = []
41
+ _response_200 = response.json()
42
+ for response_200_item_data in _response_200:
43
+ response_200_item = SandboxMetric.from_dict(response_200_item_data)
44
+
45
+ response_200.append(response_200_item)
46
+
47
+ return response_200
48
+ if response.status_code == 400:
49
+ response_400 = Error.from_dict(response.json())
50
+
51
+ return response_400
52
+ if response.status_code == 401:
53
+ response_401 = Error.from_dict(response.json())
54
+
55
+ return response_401
56
+ if response.status_code == 404:
57
+ response_404 = Error.from_dict(response.json())
58
+
59
+ return response_404
60
+ if response.status_code == 500:
61
+ response_500 = Error.from_dict(response.json())
62
+
63
+ return response_500
64
+ if client.raise_on_unexpected_status:
65
+ raise errors.UnexpectedStatus(response.status_code, response.content)
66
+ else:
67
+ return None
68
+
69
+
70
+ def _build_response(
71
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
72
+ ) -> Response[Union[Error, list["SandboxMetric"]]]:
73
+ return Response(
74
+ status_code=HTTPStatus(response.status_code),
75
+ content=response.content,
76
+ headers=response.headers,
77
+ parsed=_parse_response(client=client, response=response),
78
+ )
79
+
80
+
81
+ def sync_detailed(
82
+ sandbox_id: str,
83
+ *,
84
+ client: AuthenticatedClient,
85
+ start: Union[Unset, int] = UNSET,
86
+ end: Union[Unset, int] = UNSET,
87
+ ) -> Response[Union[Error, list["SandboxMetric"]]]:
88
+ """Get sandbox metrics
89
+
90
+ Args:
91
+ sandbox_id (str):
92
+ start (Union[Unset, int]):
93
+ end (Union[Unset, int]): Unix timestamp for the end of the interval, in seconds, for which
94
+ the metrics
95
+
96
+ Raises:
97
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
98
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
99
+
100
+ Returns:
101
+ Response[Union[Error, list['SandboxMetric']]]
102
+ """
103
+
104
+ kwargs = _get_kwargs(
105
+ sandbox_id=sandbox_id,
106
+ start=start,
107
+ end=end,
108
+ )
109
+
110
+ response = client.get_httpx_client().request(
111
+ **kwargs,
112
+ )
113
+
114
+ return _build_response(client=client, response=response)
115
+
116
+
117
+ def sync(
118
+ sandbox_id: str,
119
+ *,
120
+ client: AuthenticatedClient,
121
+ start: Union[Unset, int] = UNSET,
122
+ end: Union[Unset, int] = UNSET,
123
+ ) -> Optional[Union[Error, list["SandboxMetric"]]]:
124
+ """Get sandbox metrics
125
+
126
+ Args:
127
+ sandbox_id (str):
128
+ start (Union[Unset, int]):
129
+ end (Union[Unset, int]): Unix timestamp for the end of the interval, in seconds, for which
130
+ the metrics
131
+
132
+ Raises:
133
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
134
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
135
+
136
+ Returns:
137
+ Union[Error, list['SandboxMetric']]
138
+ """
139
+
140
+ return sync_detailed(
141
+ sandbox_id=sandbox_id,
142
+ client=client,
143
+ start=start,
144
+ end=end,
145
+ ).parsed
146
+
147
+
148
+ async def asyncio_detailed(
149
+ sandbox_id: str,
150
+ *,
151
+ client: AuthenticatedClient,
152
+ start: Union[Unset, int] = UNSET,
153
+ end: Union[Unset, int] = UNSET,
154
+ ) -> Response[Union[Error, list["SandboxMetric"]]]:
155
+ """Get sandbox metrics
156
+
157
+ Args:
158
+ sandbox_id (str):
159
+ start (Union[Unset, int]):
160
+ end (Union[Unset, int]): Unix timestamp for the end of the interval, in seconds, for which
161
+ the metrics
162
+
163
+ Raises:
164
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
165
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
166
+
167
+ Returns:
168
+ Response[Union[Error, list['SandboxMetric']]]
169
+ """
170
+
171
+ kwargs = _get_kwargs(
172
+ sandbox_id=sandbox_id,
173
+ start=start,
174
+ end=end,
175
+ )
176
+
177
+ response = await client.get_async_httpx_client().request(**kwargs)
178
+
179
+ return _build_response(client=client, response=response)
180
+
181
+
182
+ async def asyncio(
183
+ sandbox_id: str,
184
+ *,
185
+ client: AuthenticatedClient,
186
+ start: Union[Unset, int] = UNSET,
187
+ end: Union[Unset, int] = UNSET,
188
+ ) -> Optional[Union[Error, list["SandboxMetric"]]]:
189
+ """Get sandbox metrics
190
+
191
+ Args:
192
+ sandbox_id (str):
193
+ start (Union[Unset, int]):
194
+ end (Union[Unset, int]): Unix timestamp for the end of the interval, in seconds, for which
195
+ the metrics
196
+
197
+ Raises:
198
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
199
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
200
+
201
+ Returns:
202
+ Union[Error, list['SandboxMetric']]
203
+ """
204
+
205
+ return (
206
+ await asyncio_detailed(
207
+ sandbox_id=sandbox_id,
208
+ client=client,
209
+ start=start,
210
+ end=end,
211
+ )
212
+ ).parsed
@@ -0,0 +1,230 @@
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 AuthenticatedClient, Client
8
+ from ...models.error import Error
9
+ from ...models.listed_sandbox import ListedSandbox
10
+ from ...models.sandbox_state import SandboxState
11
+ from ...types import UNSET, Response, Unset
12
+
13
+
14
+ def _get_kwargs(
15
+ *,
16
+ metadata: Union[Unset, str] = UNSET,
17
+ state: Union[Unset, list[SandboxState]] = UNSET,
18
+ next_token: Union[Unset, str] = UNSET,
19
+ limit: Union[Unset, int] = 100,
20
+ ) -> dict[str, Any]:
21
+ params: dict[str, Any] = {}
22
+
23
+ params["metadata"] = metadata
24
+
25
+ json_state: Union[Unset, list[str]] = UNSET
26
+ if not isinstance(state, Unset):
27
+ json_state = []
28
+ for state_item_data in state:
29
+ state_item = state_item_data.value
30
+ json_state.append(state_item)
31
+
32
+ if not isinstance(json_state, Unset):
33
+ params["state"] = ",".join(str(item) for item in json_state)
34
+
35
+ params["nextToken"] = next_token
36
+
37
+ params["limit"] = limit
38
+
39
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
40
+
41
+ _kwargs: dict[str, Any] = {
42
+ "method": "get",
43
+ "url": "/v2/sandboxes",
44
+ "params": params,
45
+ }
46
+
47
+ return _kwargs
48
+
49
+
50
+ def _parse_response(
51
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
52
+ ) -> Optional[Union[Error, list["ListedSandbox"]]]:
53
+ if response.status_code == 200:
54
+ response_200 = []
55
+ _response_200 = response.json()
56
+ for response_200_item_data in _response_200:
57
+ response_200_item = ListedSandbox.from_dict(response_200_item_data)
58
+
59
+ response_200.append(response_200_item)
60
+
61
+ return response_200
62
+ if response.status_code == 400:
63
+ response_400 = Error.from_dict(response.json())
64
+
65
+ return response_400
66
+ if response.status_code == 401:
67
+ response_401 = Error.from_dict(response.json())
68
+
69
+ return response_401
70
+ if response.status_code == 500:
71
+ response_500 = Error.from_dict(response.json())
72
+
73
+ return response_500
74
+ if client.raise_on_unexpected_status:
75
+ raise errors.UnexpectedStatus(response.status_code, response.content)
76
+ else:
77
+ return None
78
+
79
+
80
+ def _build_response(
81
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
82
+ ) -> Response[Union[Error, list["ListedSandbox"]]]:
83
+ return Response(
84
+ status_code=HTTPStatus(response.status_code),
85
+ content=response.content,
86
+ headers=response.headers,
87
+ parsed=_parse_response(client=client, response=response),
88
+ )
89
+
90
+
91
+ def sync_detailed(
92
+ *,
93
+ client: AuthenticatedClient,
94
+ metadata: Union[Unset, str] = UNSET,
95
+ state: Union[Unset, list[SandboxState]] = UNSET,
96
+ next_token: Union[Unset, str] = UNSET,
97
+ limit: Union[Unset, int] = 100,
98
+ ) -> Response[Union[Error, list["ListedSandbox"]]]:
99
+ """List all sandboxes
100
+
101
+ Args:
102
+ metadata (Union[Unset, str]):
103
+ state (Union[Unset, list[SandboxState]]):
104
+ next_token (Union[Unset, str]):
105
+ limit (Union[Unset, int]): Default: 100.
106
+
107
+ Raises:
108
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
109
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
110
+
111
+ Returns:
112
+ Response[Union[Error, list['ListedSandbox']]]
113
+ """
114
+
115
+ kwargs = _get_kwargs(
116
+ metadata=metadata,
117
+ state=state,
118
+ next_token=next_token,
119
+ limit=limit,
120
+ )
121
+
122
+ response = client.get_httpx_client().request(
123
+ **kwargs,
124
+ )
125
+
126
+ return _build_response(client=client, response=response)
127
+
128
+
129
+ def sync(
130
+ *,
131
+ client: AuthenticatedClient,
132
+ metadata: Union[Unset, str] = UNSET,
133
+ state: Union[Unset, list[SandboxState]] = UNSET,
134
+ next_token: Union[Unset, str] = UNSET,
135
+ limit: Union[Unset, int] = 100,
136
+ ) -> Optional[Union[Error, list["ListedSandbox"]]]:
137
+ """List all sandboxes
138
+
139
+ Args:
140
+ metadata (Union[Unset, str]):
141
+ state (Union[Unset, list[SandboxState]]):
142
+ next_token (Union[Unset, str]):
143
+ limit (Union[Unset, int]): Default: 100.
144
+
145
+ Raises:
146
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
147
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
148
+
149
+ Returns:
150
+ Union[Error, list['ListedSandbox']]
151
+ """
152
+
153
+ return sync_detailed(
154
+ client=client,
155
+ metadata=metadata,
156
+ state=state,
157
+ next_token=next_token,
158
+ limit=limit,
159
+ ).parsed
160
+
161
+
162
+ async def asyncio_detailed(
163
+ *,
164
+ client: AuthenticatedClient,
165
+ metadata: Union[Unset, str] = UNSET,
166
+ state: Union[Unset, list[SandboxState]] = UNSET,
167
+ next_token: Union[Unset, str] = UNSET,
168
+ limit: Union[Unset, int] = 100,
169
+ ) -> Response[Union[Error, list["ListedSandbox"]]]:
170
+ """List all sandboxes
171
+
172
+ Args:
173
+ metadata (Union[Unset, str]):
174
+ state (Union[Unset, list[SandboxState]]):
175
+ next_token (Union[Unset, str]):
176
+ limit (Union[Unset, int]): Default: 100.
177
+
178
+ Raises:
179
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
180
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
181
+
182
+ Returns:
183
+ Response[Union[Error, list['ListedSandbox']]]
184
+ """
185
+
186
+ kwargs = _get_kwargs(
187
+ metadata=metadata,
188
+ state=state,
189
+ next_token=next_token,
190
+ limit=limit,
191
+ )
192
+
193
+ response = await client.get_async_httpx_client().request(**kwargs)
194
+
195
+ return _build_response(client=client, response=response)
196
+
197
+
198
+ async def asyncio(
199
+ *,
200
+ client: AuthenticatedClient,
201
+ metadata: Union[Unset, str] = UNSET,
202
+ state: Union[Unset, list[SandboxState]] = UNSET,
203
+ next_token: Union[Unset, str] = UNSET,
204
+ limit: Union[Unset, int] = 100,
205
+ ) -> Optional[Union[Error, list["ListedSandbox"]]]:
206
+ """List all sandboxes
207
+
208
+ Args:
209
+ metadata (Union[Unset, str]):
210
+ state (Union[Unset, list[SandboxState]]):
211
+ next_token (Union[Unset, str]):
212
+ limit (Union[Unset, int]): Default: 100.
213
+
214
+ Raises:
215
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
216
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
217
+
218
+ Returns:
219
+ Union[Error, list['ListedSandbox']]
220
+ """
221
+
222
+ return (
223
+ await asyncio_detailed(
224
+ client=client,
225
+ metadata=metadata,
226
+ state=state,
227
+ next_token=next_token,
228
+ limit=limit,
229
+ )
230
+ ).parsed
@@ -0,0 +1,172 @@
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 AuthenticatedClient, Client
8
+ from ...models.error import Error
9
+ from ...models.new_sandbox import NewSandbox
10
+ from ...models.sandbox import Sandbox
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ *,
16
+ body: NewSandbox,
17
+ ) -> dict[str, Any]:
18
+ headers: dict[str, Any] = {}
19
+
20
+ _kwargs: dict[str, Any] = {
21
+ "method": "post",
22
+ "url": "/sandboxes",
23
+ }
24
+
25
+ _kwargs["json"] = body.to_dict()
26
+
27
+ headers["Content-Type"] = "application/json"
28
+
29
+ _kwargs["headers"] = headers
30
+ return _kwargs
31
+
32
+
33
+ def _parse_response(
34
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
35
+ ) -> Optional[Union[Error, Sandbox]]:
36
+ if response.status_code == 201:
37
+ response_201 = Sandbox.from_dict(response.json())
38
+
39
+ return response_201
40
+ if response.status_code == 400:
41
+ response_400 = Error.from_dict(response.json())
42
+
43
+ return response_400
44
+ if response.status_code == 401:
45
+ response_401 = Error.from_dict(response.json())
46
+
47
+ return response_401
48
+ if response.status_code == 500:
49
+ response_500 = Error.from_dict(response.json())
50
+
51
+ return response_500
52
+ if client.raise_on_unexpected_status:
53
+ raise errors.UnexpectedStatus(response.status_code, response.content)
54
+ else:
55
+ return None
56
+
57
+
58
+ def _build_response(
59
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
60
+ ) -> Response[Union[Error, Sandbox]]:
61
+ return Response(
62
+ status_code=HTTPStatus(response.status_code),
63
+ content=response.content,
64
+ headers=response.headers,
65
+ parsed=_parse_response(client=client, response=response),
66
+ )
67
+
68
+
69
+ def sync_detailed(
70
+ *,
71
+ client: AuthenticatedClient,
72
+ body: NewSandbox,
73
+ ) -> Response[Union[Error, Sandbox]]:
74
+ """Create a sandbox from the template
75
+
76
+ Args:
77
+ body (NewSandbox):
78
+
79
+ Raises:
80
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
81
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
82
+
83
+ Returns:
84
+ Response[Union[Error, Sandbox]]
85
+ """
86
+
87
+ kwargs = _get_kwargs(
88
+ body=body,
89
+ )
90
+
91
+ response = client.get_httpx_client().request(
92
+ **kwargs,
93
+ )
94
+
95
+ return _build_response(client=client, response=response)
96
+
97
+
98
+ def sync(
99
+ *,
100
+ client: AuthenticatedClient,
101
+ body: NewSandbox,
102
+ ) -> Optional[Union[Error, Sandbox]]:
103
+ """Create a sandbox from the template
104
+
105
+ Args:
106
+ body (NewSandbox):
107
+
108
+ Raises:
109
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
110
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
111
+
112
+ Returns:
113
+ Union[Error, Sandbox]
114
+ """
115
+
116
+ return sync_detailed(
117
+ client=client,
118
+ body=body,
119
+ ).parsed
120
+
121
+
122
+ async def asyncio_detailed(
123
+ *,
124
+ client: AuthenticatedClient,
125
+ body: NewSandbox,
126
+ ) -> Response[Union[Error, Sandbox]]:
127
+ """Create a sandbox from the template
128
+
129
+ Args:
130
+ body (NewSandbox):
131
+
132
+ Raises:
133
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
134
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
135
+
136
+ Returns:
137
+ Response[Union[Error, Sandbox]]
138
+ """
139
+
140
+ kwargs = _get_kwargs(
141
+ body=body,
142
+ )
143
+
144
+ response = await client.get_async_httpx_client().request(**kwargs)
145
+
146
+ return _build_response(client=client, response=response)
147
+
148
+
149
+ async def asyncio(
150
+ *,
151
+ client: AuthenticatedClient,
152
+ body: NewSandbox,
153
+ ) -> Optional[Union[Error, Sandbox]]:
154
+ """Create a sandbox from the template
155
+
156
+ Args:
157
+ body (NewSandbox):
158
+
159
+ Raises:
160
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
161
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
162
+
163
+ Returns:
164
+ Union[Error, Sandbox]
165
+ """
166
+
167
+ return (
168
+ await asyncio_detailed(
169
+ client=client,
170
+ body=body,
171
+ )
172
+ ).parsed