boxrouter 0.0.1a1__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 (36) hide show
  1. boxrouter/__init__.py +6 -0
  2. boxrouter/api/__init__.py +2 -0
  3. boxrouter/api/providers/__init__.py +2 -0
  4. boxrouter/api/providers/list_providers.py +114 -0
  5. boxrouter/client.py +272 -0
  6. boxrouter/errors.py +16 -0
  7. boxrouter/models/__init__.py +50 -0
  8. boxrouter/models/eligible_route.py +148 -0
  9. boxrouter/models/eligible_route_attested.py +43 -0
  10. boxrouter/models/eligible_route_gates.py +50 -0
  11. boxrouter/models/eligible_route_ranking.py +85 -0
  12. boxrouter/models/eligible_route_ranking_estimate.py +73 -0
  13. boxrouter/models/eligible_route_ranking_estimate_kind.py +16 -0
  14. boxrouter/models/eligible_route_ranking_reason.py +43 -0
  15. boxrouter/models/eligible_route_resources.py +43 -0
  16. boxrouter/models/granted_gate.py +106 -0
  17. boxrouter/models/granted_gate_also.py +45 -0
  18. boxrouter/models/granted_gate_basis.py +11 -0
  19. boxrouter/models/granted_gate_granted.py +49 -0
  20. boxrouter/models/granted_gate_settings.py +43 -0
  21. boxrouter/models/lifetime.py +270 -0
  22. boxrouter/models/lifetime_at_end.py +11 -0
  23. boxrouter/models/lifetime_ends_at_source_type_1.py +13 -0
  24. boxrouter/models/lifetime_ends_at_source_type_2_type_1.py +16 -0
  25. boxrouter/models/lifetime_ends_at_source_type_3_type_1.py +16 -0
  26. boxrouter/models/lifetime_enforcer.py +11 -0
  27. boxrouter/models/lifetime_max_seconds_type_1.py +13 -0
  28. boxrouter/models/lifetime_max_seconds_type_2.py +32 -0
  29. boxrouter/models/provider_page.py +65 -0
  30. boxrouter/py.typed +1 -0
  31. boxrouter/types.py +51 -0
  32. boxrouter-0.0.1a1.dist-info/METADATA +49 -0
  33. boxrouter-0.0.1a1.dist-info/RECORD +36 -0
  34. boxrouter-0.0.1a1.dist-info/WHEEL +4 -0
  35. boxrouter-0.0.1a1.dist-info/licenses/LICENSE +202 -0
  36. boxrouter-0.0.1a1.dist-info/licenses/NOTICE +16 -0
