loopix-sdk 2.30.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 (238) hide show
  1. loopix/__init__.py +260 -0
  2. loopix/api/__init__.py +287 -0
  3. loopix/api/client/__init__.py +8 -0
  4. loopix/api/client/api/__init__.py +1 -0
  5. loopix/api/client/api/sandboxes/__init__.py +1 -0
  6. loopix/api/client/api/sandboxes/delete_sandboxes_sandbox_id.py +161 -0
  7. loopix/api/client/api/sandboxes/get_sandboxes.py +176 -0
  8. loopix/api/client/api/sandboxes/get_sandboxes_metrics.py +173 -0
  9. loopix/api/client/api/sandboxes/get_sandboxes_sandbox_id.py +163 -0
  10. loopix/api/client/api/sandboxes/get_sandboxes_sandbox_id_logs.py +199 -0
  11. loopix/api/client/api/sandboxes/get_sandboxes_sandbox_id_metrics.py +212 -0
  12. loopix/api/client/api/sandboxes/get_v2_sandboxes.py +230 -0
  13. loopix/api/client/api/sandboxes/get_v_2_sandboxes_sandbox_id_logs.py +254 -0
  14. loopix/api/client/api/sandboxes/post_sandboxes.py +172 -0
  15. loopix/api/client/api/sandboxes/post_sandboxes_sandbox_id_connect.py +193 -0
  16. loopix/api/client/api/sandboxes/post_sandboxes_sandbox_id_pause.py +187 -0
  17. loopix/api/client/api/sandboxes/post_sandboxes_sandbox_id_refreshes.py +181 -0
  18. loopix/api/client/api/sandboxes/post_sandboxes_sandbox_id_resume.py +189 -0
  19. loopix/api/client/api/sandboxes/post_sandboxes_sandbox_id_snapshots.py +195 -0
  20. loopix/api/client/api/sandboxes/post_sandboxes_sandbox_id_timeout.py +193 -0
  21. loopix/api/client/api/sandboxes/put_sandboxes_sandbox_id_network.py +199 -0
  22. loopix/api/client/api/snapshots/__init__.py +1 -0
  23. loopix/api/client/api/snapshots/get_snapshots.py +202 -0
  24. loopix/api/client/api/tags/__init__.py +1 -0
  25. loopix/api/client/api/tags/delete_templates_tags.py +174 -0
  26. loopix/api/client/api/tags/get_templates_template_id_tags.py +172 -0
  27. loopix/api/client/api/tags/post_templates_tags.py +176 -0
  28. loopix/api/client/api/templates/__init__.py +1 -0
  29. loopix/api/client/api/templates/delete_templates_template_id.py +157 -0
  30. loopix/api/client/api/templates/get_templates.py +172 -0
  31. loopix/api/client/api/templates/get_templates_aliases_alias.py +167 -0
  32. loopix/api/client/api/templates/get_templates_template_id.py +195 -0
  33. loopix/api/client/api/templates/get_templates_template_id_builds_build_id_logs.py +272 -0
  34. loopix/api/client/api/templates/get_templates_template_id_builds_build_id_status.py +232 -0
  35. loopix/api/client/api/templates/get_templates_template_id_files_hash.py +180 -0
  36. loopix/api/client/api/templates/patch_templates_template_id.py +183 -0
  37. loopix/api/client/api/templates/patch_v_2_templates_template_id.py +185 -0
  38. loopix/api/client/api/templates/post_templates.py +172 -0
  39. loopix/api/client/api/templates/post_templates_template_id.py +181 -0
  40. loopix/api/client/api/templates/post_templates_template_id_builds_build_id.py +170 -0
  41. loopix/api/client/api/templates/post_v2_templates.py +172 -0
  42. loopix/api/client/api/templates/post_v3_templates.py +176 -0
  43. loopix/api/client/api/templates/post_v_2_templates_template_id_builds_build_id.py +192 -0
  44. loopix/api/client/api/volumes/__init__.py +1 -0
  45. loopix/api/client/api/volumes/delete_volumes_volume_id.py +161 -0
  46. loopix/api/client/api/volumes/get_volumes.py +140 -0
  47. loopix/api/client/api/volumes/get_volumes_volume_id.py +163 -0
  48. loopix/api/client/api/volumes/post_volumes.py +172 -0
  49. loopix/api/client/client.py +286 -0
  50. loopix/api/client/errors.py +16 -0
  51. loopix/api/client/models/__init__.py +185 -0
  52. loopix/api/client/models/admin_build_cancel_result.py +67 -0
  53. loopix/api/client/models/admin_sandbox_kill_result.py +67 -0
  54. loopix/api/client/models/assign_template_tags_request.py +67 -0
  55. loopix/api/client/models/assigned_template_tags.py +68 -0
  56. loopix/api/client/models/aws_registry.py +85 -0
  57. loopix/api/client/models/aws_registry_type.py +8 -0
  58. loopix/api/client/models/build_log_entry.py +89 -0
  59. loopix/api/client/models/build_status_reason.py +95 -0
  60. loopix/api/client/models/connect_sandbox.py +59 -0
  61. loopix/api/client/models/created_access_token.py +100 -0
  62. loopix/api/client/models/created_team_api_key.py +166 -0
  63. loopix/api/client/models/delete_template_tags_request.py +67 -0
  64. loopix/api/client/models/disk_metrics.py +91 -0
  65. loopix/api/client/models/error.py +67 -0
  66. loopix/api/client/models/gcp_registry.py +69 -0
  67. loopix/api/client/models/gcp_registry_type.py +8 -0
  68. loopix/api/client/models/general_registry.py +77 -0
  69. loopix/api/client/models/general_registry_type.py +8 -0
  70. loopix/api/client/models/identifier_masking_details.py +83 -0
  71. loopix/api/client/models/listed_sandbox.py +179 -0
  72. loopix/api/client/models/log_level.py +11 -0
  73. loopix/api/client/models/logs_direction.py +9 -0
  74. loopix/api/client/models/logs_source.py +9 -0
  75. loopix/api/client/models/machine_info.py +83 -0
  76. loopix/api/client/models/max_team_metric.py +78 -0
  77. loopix/api/client/models/mcp_type_0.py +44 -0
  78. loopix/api/client/models/new_access_token.py +59 -0
  79. loopix/api/client/models/new_sandbox.py +224 -0
  80. loopix/api/client/models/new_team_api_key.py +59 -0
  81. loopix/api/client/models/new_volume.py +59 -0
  82. loopix/api/client/models/node.py +160 -0
  83. loopix/api/client/models/node_detail.py +160 -0
  84. loopix/api/client/models/node_metrics.py +122 -0
  85. loopix/api/client/models/node_status.py +12 -0
  86. loopix/api/client/models/node_status_change.py +82 -0
  87. loopix/api/client/models/post_sandboxes_sandbox_id_refreshes_body.py +59 -0
  88. loopix/api/client/models/post_sandboxes_sandbox_id_snapshots_body.py +60 -0
  89. loopix/api/client/models/post_sandboxes_sandbox_id_timeout_body.py +59 -0
  90. loopix/api/client/models/resumed_sandbox.py +68 -0
  91. loopix/api/client/models/sandbox.py +145 -0
  92. loopix/api/client/models/sandbox_auto_resume_config.py +60 -0
  93. loopix/api/client/models/sandbox_detail.py +267 -0
  94. loopix/api/client/models/sandbox_lifecycle.py +70 -0
  95. loopix/api/client/models/sandbox_log.py +70 -0
  96. loopix/api/client/models/sandbox_log_entry.py +93 -0
  97. loopix/api/client/models/sandbox_log_entry_fields.py +44 -0
  98. loopix/api/client/models/sandbox_logs.py +91 -0
  99. loopix/api/client/models/sandbox_logs_v2_response.py +73 -0
  100. loopix/api/client/models/sandbox_metric.py +126 -0
  101. loopix/api/client/models/sandbox_network_config.py +118 -0
  102. loopix/api/client/models/sandbox_network_config_rules.py +72 -0
  103. loopix/api/client/models/sandbox_network_rule.py +74 -0
  104. loopix/api/client/models/sandbox_network_transform.py +79 -0
  105. loopix/api/client/models/sandbox_network_transform_headers.py +47 -0
  106. loopix/api/client/models/sandbox_network_update_config.py +114 -0
  107. loopix/api/client/models/sandbox_network_update_config_rules.py +71 -0
  108. loopix/api/client/models/sandbox_on_timeout.py +9 -0
  109. loopix/api/client/models/sandbox_pause_request.py +62 -0
  110. loopix/api/client/models/sandbox_state.py +9 -0
  111. loopix/api/client/models/sandbox_volume_mount.py +67 -0
  112. loopix/api/client/models/sandboxes_with_metrics.py +59 -0
  113. loopix/api/client/models/snapshot_info.py +70 -0
  114. loopix/api/client/models/team.py +83 -0
  115. loopix/api/client/models/team_api_key.py +158 -0
  116. loopix/api/client/models/team_metric.py +86 -0
  117. loopix/api/client/models/team_user.py +75 -0
  118. loopix/api/client/models/template.py +225 -0
  119. loopix/api/client/models/template_alias_response.py +67 -0
  120. loopix/api/client/models/template_build.py +139 -0
  121. loopix/api/client/models/template_build_file_upload.py +70 -0
  122. loopix/api/client/models/template_build_info.py +126 -0
  123. loopix/api/client/models/template_build_logs_response.py +73 -0
  124. loopix/api/client/models/template_build_request.py +115 -0
  125. loopix/api/client/models/template_build_request_v2.py +88 -0
  126. loopix/api/client/models/template_build_request_v3.py +107 -0
  127. loopix/api/client/models/template_build_start_v2.py +184 -0
  128. loopix/api/client/models/template_build_status.py +11 -0
  129. loopix/api/client/models/template_legacy.py +207 -0
  130. loopix/api/client/models/template_request_response_v3.py +99 -0
  131. loopix/api/client/models/template_step.py +91 -0
  132. loopix/api/client/models/template_tag.py +78 -0
  133. loopix/api/client/models/template_update_request.py +59 -0
  134. loopix/api/client/models/template_update_response.py +59 -0
  135. loopix/api/client/models/template_with_builds.py +156 -0
  136. loopix/api/client/models/update_team_api_key.py +59 -0
  137. loopix/api/client/models/volume.py +67 -0
  138. loopix/api/client/models/volume_and_token.py +75 -0
  139. loopix/api/client/models/volume_token.py +59 -0
  140. loopix/api/client/py.typed +1 -0
  141. loopix/api/client/types.py +54 -0
  142. loopix/api/client_async/__init__.py +74 -0
  143. loopix/api/client_sync/__init__.py +73 -0
  144. loopix/api/metadata.py +14 -0
  145. loopix/connection_config.py +309 -0
  146. loopix/envd/api.py +170 -0
  147. loopix/envd/filesystem/filesystem_connect.py +193 -0
  148. loopix/envd/filesystem/filesystem_pb2.py +80 -0
  149. loopix/envd/filesystem/filesystem_pb2.pyi +272 -0
  150. loopix/envd/process/process_connect.py +174 -0
  151. loopix/envd/process/process_pb2.py +96 -0
  152. loopix/envd/process/process_pb2.pyi +316 -0
  153. loopix/envd/rpc.py +139 -0
  154. loopix/envd/versions.py +11 -0
  155. loopix/exceptions.py +133 -0
  156. loopix/io_utils.py +57 -0
  157. loopix/paginator.py +52 -0
  158. loopix/py.typed +0 -0
  159. loopix/sandbox/_git/__init__.py +85 -0
  160. loopix/sandbox/_git/args.py +363 -0
  161. loopix/sandbox/_git/auth.py +132 -0
  162. loopix/sandbox/_git/config.py +32 -0
  163. loopix/sandbox/_git/parse.py +222 -0
  164. loopix/sandbox/_git/types.py +149 -0
  165. loopix/sandbox/commands/command_handle.py +69 -0
  166. loopix/sandbox/commands/main.py +39 -0
  167. loopix/sandbox/filesystem/filesystem.py +337 -0
  168. loopix/sandbox/filesystem/watch_handle.py +70 -0
  169. loopix/sandbox/main.py +227 -0
  170. loopix/sandbox/mcp.py +1949 -0
  171. loopix/sandbox/network.py +8 -0
  172. loopix/sandbox/sandbox_api.py +624 -0
  173. loopix/sandbox/signature.py +47 -0
  174. loopix/sandbox/utils.py +34 -0
  175. loopix/sandbox_async/commands/command.py +396 -0
  176. loopix/sandbox_async/commands/command_handle.py +298 -0
  177. loopix/sandbox_async/commands/pty.py +257 -0
  178. loopix/sandbox_async/filesystem/filesystem.py +720 -0
  179. loopix/sandbox_async/filesystem/watch_handle.py +97 -0
  180. loopix/sandbox_async/git.py +1100 -0
  181. loopix/sandbox_async/main.py +987 -0
  182. loopix/sandbox_async/paginator.py +140 -0
  183. loopix/sandbox_async/sandbox_api.py +504 -0
  184. loopix/sandbox_async/utils.py +7 -0
  185. loopix/sandbox_domains.py +5 -0
  186. loopix/sandbox_sync/commands/command.py +420 -0
  187. loopix/sandbox_sync/commands/command_handle.py +239 -0
  188. loopix/sandbox_sync/commands/pty.py +279 -0
  189. loopix/sandbox_sync/filesystem/filesystem.py +710 -0
  190. loopix/sandbox_sync/filesystem/watch_handle.py +102 -0
  191. loopix/sandbox_sync/git.py +1077 -0
  192. loopix/sandbox_sync/main.py +975 -0
  193. loopix/sandbox_sync/paginator.py +140 -0
  194. loopix/sandbox_sync/sandbox_api.py +491 -0
  195. loopix/template/consts.py +45 -0
  196. loopix/template/dockerfile_parser.py +286 -0
  197. loopix/template/logger.py +232 -0
  198. loopix/template/main.py +1368 -0
  199. loopix/template/readycmd.py +144 -0
  200. loopix/template/types.py +194 -0
  201. loopix/template/utils.py +426 -0
  202. loopix/template_async/build_api.py +419 -0
  203. loopix/template_async/main.py +528 -0
  204. loopix/template_sync/build_api.py +409 -0
  205. loopix/template_sync/main.py +529 -0
  206. loopix/volume/client/__init__.py +8 -0
  207. loopix/volume/client/api/__init__.py +1 -0
  208. loopix/volume/client/api/volumes/__init__.py +1 -0
  209. loopix/volume/client/api/volumes/delete_volumecontent_volume_id_path.py +174 -0
  210. loopix/volume/client/api/volumes/get_volumecontent_volume_id_dir.py +204 -0
  211. loopix/volume/client/api/volumes/get_volumecontent_volume_id_file.py +179 -0
  212. loopix/volume/client/api/volumes/get_volumecontent_volume_id_path.py +176 -0
  213. loopix/volume/client/api/volumes/patch_volumecontent_volume_id_path.py +203 -0
  214. loopix/volume/client/api/volumes/post_volumecontent_volume_id_dir.py +239 -0
  215. loopix/volume/client/api/volumes/put_volumecontent_volume_id_file.py +259 -0
  216. loopix/volume/client/client.py +286 -0
  217. loopix/volume/client/errors.py +16 -0
  218. loopix/volume/client/models/__init__.py +13 -0
  219. loopix/volume/client/models/error.py +67 -0
  220. loopix/volume/client/models/patch_volumecontent_volume_id_path_body.py +77 -0
  221. loopix/volume/client/models/volume_entry_stat.py +145 -0
  222. loopix/volume/client/models/volume_entry_stat_type.py +11 -0
  223. loopix/volume/client/py.typed +1 -0
  224. loopix/volume/client/types.py +54 -0
  225. loopix/volume/client_async/__init__.py +88 -0
  226. loopix/volume/client_sync/__init__.py +80 -0
  227. loopix/volume/connection_config.py +145 -0
  228. loopix/volume/types.py +62 -0
  229. loopix/volume/utils.py +52 -0
  230. loopix/volume/volume_async.py +639 -0
  231. loopix/volume/volume_sync.py +639 -0
  232. loopix_connect/__init__.py +1 -0
  233. loopix_connect/client.py +534 -0
  234. loopix_connect/py.typed +0 -0
  235. loopix_sdk-2.30.0.dist-info/METADATA +98 -0
  236. loopix_sdk-2.30.0.dist-info/RECORD +238 -0
  237. loopix_sdk-2.30.0.dist-info/WHEEL +4 -0
  238. loopix_sdk-2.30.0.dist-info/licenses/LICENSE +9 -0
