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,183 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union, cast
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.error import Error
9
+ from ...models.template_update_request import TemplateUpdateRequest
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs(
14
+ template_id: str,
15
+ *,
16
+ body: TemplateUpdateRequest,
17
+ ) -> dict[str, Any]:
18
+ headers: dict[str, Any] = {}
19
+
20
+ _kwargs: dict[str, Any] = {
21
+ "method": "patch",
22
+ "url": f"/templates/{template_id}",
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[Any, Error]]:
36
+ if response.status_code == 200:
37
+ response_200 = cast(Any, None)
38
+ return response_200
39
+ if response.status_code == 400:
40
+ response_400 = Error.from_dict(response.json())
41
+
42
+ return response_400
43
+ if response.status_code == 401:
44
+ response_401 = Error.from_dict(response.json())
45
+
46
+ return response_401
47
+ if response.status_code == 500:
48
+ response_500 = Error.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(
58
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
59
+ ) -> Response[Union[Any, Error]]:
60
+ return Response(
61
+ status_code=HTTPStatus(response.status_code),
62
+ content=response.content,
63
+ headers=response.headers,
64
+ parsed=_parse_response(client=client, response=response),
65
+ )
66
+
67
+
68
+ def sync_detailed(
69
+ template_id: str,
70
+ *,
71
+ client: AuthenticatedClient,
72
+ body: TemplateUpdateRequest,
73
+ ) -> Response[Union[Any, Error]]:
74
+ """Update template
75
+
76
+ Args:
77
+ template_id (str):
78
+ body (TemplateUpdateRequest):
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[Any, Error]]
86
+ """
87
+
88
+ kwargs = _get_kwargs(
89
+ template_id=template_id,
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
+ template_id: str,
102
+ *,
103
+ client: AuthenticatedClient,
104
+ body: TemplateUpdateRequest,
105
+ ) -> Optional[Union[Any, Error]]:
106
+ """Update template
107
+
108
+ Args:
109
+ template_id (str):
110
+ body (TemplateUpdateRequest):
111
+
112
+ Raises:
113
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
114
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
115
+
116
+ Returns:
117
+ Union[Any, Error]
118
+ """
119
+
120
+ return sync_detailed(
121
+ template_id=template_id,
122
+ client=client,
123
+ body=body,
124
+ ).parsed
125
+
126
+
127
+ async def asyncio_detailed(
128
+ template_id: str,
129
+ *,
130
+ client: AuthenticatedClient,
131
+ body: TemplateUpdateRequest,
132
+ ) -> Response[Union[Any, Error]]:
133
+ """Update template
134
+
135
+ Args:
136
+ template_id (str):
137
+ body (TemplateUpdateRequest):
138
+
139
+ Raises:
140
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
141
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
142
+
143
+ Returns:
144
+ Response[Union[Any, Error]]
145
+ """
146
+
147
+ kwargs = _get_kwargs(
148
+ template_id=template_id,
149
+ body=body,
150
+ )
151
+
152
+ response = await client.get_async_httpx_client().request(**kwargs)
153
+
154
+ return _build_response(client=client, response=response)
155
+
156
+
157
+ async def asyncio(
158
+ template_id: str,
159
+ *,
160
+ client: AuthenticatedClient,
161
+ body: TemplateUpdateRequest,
162
+ ) -> Optional[Union[Any, Error]]:
163
+ """Update template
164
+
165
+ Args:
166
+ template_id (str):
167
+ body (TemplateUpdateRequest):
168
+
169
+ Raises:
170
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
171
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
172
+
173
+ Returns:
174
+ Union[Any, Error]
175
+ """
176
+
177
+ return (
178
+ await asyncio_detailed(
179
+ template_id=template_id,
180
+ client=client,
181
+ body=body,
182
+ )
183
+ ).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.template_build_request import TemplateBuildRequest
10
+ from ...models.template_legacy import TemplateLegacy
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ *,
16
+ body: TemplateBuildRequest,
17
+ ) -> dict[str, Any]:
18
+ headers: dict[str, Any] = {}
19
+
20
+ _kwargs: dict[str, Any] = {
21
+ "method": "post",
22
+ "url": "/templates",
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, TemplateLegacy]]:
36
+ if response.status_code == 202:
37
+ response_202 = TemplateLegacy.from_dict(response.json())
38
+
39
+ return response_202
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, TemplateLegacy]]:
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: TemplateBuildRequest,
73
+ ) -> Response[Union[Error, TemplateLegacy]]:
74
+ """Create a new template
75
+
76
+ Args:
77
+ body (TemplateBuildRequest):
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, TemplateLegacy]]
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: TemplateBuildRequest,
102
+ ) -> Optional[Union[Error, TemplateLegacy]]:
103
+ """Create a new template
104
+
105
+ Args:
106
+ body (TemplateBuildRequest):
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, TemplateLegacy]
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: TemplateBuildRequest,
126
+ ) -> Response[Union[Error, TemplateLegacy]]:
127
+ """Create a new template
128
+
129
+ Args:
130
+ body (TemplateBuildRequest):
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, TemplateLegacy]]
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: TemplateBuildRequest,
153
+ ) -> Optional[Union[Error, TemplateLegacy]]:
154
+ """Create a new template
155
+
156
+ Args:
157
+ body (TemplateBuildRequest):
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, TemplateLegacy]
165
+ """
166
+
167
+ return (
168
+ await asyncio_detailed(
169
+ client=client,
170
+ body=body,
171
+ )
172
+ ).parsed
@@ -0,0 +1,181 @@
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.template_build_request import TemplateBuildRequest
10
+ from ...models.template_legacy import TemplateLegacy
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ template_id: str,
16
+ *,
17
+ body: TemplateBuildRequest,
18
+ ) -> dict[str, Any]:
19
+ headers: dict[str, Any] = {}
20
+
21
+ _kwargs: dict[str, Any] = {
22
+ "method": "post",
23
+ "url": f"/templates/{template_id}",
24
+ }
25
+
26
+ _kwargs["json"] = body.to_dict()
27
+
28
+ headers["Content-Type"] = "application/json"
29
+
30
+ _kwargs["headers"] = headers
31
+ return _kwargs
32
+
33
+
34
+ def _parse_response(
35
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
36
+ ) -> Optional[Union[Error, TemplateLegacy]]:
37
+ if response.status_code == 202:
38
+ response_202 = TemplateLegacy.from_dict(response.json())
39
+
40
+ return response_202
41
+ if response.status_code == 401:
42
+ response_401 = Error.from_dict(response.json())
43
+
44
+ return response_401
45
+ if response.status_code == 500:
46
+ response_500 = Error.from_dict(response.json())
47
+
48
+ return response_500
49
+ if client.raise_on_unexpected_status:
50
+ raise errors.UnexpectedStatus(response.status_code, response.content)
51
+ else:
52
+ return None
53
+
54
+
55
+ def _build_response(
56
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
57
+ ) -> Response[Union[Error, TemplateLegacy]]:
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
+ template_id: str,
68
+ *,
69
+ client: AuthenticatedClient,
70
+ body: TemplateBuildRequest,
71
+ ) -> Response[Union[Error, TemplateLegacy]]:
72
+ """Rebuild an template
73
+
74
+ Args:
75
+ template_id (str):
76
+ body (TemplateBuildRequest):
77
+
78
+ Raises:
79
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
80
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
81
+
82
+ Returns:
83
+ Response[Union[Error, TemplateLegacy]]
84
+ """
85
+
86
+ kwargs = _get_kwargs(
87
+ template_id=template_id,
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
+ template_id: str,
100
+ *,
101
+ client: AuthenticatedClient,
102
+ body: TemplateBuildRequest,
103
+ ) -> Optional[Union[Error, TemplateLegacy]]:
104
+ """Rebuild an template
105
+
106
+ Args:
107
+ template_id (str):
108
+ body (TemplateBuildRequest):
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
+ Union[Error, TemplateLegacy]
116
+ """
117
+
118
+ return sync_detailed(
119
+ template_id=template_id,
120
+ client=client,
121
+ body=body,
122
+ ).parsed
123
+
124
+
125
+ async def asyncio_detailed(
126
+ template_id: str,
127
+ *,
128
+ client: AuthenticatedClient,
129
+ body: TemplateBuildRequest,
130
+ ) -> Response[Union[Error, TemplateLegacy]]:
131
+ """Rebuild an template
132
+
133
+ Args:
134
+ template_id (str):
135
+ body (TemplateBuildRequest):
136
+
137
+ Raises:
138
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
139
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
140
+
141
+ Returns:
142
+ Response[Union[Error, TemplateLegacy]]
143
+ """
144
+
145
+ kwargs = _get_kwargs(
146
+ template_id=template_id,
147
+ body=body,
148
+ )
149
+
150
+ response = await client.get_async_httpx_client().request(**kwargs)
151
+
152
+ return _build_response(client=client, response=response)
153
+
154
+
155
+ async def asyncio(
156
+ template_id: str,
157
+ *,
158
+ client: AuthenticatedClient,
159
+ body: TemplateBuildRequest,
160
+ ) -> Optional[Union[Error, TemplateLegacy]]:
161
+ """Rebuild an template
162
+
163
+ Args:
164
+ template_id (str):
165
+ body (TemplateBuildRequest):
166
+
167
+ Raises:
168
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
169
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
170
+
171
+ Returns:
172
+ Union[Error, TemplateLegacy]
173
+ """
174
+
175
+ return (
176
+ await asyncio_detailed(
177
+ template_id=template_id,
178
+ client=client,
179
+ body=body,
180
+ )
181
+ ).parsed
@@ -0,0 +1,170 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union, cast
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.error import Error
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs(
13
+ template_id: str,
14
+ build_id: str,
15
+ ) -> dict[str, Any]:
16
+ _kwargs: dict[str, Any] = {
17
+ "method": "post",
18
+ "url": f"/templates/{template_id}/builds/{build_id}",
19
+ }
20
+
21
+ return _kwargs
22
+
23
+
24
+ def _parse_response(
25
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
26
+ ) -> Optional[Union[Any, Error]]:
27
+ if response.status_code == 202:
28
+ response_202 = cast(Any, None)
29
+ return response_202
30
+ if response.status_code == 401:
31
+ response_401 = Error.from_dict(response.json())
32
+
33
+ return response_401
34
+ if response.status_code == 500:
35
+ response_500 = Error.from_dict(response.json())
36
+
37
+ return response_500
38
+ if client.raise_on_unexpected_status:
39
+ raise errors.UnexpectedStatus(response.status_code, response.content)
40
+ else:
41
+ return None
42
+
43
+
44
+ def _build_response(
45
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
46
+ ) -> Response[Union[Any, Error]]:
47
+ return Response(
48
+ status_code=HTTPStatus(response.status_code),
49
+ content=response.content,
50
+ headers=response.headers,
51
+ parsed=_parse_response(client=client, response=response),
52
+ )
53
+
54
+
55
+ def sync_detailed(
56
+ template_id: str,
57
+ build_id: str,
58
+ *,
59
+ client: AuthenticatedClient,
60
+ ) -> Response[Union[Any, Error]]:
61
+ """Start the build
62
+
63
+ Args:
64
+ template_id (str):
65
+ build_id (str):
66
+
67
+ Raises:
68
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
69
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
70
+
71
+ Returns:
72
+ Response[Union[Any, Error]]
73
+ """
74
+
75
+ kwargs = _get_kwargs(
76
+ template_id=template_id,
77
+ build_id=build_id,
78
+ )
79
+
80
+ response = client.get_httpx_client().request(
81
+ **kwargs,
82
+ )
83
+
84
+ return _build_response(client=client, response=response)
85
+
86
+
87
+ def sync(
88
+ template_id: str,
89
+ build_id: str,
90
+ *,
91
+ client: AuthenticatedClient,
92
+ ) -> Optional[Union[Any, Error]]:
93
+ """Start the build
94
+
95
+ Args:
96
+ template_id (str):
97
+ build_id (str):
98
+
99
+ Raises:
100
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
101
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
102
+
103
+ Returns:
104
+ Union[Any, Error]
105
+ """
106
+
107
+ return sync_detailed(
108
+ template_id=template_id,
109
+ build_id=build_id,
110
+ client=client,
111
+ ).parsed
112
+
113
+
114
+ async def asyncio_detailed(
115
+ template_id: str,
116
+ build_id: str,
117
+ *,
118
+ client: AuthenticatedClient,
119
+ ) -> Response[Union[Any, Error]]:
120
+ """Start the build
121
+
122
+ Args:
123
+ template_id (str):
124
+ build_id (str):
125
+
126
+ Raises:
127
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
128
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
129
+
130
+ Returns:
131
+ Response[Union[Any, Error]]
132
+ """
133
+
134
+ kwargs = _get_kwargs(
135
+ template_id=template_id,
136
+ build_id=build_id,
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
+ template_id: str,
146
+ build_id: str,
147
+ *,
148
+ client: AuthenticatedClient,
149
+ ) -> Optional[Union[Any, Error]]:
150
+ """Start the build
151
+
152
+ Args:
153
+ template_id (str):
154
+ build_id (str):
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[Any, Error]
162
+ """
163
+
164
+ return (
165
+ await asyncio_detailed(
166
+ template_id=template_id,
167
+ build_id=build_id,
168
+ client=client,
169
+ )
170
+ ).parsed