mithril-client 0.1.0a1__cp314-cp314-macosx_10_12_x86_64.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.
- mithril/__init__.py +7 -0
- mithril/_mcli.cpython-314-darwin.so +0 -0
- mithril/_mcli.pyi +7 -0
- mithril/_mcli_entry.py +75 -0
- mithril/api/__init__.py +7 -0
- mithril/api/bindings/.gitattributes +2 -0
- mithril/api/bindings/__init__.py +10 -0
- mithril/api/bindings/api/__init__.py +1 -0
- mithril/api/bindings/api/api_keys/__init__.py +1 -0
- mithril/api/bindings/api/api_keys/create_api_key_v2_api_keys_post.py +179 -0
- mithril/api/bindings/api/api_keys/get_api_keys_v2_api_keys_get.py +141 -0
- mithril/api/bindings/api/api_keys/revoke_api_key_v2_api_keys_key_fid_delete.py +173 -0
- mithril/api/bindings/api/image_versions/__init__.py +1 -0
- mithril/api/bindings/api/image_versions/get_image_versions_v2_image_versions_get.py +141 -0
- mithril/api/bindings/api/image_versions/get_mcc_image_versions_v2_mcc_image_versions_get.py +179 -0
- mithril/api/bindings/api/instance_types/__init__.py +1 -0
- mithril/api/bindings/api/instance_types/get_instance_types_v2_instance_types_get.py +137 -0
- mithril/api/bindings/api/instances/__init__.py +1 -0
- mithril/api/bindings/api/instances/get_instance_status_v2_instances_instance_id_status_get.py +165 -0
- mithril/api/bindings/api/instances/get_instances_v2_instances_get.py +409 -0
- mithril/api/bindings/api/kubernetes_clusters/__init__.py +1 -0
- mithril/api/bindings/api/kubernetes_clusters/create_kubernetes_cluster_v2_kubernetes_clusters_post.py +171 -0
- mithril/api/bindings/api/kubernetes_clusters/delete_kubernetes_cluster_v2_kubernetes_clusters_cluster_fid_delete.py +163 -0
- mithril/api/bindings/api/kubernetes_clusters/get_kubernetes_cluster_v2_kubernetes_clusters_cluster_fid_get.py +165 -0
- mithril/api/bindings/api/kubernetes_clusters/get_kubernetes_clusters_v2_kubernetes_clusters_get.py +175 -0
- mithril/api/bindings/api/lifecycle_scripts/__init__.py +1 -0
- mithril/api/bindings/api/lifecycle_scripts/create_lifecycle_script_v2_lifecycle_scripts_post.py +171 -0
- mithril/api/bindings/api/lifecycle_scripts/delete_lifecycle_script_v2_lifecycle_scripts_ls_fid_delete.py +155 -0
- mithril/api/bindings/api/lifecycle_scripts/get_lifecycle_script_content_v2_lifecycle_scripts_ls_fid_content_get.py +155 -0
- mithril/api/bindings/api/lifecycle_scripts/list_lifecycle_scripts_v2_lifecycle_scripts_get.py +247 -0
- mithril/api/bindings/api/lifecycle_scripts/update_lifecycle_script_v2_lifecycle_scripts_ls_fid_patch.py +179 -0
- mithril/api/bindings/api/pricing/__init__.py +1 -0
- mithril/api/bindings/api/pricing/get_current_prices_v2_v2_pricing_current_get.py +217 -0
- mithril/api/bindings/api/pricing/get_historical_prices_v2_v2_pricing_history_get.py +222 -0
- mithril/api/bindings/api/profile/__init__.py +1 -0
- mithril/api/bindings/api/profile/get_me_v2_me_get.py +132 -0
- mithril/api/bindings/api/profile/get_my_teammates_v2_me_teammates_get.py +153 -0
- mithril/api/bindings/api/projects/__init__.py +1 -0
- mithril/api/bindings/api/projects/get_projects_v2_projects_get.py +137 -0
- mithril/api/bindings/api/quotas/__init__.py +1 -0
- mithril/api/bindings/api/quotas/get_quotas_v2_quotas_get.py +175 -0
- mithril/api/bindings/api/reservations/__init__.py +1 -0
- mithril/api/bindings/api/reservations/create_reservation_v2_reservation_post.py +171 -0
- mithril/api/bindings/api/reservations/extend_reservation_v2_reservation_reservation_fid_extend_post.py +187 -0
- mithril/api/bindings/api/reservations/get_availability_v2_reservation_availability_get.py +664 -0
- mithril/api/bindings/api/reservations/get_extension_availability_v2_reservation_reservation_fid_extension_availability_get.py +165 -0
- mithril/api/bindings/api/reservations/get_reservations_v2_reservation_get.py +309 -0
- mithril/api/bindings/api/reservations/update_reservation_v2_reservation_reservation_fid_patch.py +187 -0
- mithril/api/bindings/api/spot/__init__.py +1 -0
- mithril/api/bindings/api/spot/cancel_bid_v2_spot_bids_bid_fid_delete.py +161 -0
- mithril/api/bindings/api/spot/create_bid_v2_spot_bids_post.py +171 -0
- mithril/api/bindings/api/spot/get_auctions_v2_spot_availability_get.py +137 -0
- mithril/api/bindings/api/spot/get_bid_history_v2_spot_bids_bid_fid_history_get.py +193 -0
- mithril/api/bindings/api/spot/get_bid_status_v2_spot_bids_bid_fid_status_get.py +189 -0
- mithril/api/bindings/api/spot/get_bid_v2_spot_bids_bid_fid_get.py +163 -0
- mithril/api/bindings/api/spot/get_bids_v2_spot_bids_get.py +330 -0
- mithril/api/bindings/api/spot/update_bid_v2_spot_bids_bid_fid_patch.py +185 -0
- mithril/api/bindings/api/ssh_keys/__init__.py +1 -0
- mithril/api/bindings/api/ssh_keys/create_ssh_key_v2_ssh_keys_post.py +175 -0
- mithril/api/bindings/api/ssh_keys/delete_ssh_key_v2_ssh_keys_ssh_key_fid_delete.py +167 -0
- mithril/api/bindings/api/ssh_keys/get_ssh_keys_v2_ssh_keys_get.py +175 -0
- mithril/api/bindings/api/ssh_keys/update_ssh_key_v2_ssh_keys_ssh_key_fid_patch.py +187 -0
- mithril/api/bindings/api/volumes/__init__.py +1 -0
- mithril/api/bindings/api/volumes/create_volume_v2_volumes_post.py +211 -0
- mithril/api/bindings/api/volumes/delete_volume_v2_volumes_volume_fid_delete.py +199 -0
- mithril/api/bindings/api/volumes/get_volumes_v2_volumes_get.py +239 -0
- mithril/api/bindings/api/volumes/update_volume_v2_volumes_volume_fid_patch.py +243 -0
- mithril/api/bindings/client.py +284 -0
- mithril/api/bindings/errors.py +18 -0
- mithril/api/bindings/models/__init__.py +169 -0
- mithril/api/bindings/models/api_key_model.py +114 -0
- mithril/api/bindings/models/auction_model.py +146 -0
- mithril/api/bindings/models/availability_slot_model.py +76 -0
- mithril/api/bindings/models/bid_history_event_model.py +157 -0
- mithril/api/bindings/models/bid_history_event_model_event_type.py +19 -0
- mithril/api/bindings/models/bid_history_response.py +84 -0
- mithril/api/bindings/models/bid_model.py +191 -0
- mithril/api/bindings/models/bid_model_status.py +14 -0
- mithril/api/bindings/models/bid_status_response.py +72 -0
- mithril/api/bindings/models/bid_status_response_status.py +15 -0
- mithril/api/bindings/models/check_availability_response.py +60 -0
- mithril/api/bindings/models/create_api_key_request.py +68 -0
- mithril/api/bindings/models/create_api_key_response.py +122 -0
- mithril/api/bindings/models/create_bid_request.py +116 -0
- mithril/api/bindings/models/create_kubernetes_cluster_request.py +136 -0
- mithril/api/bindings/models/create_kubernetes_cluster_request_k8s_version.py +11 -0
- mithril/api/bindings/models/create_lifecycle_script_request.py +115 -0
- mithril/api/bindings/models/create_reservation_request.py +124 -0
- mithril/api/bindings/models/create_ssh_key_request.py +99 -0
- mithril/api/bindings/models/create_volume_request.py +98 -0
- mithril/api/bindings/models/create_volume_request_disk_interface.py +11 -0
- mithril/api/bindings/models/created_ssh_key_model.py +122 -0
- mithril/api/bindings/models/current_prices_response.py +202 -0
- mithril/api/bindings/models/extend_reservation_request.py +60 -0
- mithril/api/bindings/models/extension_availability_response.py +68 -0
- mithril/api/bindings/models/get_availability_v2_reservation_availability_get_mode.py +12 -0
- mithril/api/bindings/models/get_bids_response.py +96 -0
- mithril/api/bindings/models/get_bids_v2_spot_bids_get_sort_by.py +11 -0
- mithril/api/bindings/models/get_bids_v2_spot_bids_get_status.py +14 -0
- mithril/api/bindings/models/get_instances_response.py +96 -0
- mithril/api/bindings/models/get_instances_v2_instances_get_order_type_in_type_0_item.py +11 -0
- mithril/api/bindings/models/get_instances_v2_instances_get_sort_by.py +12 -0
- mithril/api/bindings/models/get_instances_v2_instances_get_status_in_type_0_item.py +24 -0
- mithril/api/bindings/models/get_latest_end_time_response.py +68 -0
- mithril/api/bindings/models/get_reservations_response.py +96 -0
- mithril/api/bindings/models/get_reservations_v2_reservation_get_sort_by.py +11 -0
- mithril/api/bindings/models/get_reservations_v2_reservation_get_status.py +14 -0
- mithril/api/bindings/models/historical_price_point_model.py +94 -0
- mithril/api/bindings/models/historical_prices_response_model.py +76 -0
- mithril/api/bindings/models/http_validation_error.py +78 -0
- mithril/api/bindings/models/image_version_model.py +224 -0
- mithril/api/bindings/models/instance_model.py +211 -0
- mithril/api/bindings/models/instance_model_status.py +24 -0
- mithril/api/bindings/models/instance_status_response.py +141 -0
- mithril/api/bindings/models/instance_status_response_status.py +24 -0
- mithril/api/bindings/models/instance_type_model.py +170 -0
- mithril/api/bindings/models/kubernetes_cluster_model.py +207 -0
- mithril/api/bindings/models/kubernetes_cluster_model_status.py +12 -0
- mithril/api/bindings/models/launch_specification_model.py +152 -0
- mithril/api/bindings/models/lifecycle_script_model.py +134 -0
- mithril/api/bindings/models/lifecycle_script_scope.py +12 -0
- mithril/api/bindings/models/list_lifecycle_scripts_response.py +96 -0
- mithril/api/bindings/models/list_lifecycle_scripts_v2_lifecycle_scripts_get_sort_by.py +11 -0
- mithril/api/bindings/models/me_response.py +126 -0
- mithril/api/bindings/models/new_ssh_key_model.py +100 -0
- mithril/api/bindings/models/persistent_disk_change.py +92 -0
- mithril/api/bindings/models/project_model.py +76 -0
- mithril/api/bindings/models/public_lifecycle_script_scope.py +11 -0
- mithril/api/bindings/models/quota_model.py +132 -0
- mithril/api/bindings/models/reservation_model.py +215 -0
- mithril/api/bindings/models/reservation_model_status.py +14 -0
- mithril/api/bindings/models/size.py +70 -0
- mithril/api/bindings/models/size_unit.py +18 -0
- mithril/api/bindings/models/sort_direction.py +11 -0
- mithril/api/bindings/models/teammate_response.py +158 -0
- mithril/api/bindings/models/update_bid_request.py +143 -0
- mithril/api/bindings/models/update_lifecycle_script_request.py +109 -0
- mithril/api/bindings/models/update_reservation_request.py +103 -0
- mithril/api/bindings/models/update_ssh_key_request.py +60 -0
- mithril/api/bindings/models/update_volume_request.py +65 -0
- mithril/api/bindings/models/validation_error.py +89 -0
- mithril/api/bindings/models/volume_model.py +140 -0
- mithril/api/bindings/models/volume_model_attachments.py +46 -0
- mithril/api/bindings/models/volume_model_interface.py +11 -0
- mithril/api/bindings/types.py +56 -0
- mithril/api/client.py +138 -0
- mithril/cli/__init__.py +7 -0
- mithril/cli/commands/__init__.py +15 -0
- mithril/cli/commands/help.py +88 -0
- mithril/cli/commands/launch.py +353 -0
- mithril/cli/main.py +68 -0
- mithril/cli/utils/__init__.py +1 -0
- mithril/cli/utils/skypilot_passthrough.py +38 -0
- mithril/cli/utils/streaming.py +235 -0
- mithril/cli/utils/volumes.py +110 -0
- mithril/config.py +47 -0
- mithril/py.typed +0 -0
- mithril/sky/__init__.py +141 -0
- mithril/sky/client.py +176 -0
- mithril_client-0.1.0a1.dist-info/METADATA +56 -0
- mithril_client-0.1.0a1.dist-info/RECORD +163 -0
- mithril_client-0.1.0a1.dist-info/WHEEL +4 -0
- mithril_client-0.1.0a1.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import ssl
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
from attrs import define, evolve, field
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@define
|
|
11
|
+
class Client:
|
|
12
|
+
"""A class for keeping track of data related to the API
|
|
13
|
+
|
|
14
|
+
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
|
15
|
+
|
|
16
|
+
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
|
17
|
+
|
|
18
|
+
``cookies``: A dictionary of cookies to be sent with every request
|
|
19
|
+
|
|
20
|
+
``headers``: A dictionary of headers to be sent with every request
|
|
21
|
+
|
|
22
|
+
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
|
23
|
+
httpx.TimeoutException if this is exceeded.
|
|
24
|
+
|
|
25
|
+
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
|
26
|
+
but can be set to False for testing purposes.
|
|
27
|
+
|
|
28
|
+
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
|
29
|
+
|
|
30
|
+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
Attributes:
|
|
34
|
+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
|
35
|
+
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
|
36
|
+
argument to the constructor.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
|
40
|
+
_base_url: str = field(alias="base_url")
|
|
41
|
+
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
|
42
|
+
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
|
43
|
+
_timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
|
|
44
|
+
_verify_ssl: 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: httpx.Client | None = field(default=None, init=False)
|
|
52
|
+
_async_client: httpx.AsyncClient | None = 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 configuration"""
|
|
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: object, **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 set 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: object, **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: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
|
|
178
|
+
_verify_ssl: str | bool | ssl.SSLContext = field(
|
|
179
|
+
default=True, kw_only=True, alias="verify_ssl"
|
|
180
|
+
)
|
|
181
|
+
_follow_redirects: bool = field(
|
|
182
|
+
default=False, kw_only=True, alias="follow_redirects"
|
|
183
|
+
)
|
|
184
|
+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
|
185
|
+
_client: httpx.Client | None = field(default=None, init=False)
|
|
186
|
+
_async_client: httpx.AsyncClient | None = field(default=None, init=False)
|
|
187
|
+
|
|
188
|
+
token: str
|
|
189
|
+
prefix: str = "Bearer"
|
|
190
|
+
auth_header_name: str = "Authorization"
|
|
191
|
+
|
|
192
|
+
def with_headers(self, headers: dict[str, str]) -> AuthenticatedClient:
|
|
193
|
+
"""Get a new client matching this one with additional headers"""
|
|
194
|
+
if self._client is not None:
|
|
195
|
+
self._client.headers.update(headers)
|
|
196
|
+
if self._async_client is not None:
|
|
197
|
+
self._async_client.headers.update(headers)
|
|
198
|
+
return evolve(self, headers={**self._headers, **headers})
|
|
199
|
+
|
|
200
|
+
def with_cookies(self, cookies: dict[str, str]) -> AuthenticatedClient:
|
|
201
|
+
"""Get a new client matching this one with additional cookies"""
|
|
202
|
+
if self._client is not None:
|
|
203
|
+
self._client.cookies.update(cookies)
|
|
204
|
+
if self._async_client is not None:
|
|
205
|
+
self._async_client.cookies.update(cookies)
|
|
206
|
+
return evolve(self, cookies={**self._cookies, **cookies})
|
|
207
|
+
|
|
208
|
+
def with_timeout(self, timeout: httpx.Timeout) -> AuthenticatedClient:
|
|
209
|
+
"""Get a new client matching this one with a new timeout configuration"""
|
|
210
|
+
if self._client is not None:
|
|
211
|
+
self._client.timeout = timeout
|
|
212
|
+
if self._async_client is not None:
|
|
213
|
+
self._async_client.timeout = timeout
|
|
214
|
+
return evolve(self, timeout=timeout)
|
|
215
|
+
|
|
216
|
+
def set_httpx_client(self, client: httpx.Client) -> AuthenticatedClient:
|
|
217
|
+
"""Manually set the underlying httpx.Client
|
|
218
|
+
|
|
219
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
220
|
+
"""
|
|
221
|
+
self._client = client
|
|
222
|
+
return self
|
|
223
|
+
|
|
224
|
+
def get_httpx_client(self) -> httpx.Client:
|
|
225
|
+
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
|
226
|
+
if self._client is None:
|
|
227
|
+
self._headers[self.auth_header_name] = (
|
|
228
|
+
f"{self.prefix} {self.token}" if self.prefix else self.token
|
|
229
|
+
)
|
|
230
|
+
self._client = httpx.Client(
|
|
231
|
+
base_url=self._base_url,
|
|
232
|
+
cookies=self._cookies,
|
|
233
|
+
headers=self._headers,
|
|
234
|
+
timeout=self._timeout,
|
|
235
|
+
verify=self._verify_ssl,
|
|
236
|
+
follow_redirects=self._follow_redirects,
|
|
237
|
+
**self._httpx_args,
|
|
238
|
+
)
|
|
239
|
+
return self._client
|
|
240
|
+
|
|
241
|
+
def __enter__(self) -> AuthenticatedClient:
|
|
242
|
+
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
|
243
|
+
self.get_httpx_client().__enter__()
|
|
244
|
+
return self
|
|
245
|
+
|
|
246
|
+
def __exit__(self, *args: object, **kwargs: Any) -> None:
|
|
247
|
+
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
|
248
|
+
self.get_httpx_client().__exit__(*args, **kwargs)
|
|
249
|
+
|
|
250
|
+
def set_async_httpx_client(
|
|
251
|
+
self, async_client: httpx.AsyncClient
|
|
252
|
+
) -> AuthenticatedClient:
|
|
253
|
+
"""Manually set the underlying httpx.AsyncClient
|
|
254
|
+
|
|
255
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
256
|
+
"""
|
|
257
|
+
self._async_client = async_client
|
|
258
|
+
return self
|
|
259
|
+
|
|
260
|
+
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
|
261
|
+
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
|
262
|
+
if self._async_client is None:
|
|
263
|
+
self._headers[self.auth_header_name] = (
|
|
264
|
+
f"{self.prefix} {self.token}" if self.prefix else self.token
|
|
265
|
+
)
|
|
266
|
+
self._async_client = httpx.AsyncClient(
|
|
267
|
+
base_url=self._base_url,
|
|
268
|
+
cookies=self._cookies,
|
|
269
|
+
headers=self._headers,
|
|
270
|
+
timeout=self._timeout,
|
|
271
|
+
verify=self._verify_ssl,
|
|
272
|
+
follow_redirects=self._follow_redirects,
|
|
273
|
+
**self._httpx_args,
|
|
274
|
+
)
|
|
275
|
+
return self._async_client
|
|
276
|
+
|
|
277
|
+
async def __aenter__(self) -> AuthenticatedClient:
|
|
278
|
+
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
|
279
|
+
await self.get_async_httpx_client().__aenter__()
|
|
280
|
+
return self
|
|
281
|
+
|
|
282
|
+
async def __aexit__(self, *args: object, **kwargs: Any) -> None:
|
|
283
|
+
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
|
284
|
+
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Contains shared errors types that can be raised from API functions"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class UnexpectedStatus(Exception):
|
|
7
|
+
"""Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
|
|
8
|
+
|
|
9
|
+
def __init__(self, status_code: int, content: bytes):
|
|
10
|
+
self.status_code = status_code
|
|
11
|
+
self.content = content
|
|
12
|
+
|
|
13
|
+
super().__init__(
|
|
14
|
+
f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
__all__ = ["UnexpectedStatus"]
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"""Contains all the data models used in inputs/outputs"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from .api_key_model import ApiKeyModel
|
|
6
|
+
from .auction_model import AuctionModel
|
|
7
|
+
from .availability_slot_model import AvailabilitySlotModel
|
|
8
|
+
from .bid_history_event_model import BidHistoryEventModel
|
|
9
|
+
from .bid_history_event_model_event_type import BidHistoryEventModelEventType
|
|
10
|
+
from .bid_history_response import BidHistoryResponse
|
|
11
|
+
from .bid_model import BidModel
|
|
12
|
+
from .bid_model_status import BidModelStatus
|
|
13
|
+
from .bid_status_response import BidStatusResponse
|
|
14
|
+
from .bid_status_response_status import BidStatusResponseStatus
|
|
15
|
+
from .check_availability_response import CheckAvailabilityResponse
|
|
16
|
+
from .create_api_key_request import CreateApiKeyRequest
|
|
17
|
+
from .create_api_key_response import CreateApiKeyResponse
|
|
18
|
+
from .create_bid_request import CreateBidRequest
|
|
19
|
+
from .create_kubernetes_cluster_request import CreateKubernetesClusterRequest
|
|
20
|
+
from .create_kubernetes_cluster_request_k8s_version import (
|
|
21
|
+
CreateKubernetesClusterRequestK8SVersion,
|
|
22
|
+
)
|
|
23
|
+
from .create_lifecycle_script_request import CreateLifecycleScriptRequest
|
|
24
|
+
from .create_reservation_request import CreateReservationRequest
|
|
25
|
+
from .create_ssh_key_request import CreateSshKeyRequest
|
|
26
|
+
from .create_volume_request import CreateVolumeRequest
|
|
27
|
+
from .create_volume_request_disk_interface import CreateVolumeRequestDiskInterface
|
|
28
|
+
from .created_ssh_key_model import CreatedSshKeyModel
|
|
29
|
+
from .current_prices_response import CurrentPricesResponse
|
|
30
|
+
from .extend_reservation_request import ExtendReservationRequest
|
|
31
|
+
from .extension_availability_response import ExtensionAvailabilityResponse
|
|
32
|
+
from .get_availability_v2_reservation_availability_get_mode import (
|
|
33
|
+
GetAvailabilityV2ReservationAvailabilityGetMode,
|
|
34
|
+
)
|
|
35
|
+
from .get_bids_response import GetBidsResponse
|
|
36
|
+
from .get_bids_v2_spot_bids_get_sort_by import GetBidsV2SpotBidsGetSortBy
|
|
37
|
+
from .get_bids_v2_spot_bids_get_status import GetBidsV2SpotBidsGetStatus
|
|
38
|
+
from .get_instances_response import GetInstancesResponse
|
|
39
|
+
from .get_instances_v2_instances_get_order_type_in_type_0_item import (
|
|
40
|
+
GetInstancesV2InstancesGetOrderTypeInType0Item,
|
|
41
|
+
)
|
|
42
|
+
from .get_instances_v2_instances_get_sort_by import GetInstancesV2InstancesGetSortBy
|
|
43
|
+
from .get_instances_v2_instances_get_status_in_type_0_item import (
|
|
44
|
+
GetInstancesV2InstancesGetStatusInType0Item,
|
|
45
|
+
)
|
|
46
|
+
from .get_latest_end_time_response import GetLatestEndTimeResponse
|
|
47
|
+
from .get_reservations_response import GetReservationsResponse
|
|
48
|
+
from .get_reservations_v2_reservation_get_sort_by import (
|
|
49
|
+
GetReservationsV2ReservationGetSortBy,
|
|
50
|
+
)
|
|
51
|
+
from .get_reservations_v2_reservation_get_status import (
|
|
52
|
+
GetReservationsV2ReservationGetStatus,
|
|
53
|
+
)
|
|
54
|
+
from .historical_price_point_model import HistoricalPricePointModel
|
|
55
|
+
from .historical_prices_response_model import HistoricalPricesResponseModel
|
|
56
|
+
from .http_validation_error import HTTPValidationError
|
|
57
|
+
from .image_version_model import ImageVersionModel
|
|
58
|
+
from .instance_model import InstanceModel
|
|
59
|
+
from .instance_model_status import InstanceModelStatus
|
|
60
|
+
from .instance_status_response import InstanceStatusResponse
|
|
61
|
+
from .instance_status_response_status import InstanceStatusResponseStatus
|
|
62
|
+
from .instance_type_model import InstanceTypeModel
|
|
63
|
+
from .kubernetes_cluster_model import KubernetesClusterModel
|
|
64
|
+
from .kubernetes_cluster_model_status import KubernetesClusterModelStatus
|
|
65
|
+
from .launch_specification_model import LaunchSpecificationModel
|
|
66
|
+
from .lifecycle_script_model import LifecycleScriptModel
|
|
67
|
+
from .lifecycle_script_scope import LifecycleScriptScope
|
|
68
|
+
from .list_lifecycle_scripts_response import ListLifecycleScriptsResponse
|
|
69
|
+
from .list_lifecycle_scripts_v2_lifecycle_scripts_get_sort_by import (
|
|
70
|
+
ListLifecycleScriptsV2LifecycleScriptsGetSortBy,
|
|
71
|
+
)
|
|
72
|
+
from .me_response import MeResponse
|
|
73
|
+
from .new_ssh_key_model import NewSshKeyModel
|
|
74
|
+
from .persistent_disk_change import PersistentDiskChange
|
|
75
|
+
from .project_model import ProjectModel
|
|
76
|
+
from .public_lifecycle_script_scope import PublicLifecycleScriptScope
|
|
77
|
+
from .quota_model import QuotaModel
|
|
78
|
+
from .reservation_model import ReservationModel
|
|
79
|
+
from .reservation_model_status import ReservationModelStatus
|
|
80
|
+
from .size import Size
|
|
81
|
+
from .size_unit import SizeUnit
|
|
82
|
+
from .sort_direction import SortDirection
|
|
83
|
+
from .teammate_response import TeammateResponse
|
|
84
|
+
from .update_bid_request import UpdateBidRequest
|
|
85
|
+
from .update_lifecycle_script_request import UpdateLifecycleScriptRequest
|
|
86
|
+
from .update_reservation_request import UpdateReservationRequest
|
|
87
|
+
from .update_ssh_key_request import UpdateSshKeyRequest
|
|
88
|
+
from .update_volume_request import UpdateVolumeRequest
|
|
89
|
+
from .validation_error import ValidationError
|
|
90
|
+
from .volume_model import VolumeModel
|
|
91
|
+
from .volume_model_attachments import VolumeModelAttachments
|
|
92
|
+
from .volume_model_interface import VolumeModelInterface
|
|
93
|
+
|
|
94
|
+
__all__ = (
|
|
95
|
+
"ApiKeyModel",
|
|
96
|
+
"AuctionModel",
|
|
97
|
+
"AvailabilitySlotModel",
|
|
98
|
+
"BidHistoryEventModel",
|
|
99
|
+
"BidHistoryEventModelEventType",
|
|
100
|
+
"BidHistoryResponse",
|
|
101
|
+
"BidModel",
|
|
102
|
+
"BidModelStatus",
|
|
103
|
+
"BidStatusResponse",
|
|
104
|
+
"BidStatusResponseStatus",
|
|
105
|
+
"CheckAvailabilityResponse",
|
|
106
|
+
"CreateApiKeyRequest",
|
|
107
|
+
"CreateApiKeyResponse",
|
|
108
|
+
"CreateBidRequest",
|
|
109
|
+
"CreateKubernetesClusterRequest",
|
|
110
|
+
"CreateKubernetesClusterRequestK8SVersion",
|
|
111
|
+
"CreateLifecycleScriptRequest",
|
|
112
|
+
"CreateReservationRequest",
|
|
113
|
+
"CreateSshKeyRequest",
|
|
114
|
+
"CreateVolumeRequest",
|
|
115
|
+
"CreateVolumeRequestDiskInterface",
|
|
116
|
+
"CreatedSshKeyModel",
|
|
117
|
+
"CurrentPricesResponse",
|
|
118
|
+
"ExtendReservationRequest",
|
|
119
|
+
"ExtensionAvailabilityResponse",
|
|
120
|
+
"GetAvailabilityV2ReservationAvailabilityGetMode",
|
|
121
|
+
"GetBidsResponse",
|
|
122
|
+
"GetBidsV2SpotBidsGetSortBy",
|
|
123
|
+
"GetBidsV2SpotBidsGetStatus",
|
|
124
|
+
"GetInstancesResponse",
|
|
125
|
+
"GetInstancesV2InstancesGetOrderTypeInType0Item",
|
|
126
|
+
"GetInstancesV2InstancesGetSortBy",
|
|
127
|
+
"GetInstancesV2InstancesGetStatusInType0Item",
|
|
128
|
+
"GetLatestEndTimeResponse",
|
|
129
|
+
"GetReservationsResponse",
|
|
130
|
+
"GetReservationsV2ReservationGetSortBy",
|
|
131
|
+
"GetReservationsV2ReservationGetStatus",
|
|
132
|
+
"HTTPValidationError",
|
|
133
|
+
"HistoricalPricePointModel",
|
|
134
|
+
"HistoricalPricesResponseModel",
|
|
135
|
+
"ImageVersionModel",
|
|
136
|
+
"InstanceModel",
|
|
137
|
+
"InstanceModelStatus",
|
|
138
|
+
"InstanceStatusResponse",
|
|
139
|
+
"InstanceStatusResponseStatus",
|
|
140
|
+
"InstanceTypeModel",
|
|
141
|
+
"KubernetesClusterModel",
|
|
142
|
+
"KubernetesClusterModelStatus",
|
|
143
|
+
"LaunchSpecificationModel",
|
|
144
|
+
"LifecycleScriptModel",
|
|
145
|
+
"LifecycleScriptScope",
|
|
146
|
+
"ListLifecycleScriptsResponse",
|
|
147
|
+
"ListLifecycleScriptsV2LifecycleScriptsGetSortBy",
|
|
148
|
+
"MeResponse",
|
|
149
|
+
"NewSshKeyModel",
|
|
150
|
+
"PersistentDiskChange",
|
|
151
|
+
"ProjectModel",
|
|
152
|
+
"PublicLifecycleScriptScope",
|
|
153
|
+
"QuotaModel",
|
|
154
|
+
"ReservationModel",
|
|
155
|
+
"ReservationModelStatus",
|
|
156
|
+
"Size",
|
|
157
|
+
"SizeUnit",
|
|
158
|
+
"SortDirection",
|
|
159
|
+
"TeammateResponse",
|
|
160
|
+
"UpdateBidRequest",
|
|
161
|
+
"UpdateLifecycleScriptRequest",
|
|
162
|
+
"UpdateReservationRequest",
|
|
163
|
+
"UpdateSshKeyRequest",
|
|
164
|
+
"UpdateVolumeRequest",
|
|
165
|
+
"ValidationError",
|
|
166
|
+
"VolumeModel",
|
|
167
|
+
"VolumeModelAttachments",
|
|
168
|
+
"VolumeModelInterface",
|
|
169
|
+
)
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Any, Self, TypeVar, cast
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
from ..types import UNSET, Unset
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T", bound="ApiKeyModel")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@_attrs_define
|
|
15
|
+
class ApiKeyModel:
|
|
16
|
+
"""Attributes:
|
|
17
|
+
fid (str):
|
|
18
|
+
name (str):
|
|
19
|
+
created_at (str):
|
|
20
|
+
expires_at (str):
|
|
21
|
+
snippet (str):
|
|
22
|
+
deactivated_at (None | str | Unset):
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
fid: str
|
|
26
|
+
name: str
|
|
27
|
+
created_at: str
|
|
28
|
+
expires_at: str
|
|
29
|
+
snippet: str
|
|
30
|
+
deactivated_at: None | str | Unset = UNSET
|
|
31
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
32
|
+
|
|
33
|
+
def to_dict(self) -> dict[str, Any]:
|
|
34
|
+
fid = self.fid
|
|
35
|
+
|
|
36
|
+
name = self.name
|
|
37
|
+
|
|
38
|
+
created_at = self.created_at
|
|
39
|
+
|
|
40
|
+
expires_at = self.expires_at
|
|
41
|
+
|
|
42
|
+
snippet = self.snippet
|
|
43
|
+
|
|
44
|
+
deactivated_at: None | str | Unset
|
|
45
|
+
if isinstance(self.deactivated_at, Unset):
|
|
46
|
+
deactivated_at = UNSET
|
|
47
|
+
else:
|
|
48
|
+
deactivated_at = self.deactivated_at
|
|
49
|
+
|
|
50
|
+
field_dict: dict[str, Any] = {}
|
|
51
|
+
field_dict.update(self.additional_properties)
|
|
52
|
+
field_dict.update(
|
|
53
|
+
{
|
|
54
|
+
"fid": fid,
|
|
55
|
+
"name": name,
|
|
56
|
+
"created_at": created_at,
|
|
57
|
+
"expires_at": expires_at,
|
|
58
|
+
"snippet": snippet,
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
if deactivated_at is not UNSET:
|
|
62
|
+
field_dict["deactivated_at"] = deactivated_at
|
|
63
|
+
|
|
64
|
+
return field_dict
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def from_dict(cls, src_dict: Mapping[str, Any]) -> Self:
|
|
68
|
+
d = dict(src_dict)
|
|
69
|
+
fid = d.pop("fid")
|
|
70
|
+
|
|
71
|
+
name = d.pop("name")
|
|
72
|
+
|
|
73
|
+
created_at = d.pop("created_at")
|
|
74
|
+
|
|
75
|
+
expires_at = d.pop("expires_at")
|
|
76
|
+
|
|
77
|
+
snippet = d.pop("snippet")
|
|
78
|
+
|
|
79
|
+
def _parse_deactivated_at(data: object) -> None | str | Unset:
|
|
80
|
+
if data is None:
|
|
81
|
+
return data
|
|
82
|
+
if isinstance(data, Unset):
|
|
83
|
+
return data
|
|
84
|
+
return cast(None | str | Unset, data)
|
|
85
|
+
|
|
86
|
+
deactivated_at = _parse_deactivated_at(d.pop("deactivated_at", UNSET))
|
|
87
|
+
|
|
88
|
+
api_key_model = cls(
|
|
89
|
+
fid=fid,
|
|
90
|
+
name=name,
|
|
91
|
+
created_at=created_at,
|
|
92
|
+
expires_at=expires_at,
|
|
93
|
+
snippet=snippet,
|
|
94
|
+
deactivated_at=deactivated_at,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
api_key_model.additional_properties = d
|
|
98
|
+
return api_key_model
|
|
99
|
+
|
|
100
|
+
@property
|
|
101
|
+
def additional_keys(self) -> list[str]:
|
|
102
|
+
return list(self.additional_properties.keys())
|
|
103
|
+
|
|
104
|
+
def __getitem__(self, key: str) -> Any:
|
|
105
|
+
return self.additional_properties[key]
|
|
106
|
+
|
|
107
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
108
|
+
self.additional_properties[key] = value
|
|
109
|
+
|
|
110
|
+
def __delitem__(self, key: str) -> None:
|
|
111
|
+
del self.additional_properties[key]
|
|
112
|
+
|
|
113
|
+
def __contains__(self, key: str) -> bool:
|
|
114
|
+
return key in self.additional_properties
|