@@ -0,0 +1,286 @@
1
+ import ssl
2
+ from typing import Any, Optional, Union
3
+
4
+ import httpx
5
+ from attrs import define, evolve, field
6
+
7
+
8
+ @define
9
+ class Client:
10
+ """A class for keeping track of data related to the API
11
+
12
+ The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
13
+
14
+ ``base_url``: The base URL for the API, all requests are made to a relative path to this URL
15
+
16
+ ``cookies``: A dictionary of cookies to be sent with every request
17
+
18
+ ``headers``: A dictionary of headers to be sent with every request
19
+
20
+ ``timeout``: The maximum amount of a time a request can take. API functions will raise
21
+ httpx.TimeoutException if this is exceeded.
22
+
23
+ ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
24
+ but can be set to False for testing purposes.
25
+
26
+ ``follow_redirects``: Whether or not to follow redirects. Default value is False.
27
+
28
+ ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
29
+
30
+
31
+ Attributes:
32
+ raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
33
+ status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
34
+ argument to the constructor.
35
+ """
36
+
37
+ raise_on_unexpected_status: bool = field(default=False, kw_only=True)
38
+ _base_url: str = field(alias="base_url")
39
+ _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
40
+ _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
41
+ _timeout: Optional[httpx.Timeout] = field(
42
+ default=None, kw_only=True, alias="timeout"
43
+ )
44
+ _verify_ssl: Union[str, bool, ssl.SSLContext] = field(
45
+ default=True, kw_only=True, alias="verify_ssl"
46
+ )
47
+ _follow_redirects: bool = field(
48
+ default=False, kw_only=True, alias="follow_redirects"
49
+ )
50
+ _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
51
+ _client: Optional[httpx.Client] = field(default=None, init=False)
52
+ _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
53
+
54
+ def with_headers(self, headers: dict[str, str]) -> "Client":
55
+ """Get a new client matching this one with additional headers"""
56
+ if self._client is not None:
57
+ self._client.headers.update(headers)
58
+ if self._async_client is not None:
59
+ self._async_client.headers.update(headers)
60
+ return evolve(self, headers={**self._headers, **headers})
61
+
62
+ def with_cookies(self, cookies: dict[str, str]) -> "Client":
63
+ """Get a new client matching this one with additional cookies"""
64
+ if self._client is not None:
65
+ self._client.cookies.update(cookies)
66
+ if self._async_client is not None:
67
+ self._async_client.cookies.update(cookies)
68
+ return evolve(self, cookies={**self._cookies, **cookies})
69
+
70
+ def with_timeout(self, timeout: httpx.Timeout) -> "Client":
71
+ """Get a new client matching this one with a new timeout (in seconds)"""
72
+ if self._client is not None:
73
+ self._client.timeout = timeout
74
+ if self._async_client is not None:
75
+ self._async_client.timeout = timeout
76
+ return evolve(self, timeout=timeout)
77
+
78
+ def set_httpx_client(self, client: httpx.Client) -> "Client":
79
+ """Manually set the underlying httpx.Client
80
+
81
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
82
+ """
83
+ self._client = client
84
+ return self
85
+
86
+ def get_httpx_client(self) -> httpx.Client:
87
+ """Get the underlying httpx.Client, constructing a new one if not previously set"""
88
+ if self._client is None:
89
+ self._client = httpx.Client(
90
+ base_url=self._base_url,
91
+ cookies=self._cookies,
92
+ headers=self._headers,
93
+ timeout=self._timeout,
94
+ verify=self._verify_ssl,
95
+ follow_redirects=self._follow_redirects,
96
+ **self._httpx_args,
97
+ )
98
+ return self._client
99
+
100
+ def __enter__(self) -> "Client":
101
+ """Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
102
+ self.get_httpx_client().__enter__()
103
+ return self
104
+
105
+ def __exit__(self, *args: Any, **kwargs: Any) -> None:
106
+ """Exit a context manager for internal httpx.Client (see httpx docs)"""
107
+ self.get_httpx_client().__exit__(*args, **kwargs)
108
+
109
+ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client":
110
+ """Manually the underlying httpx.AsyncClient
111
+
112
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
113
+ """
114
+ self._async_client = async_client
115
+ return self
116
+
117
+ def get_async_httpx_client(self) -> httpx.AsyncClient:
118
+ """Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
119
+ if self._async_client is None:
120
+ self._async_client = httpx.AsyncClient(
121
+ base_url=self._base_url,
122
+ cookies=self._cookies,
123
+ headers=self._headers,
124
+ timeout=self._timeout,
125
+ verify=self._verify_ssl,
126
+ follow_redirects=self._follow_redirects,
127
+ **self._httpx_args,
128
+ )
129
+ return self._async_client
130
+
131
+ async def __aenter__(self) -> "Client":
132
+ """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
133
+ await self.get_async_httpx_client().__aenter__()
134
+ return self
135
+
136
+ async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
137
+ """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
138
+ await self.get_async_httpx_client().__aexit__(*args, **kwargs)
139
+
140
+
141
+ @define
142
+ class AuthenticatedClient:
143
+ """A Client which has been authenticated for use on secured endpoints
144
+
145
+ The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
146
+
147
+ ``base_url``: The base URL for the API, all requests are made to a relative path to this URL
148
+
149
+ ``cookies``: A dictionary of cookies to be sent with every request
150
+
151
+ ``headers``: A dictionary of headers to be sent with every request
152
+
153
+ ``timeout``: The maximum amount of a time a request can take. API functions will raise
154
+ httpx.TimeoutException if this is exceeded.
155
+
156
+ ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
157
+ but can be set to False for testing purposes.
158
+
159
+ ``follow_redirects``: Whether or not to follow redirects. Default value is False.
160
+
161
+ ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
162
+
163
+
164
+ Attributes:
165
+ raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
166
+ status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
167
+ argument to the constructor.
168
+ token: The token to use for authentication
169
+ prefix: The prefix to use for the Authorization header
170
+ auth_header_name: The name of the Authorization header
171
+ """
172
+
173
+ raise_on_unexpected_status: bool = field(default=False, kw_only=True)
174
+ _base_url: str = field(alias="base_url")
175
+ _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
176
+ _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
177
+ _timeout: Optional[httpx.Timeout] = field(
178
+ default=None, kw_only=True, alias="timeout"
179
+ )
180
+ _verify_ssl: Union[str, bool, ssl.SSLContext] = field(
181
+ default=True, kw_only=True, alias="verify_ssl"
182
+ )
183
+ _follow_redirects: bool = field(
184
+ default=False, kw_only=True, alias="follow_redirects"
185
+ )
186
+ _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
187
+ _client: Optional[httpx.Client] = field(default=None, init=False)
188
+ _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
189
+
190
+ token: str
191
+ prefix: str = "Bearer"
192
+ auth_header_name: str = "Authorization"
193
+
194
+ def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
195
+ """Get a new client matching this one with additional headers"""
196
+ if self._client is not None:
197
+ self._client.headers.update(headers)
198
+ if self._async_client is not None:
199
+ self._async_client.headers.update(headers)
200
+ return evolve(self, headers={**self._headers, **headers})
201
+
202
+ def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
203
+ """Get a new client matching this one with additional cookies"""
204
+ if self._client is not None:
205
+ self._client.cookies.update(cookies)
206
+ if self._async_client is not None:
207
+ self._async_client.cookies.update(cookies)
208
+ return evolve(self, cookies={**self._cookies, **cookies})
209
+
210
+ def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
211
+ """Get a new client matching this one with a new timeout (in seconds)"""
212
+ if self._client is not None:
213
+ self._client.timeout = timeout
214
+ if self._async_client is not None:
215
+ self._async_client.timeout = timeout
216
+ return evolve(self, timeout=timeout)
217
+
218
+ def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient":
219
+ """Manually set the underlying httpx.Client
220
+
221
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
222
+ """
223
+ self._client = client
224
+ return self
225
+
226
+ def get_httpx_client(self) -> httpx.Client:
227
+ """Get the underlying httpx.Client, constructing a new one if not previously set"""
228
+ if self._client is None:
229
+ self._headers[self.auth_header_name] = (
230
+ f"{self.prefix} {self.token}" if self.prefix else self.token
231
+ )
232
+ self._client = httpx.Client(
233
+ base_url=self._base_url,
234
+ cookies=self._cookies,
235
+ headers=self._headers,
236
+ timeout=self._timeout,
237
+ verify=self._verify_ssl,
238
+ follow_redirects=self._follow_redirects,
239
+ **self._httpx_args,
240
+ )
241
+ return self._client
242
+
243
+ def __enter__(self) -> "AuthenticatedClient":
244
+ """Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
245
+ self.get_httpx_client().__enter__()
246
+ return self
247
+
248
+ def __exit__(self, *args: Any, **kwargs: Any) -> None:
249
+ """Exit a context manager for internal httpx.Client (see httpx docs)"""
250
+ self.get_httpx_client().__exit__(*args, **kwargs)
251
+
252
+ def set_async_httpx_client(
253
+ self, async_client: httpx.AsyncClient
254
+ ) -> "AuthenticatedClient":
255
+ """Manually the underlying httpx.AsyncClient
256
+
257
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
258
+ """
259
+ self._async_client = async_client
260
+ return self
261
+
262
+ def get_async_httpx_client(self) -> httpx.AsyncClient:
263
+ """Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
264
+ if self._async_client is None:
265
+ self._headers[self.auth_header_name] = (
266
+ f"{self.prefix} {self.token}" if self.prefix else self.token
267
+ )
268
+ self._async_client = httpx.AsyncClient(
269
+ base_url=self._base_url,
270
+ cookies=self._cookies,
271
+ headers=self._headers,
272
+ timeout=self._timeout,
273
+ verify=self._verify_ssl,
274
+ follow_redirects=self._follow_redirects,
275
+ **self._httpx_args,
276
+ )
277
+ return self._async_client
278
+
279
+ async def __aenter__(self) -> "AuthenticatedClient":
280
+ """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
281
+ await self.get_async_httpx_client().__aenter__()
282
+ return self
283
+
284
+ async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
285
+ """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
286
+ await self.get_async_httpx_client().__aexit__(*args, **kwargs)
@@ -0,0 +1,16 @@
1
+ """Contains shared errors types that can be raised from API functions"""
2
+
3
+
4
+ class UnexpectedStatus(Exception):
5
+ """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
6
+
7
+ def __init__(self, status_code: int, content: bytes):
8
+ self.status_code = status_code
9
+ self.content = content
10
+
11
+ super().__init__(
12
+ f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
13
+ )
14
+
15
+
16
+ __all__ = ["UnexpectedStatus"]
@@ -0,0 +1,13 @@
1
+ """Contains all the data models used in inputs/outputs"""
2
+
3
+ from .error import Error
4
+ from .patch_volumecontent_volume_id_path_body import PatchVolumecontentVolumeIDPathBody
5
+ from .volume_entry_stat import VolumeEntryStat
6
+ from .volume_entry_stat_type import VolumeEntryStatType
7
+
8
+ __all__ = (
9
+ "Error",
10
+ "PatchVolumecontentVolumeIDPathBody",
11
+ "VolumeEntryStat",
12
+ "VolumeEntryStatType",
13
+ )
@@ -0,0 +1,67 @@
1
+ from collections.abc import Mapping
2
+ from typing import Any, TypeVar
3
+
4
+ from attrs import define as _attrs_define
5
+ from attrs import field as _attrs_field
6
+
7
+ T = TypeVar("T", bound="Error")
8
+
9
+
10
+ @_attrs_define
11
+ class Error:
12
+ """
13
+ Attributes:
14
+ code (str): Error code
15
+ message (str): Error message
16
+ """
17
+
18
+ code: str
19
+ message: str
20
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
21
+
22
+ def to_dict(self) -> dict[str, Any]:
23
+ code = self.code
24
+
25
+ message = self.message
26
+
27
+ field_dict: dict[str, Any] = {}
28
+ field_dict.update(self.additional_properties)
29
+ field_dict.update(
30
+ {
31
+ "code": code,
32
+ "message": message,
33
+ }
34
+ )
35
+
36
+ return field_dict
37
+
38
+ @classmethod
39
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
40
+ d = dict(src_dict)
41
+ code = d.pop("code")
42
+
43
+ message = d.pop("message")
44
+
45
+ error = cls(
46
+ code=code,
47
+ message=message,
48
+ )
49
+
50
+ error.additional_properties = d
51
+ return error
52
+
53
+ @property
54
+ def additional_keys(self) -> list[str]:
55
+ return list(self.additional_properties.keys())
56
+
57
+ def __getitem__(self, key: str) -> Any:
58
+ return self.additional_properties[key]
59
+
60
+ def __setitem__(self, key: str, value: Any) -> None:
61
+ self.additional_properties[key] = value
62
+
63
+ def __delitem__(self, key: str) -> None:
64
+ del self.additional_properties[key]
65
+
66
+ def __contains__(self, key: str) -> bool:
67
+ return key in self.additional_properties
@@ -0,0 +1,77 @@
1
+ from collections.abc import Mapping
2
+ from typing import Any, TypeVar, Union
3
+
4
+ from attrs import define as _attrs_define
5
+ from attrs import field as _attrs_field
6
+
7
+ from ..types import UNSET, Unset
8
+
9
+ T = TypeVar("T", bound="PatchVolumecontentVolumeIDPathBody")
10
+
11
+
12
+ @_attrs_define
13
+ class PatchVolumecontentVolumeIDPathBody:
14
+ """
15
+ Attributes:
16
+ uid (Union[Unset, int]):
17
+ gid (Union[Unset, int]):
18
+ mode (Union[Unset, int]):
19
+ """
20
+
21
+ uid: Union[Unset, int] = UNSET
22
+ gid: Union[Unset, int] = UNSET
23
+ mode: Union[Unset, int] = UNSET
24
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
25
+
26
+ def to_dict(self) -> dict[str, Any]:
27
+ uid = self.uid
28
+
29
+ gid = self.gid
30
+
31
+ mode = self.mode
32
+
33
+ field_dict: dict[str, Any] = {}
34
+ field_dict.update(self.additional_properties)
35
+ field_dict.update({})
36
+ if uid is not UNSET:
37
+ field_dict["uid"] = uid
38
+ if gid is not UNSET:
39
+ field_dict["gid"] = gid
40
+ if mode is not UNSET:
41
+ field_dict["mode"] = mode
42
+
43
+ return field_dict
44
+
45
+ @classmethod
46
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
47
+ d = dict(src_dict)
48
+ uid = d.pop("uid", UNSET)
49
+
50
+ gid = d.pop("gid", UNSET)
51
+
52
+ mode = d.pop("mode", UNSET)
53
+
54
+ patch_volumecontent_volume_id_path_body = cls(
55
+ uid=uid,
56
+ gid=gid,
57
+ mode=mode,
58
+ )
59
+
60
+ patch_volumecontent_volume_id_path_body.additional_properties = d
61
+ return patch_volumecontent_volume_id_path_body
62
+
63
+ @property
64
+ def additional_keys(self) -> list[str]:
65
+ return list(self.additional_properties.keys())
66
+
67
+ def __getitem__(self, key: str) -> Any:
68
+ return self.additional_properties[key]
69
+
70
+ def __setitem__(self, key: str, value: Any) -> None:
71
+ self.additional_properties[key] = value
72
+
73
+ def __delitem__(self, key: str) -> None:
74
+ del self.additional_properties[key]
75
+
76
+ def __contains__(self, key: str) -> bool:
77
+ return key in self.additional_properties
@@ -0,0 +1,145 @@
1
+ import datetime
2
+ from collections.abc import Mapping
3
+ from typing import Any, TypeVar, Union
4
+
5
+ from attrs import define as _attrs_define
6
+ from attrs import field as _attrs_field
7
+ from dateutil.parser import isoparse
8
+
9
+ from ..models.volume_entry_stat_type import VolumeEntryStatType
10
+ from ..types import UNSET, Unset
11
+
12
+ T = TypeVar("T", bound="VolumeEntryStat")
13
+
14
+
15
+ @_attrs_define
16
+ class VolumeEntryStat:
17
+ """
18
+ Attributes:
19
+ name (str):
20
+ type_ (VolumeEntryStatType):
21
+ path (str):
22
+ size (int):
23
+ mode (int):
24
+ uid (int):
25
+ gid (int):
26
+ atime (datetime.datetime):
27
+ mtime (datetime.datetime):
28
+ ctime (datetime.datetime):
29
+ target (Union[Unset, str]):
30
+ """
31
+
32
+ name: str
33
+ type_: VolumeEntryStatType
34
+ path: str
35
+ size: int
36
+ mode: int
37
+ uid: int
38
+ gid: int
39
+ atime: datetime.datetime
40
+ mtime: datetime.datetime
41
+ ctime: datetime.datetime
42
+ target: Union[Unset, str] = UNSET
43
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
44
+
45
+ def to_dict(self) -> dict[str, Any]:
46
+ name = self.name
47
+
48
+ type_ = self.type_.value
49
+
50
+ path = self.path
51
+
52
+ size = self.size
53
+
54
+ mode = self.mode
55
+
56
+ uid = self.uid
57
+
58
+ gid = self.gid
59
+
60
+ atime = self.atime.isoformat()
61
+
62
+ mtime = self.mtime.isoformat()
63
+
64
+ ctime = self.ctime.isoformat()
65
+
66
+ target = self.target
67
+
68
+ field_dict: dict[str, Any] = {}
69
+ field_dict.update(self.additional_properties)
70
+ field_dict.update(
71
+ {
72
+ "name": name,
73
+ "type": type_,
74
+ "path": path,
75
+ "size": size,
76
+ "mode": mode,
77
+ "uid": uid,
78
+ "gid": gid,
79
+ "atime": atime,
80
+ "mtime": mtime,
81
+ "ctime": ctime,
82
+ }
83
+ )
84
+ if target is not UNSET:
85
+ field_dict["target"] = target
86
+
87
+ return field_dict
88
+
89
+ @classmethod
90
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
91
+ d = dict(src_dict)
92
+ name = d.pop("name")
93
+
94
+ type_ = VolumeEntryStatType(d.pop("type"))
95
+
96
+ path = d.pop("path")
97
+
98
+ size = d.pop("size")
99
+
100
+ mode = d.pop("mode")
101
+
102
+ uid = d.pop("uid")
103
+
104
+ gid = d.pop("gid")
105
+
106
+ atime = isoparse(d.pop("atime"))
107
+
108
+ mtime = isoparse(d.pop("mtime"))
109
+
110
+ ctime = isoparse(d.pop("ctime"))
111
+
112
+ target = d.pop("target", UNSET)
113
+
114
+ volume_entry_stat = cls(
115
+ name=name,
116
+ type_=type_,
117
+ path=path,
118
+ size=size,
119
+ mode=mode,
120
+ uid=uid,
121
+ gid=gid,
122
+ atime=atime,
123
+ mtime=mtime,
124
+ ctime=ctime,
125
+ target=target,
126
+ )
127
+
128
+ volume_entry_stat.additional_properties = d
129
+ return volume_entry_stat
130
+
131
+ @property
132
+ def additional_keys(self) -> list[str]:
133
+ return list(self.additional_properties.keys())
134
+
135
+ def __getitem__(self, key: str) -> Any:
136
+ return self.additional_properties[key]
137
+
138
+ def __setitem__(self, key: str, value: Any) -> None:
139
+ self.additional_properties[key] = value
140
+
141
+ def __delitem__(self, key: str) -> None:
142
+ del self.additional_properties[key]
143
+
144
+ def __contains__(self, key: str) -> bool:
145
+ return key in self.additional_properties
@@ -0,0 +1,11 @@
1
+ from enum import Enum
2
+
3
+
4
+ class VolumeEntryStatType(str, Enum):
5
+ DIRECTORY = "directory"
6
+ FILE = "file"
7
+ SYMLINK = "symlink"
8
+ UNKNOWN = "unknown"
9
+
10
+ def __str__(self) -> str:
11
+ return str(self.value)
@@ -0,0 +1 @@
1
+ # Marker file for PEP 561
@@ -0,0 +1,54 @@
1
+ """Contains some shared types for properties"""
2
+
3
+ from collections.abc import Mapping, MutableMapping
4
+ from http import HTTPStatus
5
+ from typing import IO, BinaryIO, Generic, Literal, Optional, TypeVar, Union
6
+
7
+ from attrs import define
8
+
9
+
10
+ class Unset:
11
+ def __bool__(self) -> Literal[False]:
12
+ return False
13
+
14
+
15
+ UNSET: Unset = Unset()
16
+
17
+ # The types that `httpx.Client(files=)` can accept, copied from that library.
18
+ FileContent = Union[IO[bytes], bytes, str]
19
+ FileTypes = Union[
20
+ # (filename, file (or bytes), content_type)
21
+ tuple[Optional[str], FileContent, Optional[str]],
22
+ # (filename, file (or bytes), content_type, headers)
23
+ tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]],
24
+ ]
25
+ RequestFiles = list[tuple[str, FileTypes]]
26
+
27
+
28
+ @define
29
+ class File:
30
+ """Contains information for file uploads"""
31
+
32
+ payload: BinaryIO
33
+ file_name: Optional[str] = None
34
+ mime_type: Optional[str] = None
35
+
36
+ def to_tuple(self) -> FileTypes:
37
+ """Return a tuple representation that httpx will accept for multipart/form-data"""
38
+ return self.file_name, self.payload, self.mime_type
39
+
40
+
41
+ T = TypeVar("T")
42
+
43
+
44
+ @define
45
+ class Response(Generic[T]):
46
+ """A response from an endpoint"""
47
+
48
+ status_code: HTTPStatus
49
+ content: bytes
50
+ headers: MutableMapping[str, str]
51
+ parsed: Optional[T]
52
+
53
+
54
+ __all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"]