solari-runloop-compat 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 (45) hide show
  1. solari_runloop/__init__.py +42 -0
  2. solari_runloop/_branding.py +10 -0
  3. solari_runloop/_client.py +107 -0
  4. solari_runloop/_config.py +57 -0
  5. solari_runloop/_context.py +91 -0
  6. solari_runloop/_dockerfile.py +348 -0
  7. solari_runloop/_exceptions.py +122 -0
  8. solari_runloop/_gateway.py +1048 -0
  9. solari_runloop/_guest/solari-run.sh +14 -0
  10. solari_runloop/_guest/solari_extract.py +101 -0
  11. solari_runloop/_guest/solari_sizecheck.py +14 -0
  12. solari_runloop/_loop.py +54 -0
  13. solari_runloop/_mapping.py +322 -0
  14. solari_runloop/_models.py +13 -0
  15. solari_runloop/_resources.py +416 -0
  16. solari_runloop/_sync.py +76 -0
  17. solari_runloop/lib/__init__.py +0 -0
  18. solari_runloop/lib/polling.py +118 -0
  19. solari_runloop/pagination.py +66 -0
  20. solari_runloop/sdk.py +594 -0
  21. solari_runloop/types/__init__.py +17 -0
  22. solari_runloop/types/blueprint_build_log.py +16 -0
  23. solari_runloop/types/blueprint_build_logs_list_view.py +16 -0
  24. solari_runloop/types/blueprint_build_parameters.py +123 -0
  25. solari_runloop/types/blueprint_view.py +97 -0
  26. solari_runloop/types/devbox_async_execution_detail_view.py +46 -0
  27. solari_runloop/types/devbox_execution_detail_view.py +24 -0
  28. solari_runloop/types/devbox_snapshot_list_view.py +17 -0
  29. solari_runloop/types/devbox_snapshot_view.py +33 -0
  30. solari_runloop/types/devbox_view.py +176 -0
  31. solari_runloop/types/devboxes/__init__.py +0 -0
  32. solari_runloop/types/devboxes/devbox_logs_list_view.py +39 -0
  33. solari_runloop/types/secret_view.py +23 -0
  34. solari_runloop/types/shared/__init__.py +0 -0
  35. solari_runloop/types/shared/after_idle.py +15 -0
  36. solari_runloop/types/shared/code_mount_parameters.py +30 -0
  37. solari_runloop/types/shared/launch_parameters.py +104 -0
  38. solari_runloop/types/shared/lifecycle_configuration.py +38 -0
  39. solari_runloop/types/shared/lifecycle_hooks.py +28 -0
  40. solari_runloop/types/shared/resume_triggers.py +17 -0
  41. solari_runloop/types/tunnel_view.py +47 -0
  42. solari_runloop_compat-0.1.0.dist-info/METADATA +47 -0
  43. solari_runloop_compat-0.1.0.dist-info/RECORD +45 -0
  44. solari_runloop_compat-0.1.0.dist-info/WHEEL +4 -0
  45. solari_runloop_compat-0.1.0.dist-info/licenses/NOTICE +25 -0
@@ -0,0 +1,122 @@
1
+ """Runloop's exception hierarchy, same names and attributes where a Solari call can raise them.
2
+
3
+ Solari gateway errors are translated by :func:`solari_runloop._mapping.map_error`; the original
4
+ ``{code, error, message, retryable}`` JSON stays available as ``.body``.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import Any, Optional
10
+
11
+ __all__ = [
12
+ "RunloopError",
13
+ "APIError",
14
+ "APIResponseValidationError",
15
+ "APIStatusError",
16
+ "APIConnectionError",
17
+ "APITimeoutError",
18
+ "BadRequestError",
19
+ "AuthenticationError",
20
+ "PermissionDeniedError",
21
+ "NotFoundError",
22
+ "ConflictError",
23
+ "UnprocessableEntityError",
24
+ "RateLimitError",
25
+ "InternalServerError",
26
+ "SolariCompatUnsupported",
27
+ ]
28
+
29
+
30
+ class RunloopError(Exception):
31
+ pass
32
+
33
+
34
+ class APIError(RunloopError):
35
+ message: str
36
+ request: Optional[Any]
37
+ body: Optional[object]
38
+
39
+ def __init__(self, message: str, request: Optional[Any] = None, *, body: Optional[object] = None) -> None:
40
+ super().__init__(message)
41
+ self.message = message
42
+ self.request = request
43
+ self.body = body
44
+
45
+
46
+ class APIResponseValidationError(APIError):
47
+ def __init__(self, message: Optional[str] = None, *, body: Optional[object] = None, response: Optional[Any] = None) -> None:
48
+ super().__init__(message or "Data returned by API invalid for expected schema.", None, body=body)
49
+ self.response = response
50
+ self.status_code: Optional[int] = getattr(response, "status_code", None)
51
+
52
+
53
+ class APIStatusError(APIError):
54
+ """A 4xx/5xx from the Solari gateway."""
55
+
56
+ status_code: int
57
+
58
+ def __init__(
59
+ self,
60
+ message: str,
61
+ *,
62
+ status_code: Optional[int] = None,
63
+ body: Optional[object] = None,
64
+ response: Optional[Any] = None,
65
+ ) -> None:
66
+ super().__init__(message, None, body=body)
67
+ self.response = response
68
+ if status_code is not None:
69
+ self.status_code = status_code
70
+
71
+
72
+ class APIConnectionError(APIError):
73
+ def __init__(self, message: str = "Connection error.", request: Optional[Any] = None) -> None:
74
+ super().__init__(message, request, body=None)
75
+
76
+
77
+ class APITimeoutError(APIConnectionError):
78
+ def __init__(self, request: Optional[Any] = None) -> None:
79
+ super().__init__("Request timed out.", request)
80
+
81
+
82
+ class BadRequestError(APIStatusError):
83
+ status_code = 400
84
+
85
+
86
+ class AuthenticationError(APIStatusError):
87
+ status_code = 401
88
+
89
+
90
+ class PermissionDeniedError(APIStatusError):
91
+ status_code = 403
92
+
93
+
94
+ class NotFoundError(APIStatusError):
95
+ status_code = 404
96
+
97
+
98
+ class ConflictError(APIStatusError):
99
+ status_code = 409
100
+
101
+
102
+ class UnprocessableEntityError(APIStatusError):
103
+ status_code = 422
104
+
105
+
106
+ class RateLimitError(APIStatusError):
107
+ status_code = 429
108
+
109
+
110
+ class InternalServerError(APIStatusError):
111
+ pass
112
+
113
+
114
+ class SolariCompatUnsupported(APIError):
115
+ """The Runloop feature has no Solari equivalent yet (see COMPAT.md). Never silently ignored."""
116
+
117
+ def __init__(self, feature: str, hint: str = "") -> None:
118
+ msg = f"{feature} is not supported by the Solari compatibility layer yet."
119
+ if hint:
120
+ msg += f" {hint}"
121
+ super().__init__(msg, None, body=None)
122
+ self.feature = feature