boxrouter/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ # Generated by openapi-python-client; imports normalized by BoxRouter.
2
+ """A client library for accessing BoxRouter"""
3
+
4
+ from boxrouter.client import AuthenticatedClient, Client
5
+
6
+ __all__ = ("AuthenticatedClient", "Client")
@@ -0,0 +1,2 @@
1
+ # Generated by openapi-python-client; imports normalized by BoxRouter.
2
+ """Contains methods for accessing the API"""
@@ -0,0 +1,2 @@
1
+ # Generated by openapi-python-client; imports normalized by BoxRouter.
2
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,114 @@
1
+ # Generated by openapi-python-client; imports normalized by BoxRouter.
2
+ from http import HTTPStatus
3
+ from typing import Any, cast
4
+
5
+ import httpx
6
+
7
+ from boxrouter.client import AuthenticatedClient, Client
8
+ from boxrouter.models.provider_page import ProviderPage
9
+ from boxrouter.types import Response
10
+
11
+
12
+ def _get_kwargs() -> dict[str, Any]:
13
+ _kwargs: dict[str, Any] = {"method": "get", "url": "/providers"}
14
+ return _kwargs
15
+
16
+
17
+ def _parse_response(
18
+ *, client: AuthenticatedClient | Client, response: httpx.Response
19
+ ) -> Any | ProviderPage:
20
+ if response.status_code == 200:
21
+ response_200 = ProviderPage.from_dict(response.json())
22
+ return response_200
23
+ if response.status_code == 401:
24
+ response_401 = cast(Any, None)
25
+ return response_401
26
+ response_default = cast(Any, None)
27
+ return response_default
28
+
29
+
30
+ def _build_response(
31
+ *, client: AuthenticatedClient | Client, response: httpx.Response
32
+ ) -> Response[Any | ProviderPage]:
33
+ return Response(
34
+ status_code=HTTPStatus(response.status_code),
35
+ content=response.content,
36
+ headers=response.headers,
37
+ parsed=_parse_response(client=client, response=response),
38
+ )
39
+
40
+
41
+ def sync_detailed(*, client: AuthenticatedClient | Client) -> Response[Any | ProviderPage]:
42
+ """List available provider routes
43
+
44
+ Returns only supply visible to the caller, including account-specific
45
+ entitlements and limits. This is a point-in-time eligibility view, not a
46
+ capacity reservation. Unknown or unverified capability guarantees are not
47
+ advertised as supported. Server-side eligibility is rechecked at creation.
48
+
49
+ Raises:
50
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
51
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
52
+
53
+ Returns:
54
+ Response[Any | ProviderPage]
55
+ """
56
+ kwargs = _get_kwargs()
57
+ response = client.get_httpx_client().request(**kwargs)
58
+ return _build_response(client=client, response=response)
59
+
60
+
61
+ def sync(*, client: AuthenticatedClient | Client) -> Any | ProviderPage | None:
62
+ """List available provider routes
63
+
64
+ Returns only supply visible to the caller, including account-specific
65
+ entitlements and limits. This is a point-in-time eligibility view, not a
66
+ capacity reservation. Unknown or unverified capability guarantees are not
67
+ advertised as supported. Server-side eligibility is rechecked at creation.
68
+
69
+ Raises:
70
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
71
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
72
+
73
+ Returns:
74
+ Any | ProviderPage
75
+ """
76
+ return sync_detailed(client=client).parsed
77
+
78
+
79
+ async def asyncio_detailed(*, client: AuthenticatedClient | Client) -> Response[Any | ProviderPage]:
80
+ """List available provider routes
81
+
82
+ Returns only supply visible to the caller, including account-specific
83
+ entitlements and limits. This is a point-in-time eligibility view, not a
84
+ capacity reservation. Unknown or unverified capability guarantees are not
85
+ advertised as supported. Server-side eligibility is rechecked at creation.
86
+
87
+ Raises:
88
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
89
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
90
+
91
+ Returns:
92
+ Response[Any | ProviderPage]
93
+ """
94
+ kwargs = _get_kwargs()
95
+ response = await client.get_async_httpx_client().request(**kwargs)
96
+ return _build_response(client=client, response=response)
97
+
98
+
99
+ async def asyncio(*, client: AuthenticatedClient | Client) -> Any | ProviderPage | None:
100
+ """List available provider routes
101
+
102
+ Returns only supply visible to the caller, including account-specific
103
+ entitlements and limits. This is a point-in-time eligibility view, not a
104
+ capacity reservation. Unknown or unverified capability guarantees are not
105
+ advertised as supported. Server-side eligibility is rechecked at creation.
106
+
107
+ Raises:
108
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
109
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
110
+
111
+ Returns:
112
+ Any | ProviderPage
113
+ """
114
+ return (await asyncio_detailed(client=client)).parsed
boxrouter/client.py ADDED
@@ -0,0 +1,272 @@
1
+ # Generated by openapi-python-client; imports normalized by BoxRouter.
2
+ import ssl
3
+ from typing import Any, Self
4
+
5
+ import httpx
6
+ from attrs import define, evolve, field
7
+
8
+
9
+ @define(repr=False)
10
+ class Client:
11
+ """A class for keeping track of data related to the API
12
+
13
+ The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
14
+
15
+ ``base_url``: The base URL for the API, all requests are made to a relative path to this URL
16
+
17
+ ``cookies``: A dictionary of cookies to be sent with every request
18
+
19
+ ``headers``: A dictionary of headers to be sent with every request
20
+
21
+ ``timeout``: The maximum amount of a time a request can take. API functions will raise
22
+ httpx.TimeoutException if this is exceeded.
23
+
24
+ ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
25
+ but can be set to False for testing purposes.
26
+
27
+ ``follow_redirects``: Whether or not to follow redirects. Default value is False.
28
+
29
+ ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
30
+
31
+
32
+ Attributes:
33
+ raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
34
+ status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
35
+ argument to the constructor.
36
+ """
37
+
38
+ raise_on_unexpected_status: bool = field(default=False, kw_only=True)
39
+ _base_url: str = field(alias="base_url")
40
+ _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
41
+ _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
42
+ _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
43
+ _verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
44
+ _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
45
+ _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
46
+ _client: httpx.Client | None = field(default=None, init=False)
47
+ _async_client: httpx.AsyncClient | None = field(default=None, init=False)
48
+
49
+ def with_headers(self, headers: dict[str, str]) -> "Client":
50
+ """Get a new client matching this one with additional headers"""
51
+ if self._client is not None:
52
+ self._client.headers.update(headers)
53
+ if self._async_client is not None:
54
+ self._async_client.headers.update(headers)
55
+ return evolve(self, headers={**self._headers, **headers})
56
+
57
+ def with_cookies(self, cookies: dict[str, str]) -> "Client":
58
+ """Get a new client matching this one with additional cookies"""
59
+ if self._client is not None:
60
+ self._client.cookies.update(cookies)
61
+ if self._async_client is not None:
62
+ self._async_client.cookies.update(cookies)
63
+ return evolve(self, cookies={**self._cookies, **cookies})
64
+
65
+ def with_timeout(self, timeout: httpx.Timeout) -> "Client":
66
+ """Get a new client matching this one with a new timeout configuration"""
67
+ if self._client is not None:
68
+ self._client.timeout = timeout
69
+ if self._async_client is not None:
70
+ self._async_client.timeout = timeout
71
+ return evolve(self, timeout=timeout)
72
+
73
+ def set_httpx_client(self, client: httpx.Client) -> Self:
74
+ """Manually set the underlying httpx.Client
75
+
76
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
77
+ """
78
+ self._client = client
79
+ return self
80
+
81
+ def get_httpx_client(self) -> httpx.Client:
82
+ """Get the underlying httpx.Client, constructing a new one if not previously set"""
83
+ if self._client is None:
84
+ self._client = httpx.Client(
85
+ base_url=self._base_url,
86
+ cookies=self._cookies,
87
+ headers=self._headers,
88
+ timeout=self._timeout,
89
+ verify=self._verify_ssl,
90
+ follow_redirects=self._follow_redirects,
91
+ **self._httpx_args,
92
+ )
93
+ return self._client
94
+
95
+ def __enter__(self) -> Self:
96
+ """Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
97
+ self.get_httpx_client().__enter__()
98
+ return self
99
+
100
+ def __exit__(self, *args: Any, **kwargs: Any) -> None:
101
+ """Exit a context manager for internal httpx.Client (see httpx docs)"""
102
+ self.get_httpx_client().__exit__(*args, **kwargs)
103
+
104
+ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self:
105
+ """Manually set the underlying httpx.AsyncClient
106
+
107
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
108
+ """
109
+ self._async_client = async_client
110
+ return self
111
+
112
+ def get_async_httpx_client(self) -> httpx.AsyncClient:
113
+ """Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
114
+ if self._async_client is None:
115
+ self._async_client = httpx.AsyncClient(
116
+ base_url=self._base_url,
117
+ cookies=self._cookies,
118
+ headers=self._headers,
119
+ timeout=self._timeout,
120
+ verify=self._verify_ssl,
121
+ follow_redirects=self._follow_redirects,
122
+ **self._httpx_args,
123
+ )
124
+ return self._async_client
125
+
126
+ async def __aenter__(self) -> Self:
127
+ """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
128
+ await self.get_async_httpx_client().__aenter__()
129
+ return self
130
+
131
+ async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
132
+ """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
133
+ await self.get_async_httpx_client().__aexit__(*args, **kwargs)
134
+
135
+
136
+ @define(repr=False)
137
+ class AuthenticatedClient:
138
+ """A Client which has been authenticated for use on secured endpoints
139
+
140
+ The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
141
+
142
+ ``base_url``: The base URL for the API, all requests are made to a relative path to this URL
143
+
144
+ ``cookies``: A dictionary of cookies to be sent with every request
145
+
146
+ ``headers``: A dictionary of headers to be sent with every request
147
+
148
+ ``timeout``: The maximum amount of a time a request can take. API functions will raise
149
+ httpx.TimeoutException if this is exceeded.
150
+
151
+ ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
152
+ but can be set to False for testing purposes.
153
+
154
+ ``follow_redirects``: Whether or not to follow redirects. Default value is False.
155
+
156
+ ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
157
+
158
+
159
+ Attributes:
160
+ raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
161
+ status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
162
+ argument to the constructor.
163
+ token: The token to use for authentication
164
+ prefix: The prefix to use for the Authorization header
165
+ auth_header_name: The name of the Authorization header
166
+ """
167
+
168
+ raise_on_unexpected_status: bool = field(default=False, kw_only=True)
169
+ _base_url: str = field(alias="base_url")
170
+ _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
171
+ _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
172
+ _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
173
+ _verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
174
+ _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
175
+ _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
176
+ _client: httpx.Client | None = field(default=None, init=False)
177
+ _async_client: httpx.AsyncClient | None = field(default=None, init=False)
178
+ token: str
179
+ prefix: str = "Bearer"
180
+ auth_header_name: str = "Authorization"
181
+
182
+ def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
183
+ """Get a new client matching this one with additional headers"""
184
+ if self._client is not None:
185
+ self._client.headers.update(headers)
186
+ if self._async_client is not None:
187
+ self._async_client.headers.update(headers)
188
+ return evolve(self, headers={**self._headers, **headers})
189
+
190
+ def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
191
+ """Get a new client matching this one with additional cookies"""
192
+ if self._client is not None:
193
+ self._client.cookies.update(cookies)
194
+ if self._async_client is not None:
195
+ self._async_client.cookies.update(cookies)
196
+ return evolve(self, cookies={**self._cookies, **cookies})
197
+
198
+ def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
199
+ """Get a new client matching this one with a new timeout configuration"""
200
+ if self._client is not None:
201
+ self._client.timeout = timeout
202
+ if self._async_client is not None:
203
+ self._async_client.timeout = timeout
204
+ return evolve(self, timeout=timeout)
205
+
206
+ def set_httpx_client(self, client: httpx.Client) -> Self:
207
+ """Manually set the underlying httpx.Client
208
+
209
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
210
+ """
211
+ self._client = client
212
+ return self
213
+
214
+ def get_httpx_client(self) -> httpx.Client:
215
+ """Get the underlying httpx.Client, constructing a new one if not previously set"""
216
+ if self._client is None:
217
+ self._headers[self.auth_header_name] = (
218
+ f"{self.prefix} {self.token}" if self.prefix else self.token
219
+ )
220
+ self._client = httpx.Client(
221
+ base_url=self._base_url,
222
+ cookies=self._cookies,
223
+ headers=self._headers,
224
+ timeout=self._timeout,
225
+ verify=self._verify_ssl,
226
+ follow_redirects=self._follow_redirects,
227
+ **self._httpx_args,
228
+ )
229
+ return self._client
230
+
231
+ def __enter__(self) -> Self:
232
+ """Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
233
+ self.get_httpx_client().__enter__()
234
+ return self
235
+
236
+ def __exit__(self, *args: Any, **kwargs: Any) -> None:
237
+ """Exit a context manager for internal httpx.Client (see httpx docs)"""
238
+ self.get_httpx_client().__exit__(*args, **kwargs)
239
+
240
+ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self:
241
+ """Manually set the underlying httpx.AsyncClient
242
+
243
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
244
+ """
245
+ self._async_client = async_client
246
+ return self
247
+
248
+ def get_async_httpx_client(self) -> httpx.AsyncClient:
249
+ """Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
250
+ if self._async_client is None:
251
+ self._headers[self.auth_header_name] = (
252
+ f"{self.prefix} {self.token}" if self.prefix else self.token
253
+ )
254
+ self._async_client = httpx.AsyncClient(
255
+ base_url=self._base_url,
256
+ cookies=self._cookies,
257
+ headers=self._headers,
258
+ timeout=self._timeout,
259
+ verify=self._verify_ssl,
260
+ follow_redirects=self._follow_redirects,
261
+ **self._httpx_args,
262
+ )
263
+ return self._async_client
264
+
265
+ async def __aenter__(self) -> Self:
266
+ """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
267
+ await self.get_async_httpx_client().__aenter__()
268
+ return self
269
+
270
+ async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
271
+ """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
272
+ await self.get_async_httpx_client().__aexit__(*args, **kwargs)
boxrouter/errors.py ADDED
@@ -0,0 +1,16 @@
1
+ # Generated by openapi-python-client; imports normalized by BoxRouter.
2
+ """Contains shared errors types that can be raised from API functions"""
3
+
4
+
5
+ class UnexpectedStatus(Exception):
6
+ """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
7
+
8
+ def __init__(self, status_code: int, content: bytes):
9
+ self.status_code = status_code
10
+ self.content = content
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,50 @@
1
+ # Generated by openapi-python-client; imports normalized by BoxRouter.
2
+ """Contains all the data models used in inputs/outputs"""
3
+
4
+ from boxrouter.models.eligible_route import EligibleRoute
5
+ from boxrouter.models.eligible_route_attested import EligibleRouteAttested
6
+ from boxrouter.models.eligible_route_gates import EligibleRouteGates
7
+ from boxrouter.models.eligible_route_ranking import EligibleRouteRanking
8
+ from boxrouter.models.eligible_route_ranking_estimate import EligibleRouteRankingEstimate
9
+ from boxrouter.models.eligible_route_ranking_estimate_kind import EligibleRouteRankingEstimateKind
10
+ from boxrouter.models.eligible_route_ranking_reason import EligibleRouteRankingReason
11
+ from boxrouter.models.eligible_route_resources import EligibleRouteResources
12
+ from boxrouter.models.granted_gate import GrantedGate
13
+ from boxrouter.models.granted_gate_also import GrantedGateAlso
14
+ from boxrouter.models.granted_gate_basis import GrantedGateBasis
15
+ from boxrouter.models.granted_gate_granted import GrantedGateGranted
16
+ from boxrouter.models.granted_gate_settings import GrantedGateSettings
17
+ from boxrouter.models.lifetime import Lifetime
18
+ from boxrouter.models.lifetime_at_end import LifetimeAtEnd
19
+ from boxrouter.models.lifetime_ends_at_source_type_1 import LifetimeEndsAtSourceType1
20
+ from boxrouter.models.lifetime_ends_at_source_type_2_type_1 import LifetimeEndsAtSourceType2Type1
21
+ from boxrouter.models.lifetime_ends_at_source_type_3_type_1 import LifetimeEndsAtSourceType3Type1
22
+ from boxrouter.models.lifetime_enforcer import LifetimeEnforcer
23
+ from boxrouter.models.lifetime_max_seconds_type_1 import LifetimeMaxSecondsType1
24
+ from boxrouter.models.lifetime_max_seconds_type_2 import LifetimeMaxSecondsType2
25
+ from boxrouter.models.provider_page import ProviderPage
26
+
27
+ __all__ = (
28
+ "EligibleRoute",
29
+ "EligibleRouteAttested",
30
+ "EligibleRouteGates",
31
+ "EligibleRouteRanking",
32
+ "EligibleRouteRankingEstimate",
33
+ "EligibleRouteRankingEstimateKind",
34
+ "EligibleRouteRankingReason",
35
+ "EligibleRouteResources",
36
+ "GrantedGate",
37
+ "GrantedGateAlso",
38
+ "GrantedGateBasis",
39
+ "GrantedGateGranted",
40
+ "GrantedGateSettings",
41
+ "Lifetime",
42
+ "LifetimeAtEnd",
43
+ "LifetimeEndsAtSourceType1",
44
+ "LifetimeEndsAtSourceType2Type1",
45
+ "LifetimeEndsAtSourceType3Type1",
46
+ "LifetimeEnforcer",
47
+ "LifetimeMaxSecondsType1",
48
+ "LifetimeMaxSecondsType2",
49
+ "ProviderPage",
50
+ )
@@ -0,0 +1,148 @@
1
+ # Generated by openapi-python-client; imports normalized by BoxRouter.
2
+ from __future__ import annotations
3
+
4
+ from collections.abc import Mapping
5
+ from typing import Any, TypeVar, cast
6
+
7
+ from attrs import define as _attrs_define
8
+ from attrs import field as _attrs_field
9
+
10
+ from boxrouter.models.eligible_route_attested import EligibleRouteAttested
11
+ from boxrouter.models.eligible_route_gates import EligibleRouteGates
12
+ from boxrouter.models.eligible_route_ranking import EligibleRouteRanking
13
+ from boxrouter.models.eligible_route_resources import EligibleRouteResources
14
+ from boxrouter.models.lifetime import Lifetime
15
+ from boxrouter.types import UNSET, Unset
16
+
17
+ T = TypeVar("T", bound="EligibleRoute")
18
+
19
+
20
+ @_attrs_define
21
+ class EligibleRoute:
22
+ """One candidate that fits, with the contract it would grant.
23
+
24
+ Attributes:
25
+ provider (str):
26
+ class_ (None | str):
27
+ account_id (None | str):
28
+ supply (str):
29
+ adapter_version (str):
30
+ gates (EligibleRouteGates):
31
+ resources (EligibleRouteResources):
32
+ attested (EligibleRouteAttested):
33
+ lifetime (Lifetime): How long the provider lets the sandbox live. It counts from the provider's create, as
34
+ with the provider's own SDK (BoxRouter's clock starts when it sends the create), and the
35
+ provider's own timer ends the sandbox (enforcer provider). Whether paused or stopped
36
+ time counts depends on the provider.
37
+ ranking (EligibleRouteRanking | Unset): Why this route sits where it does in the order creation would try, with
38
+ the price estimate
39
+ the order may rest on. It explains the ordering of this dry run; creation re-ranks with the
40
+ signals of that moment. Absent on responses from a Cloud that predates it.
41
+ """
42
+
43
+ provider: str
44
+ class_: None | str
45
+ account_id: None | str
46
+ supply: str
47
+ adapter_version: str
48
+ gates: EligibleRouteGates
49
+ resources: EligibleRouteResources
50
+ attested: EligibleRouteAttested
51
+ lifetime: Lifetime
52
+ ranking: EligibleRouteRanking | Unset = UNSET
53
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
54
+
55
+ def to_dict(self) -> dict[str, Any]:
56
+ provider = self.provider
57
+ class_: None | str
58
+ class_ = self.class_
59
+ account_id: None | str
60
+ account_id = self.account_id
61
+ supply = self.supply
62
+ adapter_version = self.adapter_version
63
+ gates = self.gates.to_dict()
64
+ resources = self.resources.to_dict()
65
+ attested = self.attested.to_dict()
66
+ lifetime = self.lifetime.to_dict()
67
+ ranking: dict[str, Any] | Unset = UNSET
68
+ if not isinstance(self.ranking, Unset):
69
+ ranking = self.ranking.to_dict()
70
+ field_dict: dict[str, Any] = {}
71
+ field_dict.update(self.additional_properties)
72
+ field_dict.update(
73
+ {
74
+ "provider": provider,
75
+ "class": class_,
76
+ "account_id": account_id,
77
+ "supply": supply,
78
+ "adapter_version": adapter_version,
79
+ "gates": gates,
80
+ "resources": resources,
81
+ "attested": attested,
82
+ "lifetime": lifetime,
83
+ }
84
+ )
85
+ if ranking is not UNSET:
86
+ field_dict["ranking"] = ranking
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
+ provider = d.pop("provider")
93
+
94
+ def _parse_class_(data: object) -> None | str:
95
+ if data is None:
96
+ return data
97
+ return cast(None | str, data)
98
+
99
+ class_ = _parse_class_(d.pop("class"))
100
+
101
+ def _parse_account_id(data: object) -> None | str:
102
+ if data is None:
103
+ return data
104
+ return cast(None | str, data)
105
+
106
+ account_id = _parse_account_id(d.pop("account_id"))
107
+ supply = d.pop("supply")
108
+ adapter_version = d.pop("adapter_version")
109
+ gates = EligibleRouteGates.from_dict(d.pop("gates"))
110
+ resources = EligibleRouteResources.from_dict(d.pop("resources"))
111
+ attested = EligibleRouteAttested.from_dict(d.pop("attested"))
112
+ lifetime = Lifetime.from_dict(d.pop("lifetime"))
113
+ _ranking = d.pop("ranking", UNSET)
114
+ ranking: EligibleRouteRanking | Unset
115
+ if isinstance(_ranking, Unset):
116
+ ranking = UNSET
117
+ else:
118
+ ranking = EligibleRouteRanking.from_dict(_ranking)
119
+ eligible_route = cls(
120
+ provider=provider,
121
+ class_=class_,
122
+ account_id=account_id,
123
+ supply=supply,
124
+ adapter_version=adapter_version,
125
+ gates=gates,
126
+ resources=resources,
127
+ attested=attested,
128
+ lifetime=lifetime,
129
+ ranking=ranking,
130
+ )
131
+ eligible_route.additional_properties = d
132
+ return eligible_route
133
+
134
+ @property
135
+ def additional_keys(self) -> list[str]:
136
+ return list(self.additional_properties.keys())
137
+
138
+ def __getitem__(self, key: str) -> Any:
139
+ return self.additional_properties[key]
140
+
141
+ def __setitem__(self, key: str, value: Any) -> None:
142
+ self.additional_properties[key] = value
143
+
144
+ def __delitem__(self, key: str) -> None:
145
+ del self.additional_properties[key]
146
+
147
+ def __contains__(self, key: str) -> bool:
148
+ return key in self.additional_properties
@@ -0,0 +1,43 @@
1
+ # Generated by openapi-python-client; imports normalized by BoxRouter.
2
+ from __future__ import annotations
3
+
4
+ from collections.abc import Mapping
5
+ from typing import Any, TypeVar
6
+
7
+ from attrs import define as _attrs_define
8
+ from attrs import field as _attrs_field
9
+
10
+ T = TypeVar("T", bound="EligibleRouteAttested")
11
+
12
+
13
+ @_attrs_define
14
+ class EligibleRouteAttested:
15
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
16
+
17
+ def to_dict(self) -> dict[str, Any]:
18
+ field_dict: dict[str, Any] = {}
19
+ field_dict.update(self.additional_properties)
20
+ return field_dict
21
+
22
+ @classmethod
23
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
24
+ d = dict(src_dict)
25
+ eligible_route_attested = cls()
26
+ eligible_route_attested.additional_properties = d
27
+ return eligible_route_attested
28
+
29
+ @property
30
+ def additional_keys(self) -> list[str]:
31
+ return list(self.additional_properties.keys())
32
+
33
+ def __getitem__(self, key: str) -> Any:
34
+ return self.additional_properties[key]
35
+
36
+ def __setitem__(self, key: str, value: Any) -> None:
37
+ self.additional_properties[key] = value
38
+
39
+ def __delitem__(self, key: str) -> None:
40
+ del self.additional_properties[key]
41
+
42
+ def __contains__(self, key: str) -> bool:
43
+ return key in self.additional_properties