contextbase-base-client 0.5.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.
- base_client/.fern/metadata.json +13 -0
- base_client/CONTRIBUTING.md +125 -0
- base_client/README.md +176 -0
- base_client/__init__.py +159 -0
- base_client/_default_clients.py +30 -0
- base_client/bases/__init__.py +34 -0
- base_client/bases/client.py +256 -0
- base_client/bases/raw_client.py +365 -0
- base_client/bases/types/__init__.py +34 -0
- base_client/bases/types/list_bases_response.py +20 -0
- base_client/binding_plan/__init__.py +4 -0
- base_client/binding_plan/client.py +108 -0
- base_client/binding_plan/raw_client.py +128 -0
- base_client/bindings/__init__.py +34 -0
- base_client/bindings/client.py +242 -0
- base_client/bindings/raw_client.py +326 -0
- base_client/bindings/types/__init__.py +34 -0
- base_client/bindings/types/list_bindings_response.py +20 -0
- base_client/client.py +252 -0
- base_client/core/__init__.py +127 -0
- base_client/core/api_error.py +23 -0
- base_client/core/client_wrapper.py +102 -0
- base_client/core/datetime_utils.py +70 -0
- base_client/core/file.py +67 -0
- base_client/core/force_multipart.py +18 -0
- base_client/core/http_client.py +839 -0
- base_client/core/http_response.py +59 -0
- base_client/core/http_sse/__init__.py +42 -0
- base_client/core/http_sse/_api.py +170 -0
- base_client/core/http_sse/_decoders.py +61 -0
- base_client/core/http_sse/_exceptions.py +7 -0
- base_client/core/http_sse/_models.py +17 -0
- base_client/core/jsonable_encoder.py +120 -0
- base_client/core/logging.py +107 -0
- base_client/core/parse_error.py +36 -0
- base_client/core/pydantic_utilities.py +508 -0
- base_client/core/query_encoder.py +58 -0
- base_client/core/remove_none_from_dict.py +11 -0
- base_client/core/request_options.py +35 -0
- base_client/core/serialization.py +347 -0
- base_client/dsn/__init__.py +4 -0
- base_client/dsn/client.py +104 -0
- base_client/dsn/raw_client.py +128 -0
- base_client/errors/__init__.py +38 -0
- base_client/errors/bad_request_error.py +11 -0
- base_client/errors/forbidden_error.py +11 -0
- base_client/reference.md +591 -0
- base_client/sync_state/__init__.py +34 -0
- base_client/sync_state/client.py +206 -0
- base_client/sync_state/raw_client.py +280 -0
- base_client/sync_state/types/__init__.py +34 -0
- base_client/sync_state/types/sync_state_input_bindings_value.py +23 -0
- base_client/tests/conftest.py +21 -0
- base_client/tests/test_aiohttp_autodetect.py +113 -0
- base_client/types/__init__.py +126 -0
- base_client/types/api_key_auth.py +19 -0
- base_client/types/authenticated_account_ref.py +20 -0
- base_client/types/base.py +23 -0
- base_client/types/binding.py +29 -0
- base_client/types/binding_auth.py +72 -0
- base_client/types/binding_auth_input.py +77 -0
- base_client/types/binding_auth_input_api_key.py +19 -0
- base_client/types/binding_auth_input_authenticated_account.py +20 -0
- base_client/types/binding_auth_input_client_credentials.py +20 -0
- base_client/types/binding_auth_input_none.py +17 -0
- base_client/types/binding_auth_none.py +17 -0
- base_client/types/binding_models.py +23 -0
- base_client/types/binding_state.py +24 -0
- base_client/types/binding_state_response.py +21 -0
- base_client/types/client_credentials_auth.py +20 -0
- base_client/types/dagster_all_plan_binding.py +27 -0
- base_client/types/dagster_all_plan_binding_mode.py +5 -0
- base_client/types/dagster_binding_plan_all.py +23 -0
- base_client/types/dsn_response.py +19 -0
- base_client/types/error.py +19 -0
- base_client/types/run_status.py +10 -0
- contextbase_base_client-0.5.0.dist-info/METADATA +10 -0
- contextbase_base_client-0.5.0.dist-info/RECORD +79 -0
- contextbase_base_client-0.5.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
6
|
+
from ..core.request_options import RequestOptions
|
|
7
|
+
from ..types.base import Base
|
|
8
|
+
from .raw_client import AsyncRawBasesClient, RawBasesClient
|
|
9
|
+
from .types.list_bases_response import ListBasesResponse
|
|
10
|
+
|
|
11
|
+
# this is used as the default value for optional parameters
|
|
12
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class BasesClient:
|
|
16
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
17
|
+
self._raw_client = RawBasesClient(client_wrapper=client_wrapper)
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def with_raw_response(self) -> RawBasesClient:
|
|
21
|
+
"""
|
|
22
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
RawBasesClient
|
|
27
|
+
"""
|
|
28
|
+
return self._raw_client
|
|
29
|
+
|
|
30
|
+
def list_bases(self, *, request_options: typing.Optional[RequestOptions] = None) -> ListBasesResponse:
|
|
31
|
+
"""
|
|
32
|
+
Parameters
|
|
33
|
+
----------
|
|
34
|
+
request_options : typing.Optional[RequestOptions]
|
|
35
|
+
Request-specific configuration.
|
|
36
|
+
|
|
37
|
+
Returns
|
|
38
|
+
-------
|
|
39
|
+
ListBasesResponse
|
|
40
|
+
The caller's bases (a machine caller, as deployment-root, gets the full list).
|
|
41
|
+
|
|
42
|
+
Examples
|
|
43
|
+
--------
|
|
44
|
+
from base_client import BaseAPIClient
|
|
45
|
+
|
|
46
|
+
client = BaseAPIClient(
|
|
47
|
+
base_url="https://yourhost.com/path/to/api",
|
|
48
|
+
)
|
|
49
|
+
client.bases.list_bases()
|
|
50
|
+
"""
|
|
51
|
+
_response = self._raw_client.list_bases(request_options=request_options)
|
|
52
|
+
return _response.data
|
|
53
|
+
|
|
54
|
+
def create_base(
|
|
55
|
+
self,
|
|
56
|
+
*,
|
|
57
|
+
dsn_secret: str,
|
|
58
|
+
name: str,
|
|
59
|
+
owner_user_id: typing.Optional[str] = OMIT,
|
|
60
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
61
|
+
) -> Base:
|
|
62
|
+
"""
|
|
63
|
+
Parameters
|
|
64
|
+
----------
|
|
65
|
+
dsn_secret : str
|
|
66
|
+
|
|
67
|
+
name : str
|
|
68
|
+
|
|
69
|
+
owner_user_id : typing.Optional[str]
|
|
70
|
+
|
|
71
|
+
request_options : typing.Optional[RequestOptions]
|
|
72
|
+
Request-specific configuration.
|
|
73
|
+
|
|
74
|
+
Returns
|
|
75
|
+
-------
|
|
76
|
+
Base
|
|
77
|
+
The created base.
|
|
78
|
+
|
|
79
|
+
Examples
|
|
80
|
+
--------
|
|
81
|
+
from base_client import BaseAPIClient
|
|
82
|
+
|
|
83
|
+
client = BaseAPIClient(
|
|
84
|
+
base_url="https://yourhost.com/path/to/api",
|
|
85
|
+
)
|
|
86
|
+
client.bases.create_base(
|
|
87
|
+
dsn_secret="dsn_secret",
|
|
88
|
+
name="name",
|
|
89
|
+
)
|
|
90
|
+
"""
|
|
91
|
+
_response = self._raw_client.create_base(
|
|
92
|
+
dsn_secret=dsn_secret, name=name, owner_user_id=owner_user_id, request_options=request_options
|
|
93
|
+
)
|
|
94
|
+
return _response.data
|
|
95
|
+
|
|
96
|
+
def get_base(self, base_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Base:
|
|
97
|
+
"""
|
|
98
|
+
Parameters
|
|
99
|
+
----------
|
|
100
|
+
base_id : str
|
|
101
|
+
|
|
102
|
+
request_options : typing.Optional[RequestOptions]
|
|
103
|
+
Request-specific configuration.
|
|
104
|
+
|
|
105
|
+
Returns
|
|
106
|
+
-------
|
|
107
|
+
Base
|
|
108
|
+
The base.
|
|
109
|
+
|
|
110
|
+
Examples
|
|
111
|
+
--------
|
|
112
|
+
from base_client import BaseAPIClient
|
|
113
|
+
|
|
114
|
+
client = BaseAPIClient(
|
|
115
|
+
base_url="https://yourhost.com/path/to/api",
|
|
116
|
+
)
|
|
117
|
+
client.bases.get_base(
|
|
118
|
+
base_id="base_id",
|
|
119
|
+
)
|
|
120
|
+
"""
|
|
121
|
+
_response = self._raw_client.get_base(base_id, request_options=request_options)
|
|
122
|
+
return _response.data
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class AsyncBasesClient:
|
|
126
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
127
|
+
self._raw_client = AsyncRawBasesClient(client_wrapper=client_wrapper)
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def with_raw_response(self) -> AsyncRawBasesClient:
|
|
131
|
+
"""
|
|
132
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
133
|
+
|
|
134
|
+
Returns
|
|
135
|
+
-------
|
|
136
|
+
AsyncRawBasesClient
|
|
137
|
+
"""
|
|
138
|
+
return self._raw_client
|
|
139
|
+
|
|
140
|
+
async def list_bases(self, *, request_options: typing.Optional[RequestOptions] = None) -> ListBasesResponse:
|
|
141
|
+
"""
|
|
142
|
+
Parameters
|
|
143
|
+
----------
|
|
144
|
+
request_options : typing.Optional[RequestOptions]
|
|
145
|
+
Request-specific configuration.
|
|
146
|
+
|
|
147
|
+
Returns
|
|
148
|
+
-------
|
|
149
|
+
ListBasesResponse
|
|
150
|
+
The caller's bases (a machine caller, as deployment-root, gets the full list).
|
|
151
|
+
|
|
152
|
+
Examples
|
|
153
|
+
--------
|
|
154
|
+
import asyncio
|
|
155
|
+
|
|
156
|
+
from base_client import AsyncBaseAPIClient
|
|
157
|
+
|
|
158
|
+
client = AsyncBaseAPIClient(
|
|
159
|
+
base_url="https://yourhost.com/path/to/api",
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
async def main() -> None:
|
|
164
|
+
await client.bases.list_bases()
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
asyncio.run(main())
|
|
168
|
+
"""
|
|
169
|
+
_response = await self._raw_client.list_bases(request_options=request_options)
|
|
170
|
+
return _response.data
|
|
171
|
+
|
|
172
|
+
async def create_base(
|
|
173
|
+
self,
|
|
174
|
+
*,
|
|
175
|
+
dsn_secret: str,
|
|
176
|
+
name: str,
|
|
177
|
+
owner_user_id: typing.Optional[str] = OMIT,
|
|
178
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
179
|
+
) -> Base:
|
|
180
|
+
"""
|
|
181
|
+
Parameters
|
|
182
|
+
----------
|
|
183
|
+
dsn_secret : str
|
|
184
|
+
|
|
185
|
+
name : str
|
|
186
|
+
|
|
187
|
+
owner_user_id : typing.Optional[str]
|
|
188
|
+
|
|
189
|
+
request_options : typing.Optional[RequestOptions]
|
|
190
|
+
Request-specific configuration.
|
|
191
|
+
|
|
192
|
+
Returns
|
|
193
|
+
-------
|
|
194
|
+
Base
|
|
195
|
+
The created base.
|
|
196
|
+
|
|
197
|
+
Examples
|
|
198
|
+
--------
|
|
199
|
+
import asyncio
|
|
200
|
+
|
|
201
|
+
from base_client import AsyncBaseAPIClient
|
|
202
|
+
|
|
203
|
+
client = AsyncBaseAPIClient(
|
|
204
|
+
base_url="https://yourhost.com/path/to/api",
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
async def main() -> None:
|
|
209
|
+
await client.bases.create_base(
|
|
210
|
+
dsn_secret="dsn_secret",
|
|
211
|
+
name="name",
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
asyncio.run(main())
|
|
216
|
+
"""
|
|
217
|
+
_response = await self._raw_client.create_base(
|
|
218
|
+
dsn_secret=dsn_secret, name=name, owner_user_id=owner_user_id, request_options=request_options
|
|
219
|
+
)
|
|
220
|
+
return _response.data
|
|
221
|
+
|
|
222
|
+
async def get_base(self, base_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Base:
|
|
223
|
+
"""
|
|
224
|
+
Parameters
|
|
225
|
+
----------
|
|
226
|
+
base_id : str
|
|
227
|
+
|
|
228
|
+
request_options : typing.Optional[RequestOptions]
|
|
229
|
+
Request-specific configuration.
|
|
230
|
+
|
|
231
|
+
Returns
|
|
232
|
+
-------
|
|
233
|
+
Base
|
|
234
|
+
The base.
|
|
235
|
+
|
|
236
|
+
Examples
|
|
237
|
+
--------
|
|
238
|
+
import asyncio
|
|
239
|
+
|
|
240
|
+
from base_client import AsyncBaseAPIClient
|
|
241
|
+
|
|
242
|
+
client = AsyncBaseAPIClient(
|
|
243
|
+
base_url="https://yourhost.com/path/to/api",
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
async def main() -> None:
|
|
248
|
+
await client.bases.get_base(
|
|
249
|
+
base_id="base_id",
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
asyncio.run(main())
|
|
254
|
+
"""
|
|
255
|
+
_response = await self._raw_client.get_base(base_id, request_options=request_options)
|
|
256
|
+
return _response.data
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ..core.api_error import ApiError
|
|
7
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
+
from ..core.jsonable_encoder import encode_path_param
|
|
10
|
+
from ..core.parse_error import ParsingError
|
|
11
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
12
|
+
from ..core.request_options import RequestOptions
|
|
13
|
+
from ..errors.bad_request_error import BadRequestError
|
|
14
|
+
from ..errors.forbidden_error import ForbiddenError
|
|
15
|
+
from ..types.base import Base
|
|
16
|
+
from ..types.error import Error
|
|
17
|
+
from .types.list_bases_response import ListBasesResponse
|
|
18
|
+
from pydantic import ValidationError
|
|
19
|
+
|
|
20
|
+
# this is used as the default value for optional parameters
|
|
21
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class RawBasesClient:
|
|
25
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
26
|
+
self._client_wrapper = client_wrapper
|
|
27
|
+
|
|
28
|
+
def list_bases(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[ListBasesResponse]:
|
|
29
|
+
"""
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
request_options : typing.Optional[RequestOptions]
|
|
33
|
+
Request-specific configuration.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
HttpResponse[ListBasesResponse]
|
|
38
|
+
The caller's bases (a machine caller, as deployment-root, gets the full list).
|
|
39
|
+
"""
|
|
40
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
41
|
+
"base/bases",
|
|
42
|
+
method="GET",
|
|
43
|
+
request_options=request_options,
|
|
44
|
+
)
|
|
45
|
+
try:
|
|
46
|
+
if 200 <= _response.status_code < 300:
|
|
47
|
+
_data = typing.cast(
|
|
48
|
+
ListBasesResponse,
|
|
49
|
+
parse_obj_as(
|
|
50
|
+
type_=ListBasesResponse, # type: ignore
|
|
51
|
+
object_=_response.json(),
|
|
52
|
+
),
|
|
53
|
+
)
|
|
54
|
+
return HttpResponse(response=_response, data=_data)
|
|
55
|
+
_response_json = _response.json()
|
|
56
|
+
except JSONDecodeError:
|
|
57
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
58
|
+
except ValidationError as e:
|
|
59
|
+
raise ParsingError(
|
|
60
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
61
|
+
)
|
|
62
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
63
|
+
|
|
64
|
+
def create_base(
|
|
65
|
+
self,
|
|
66
|
+
*,
|
|
67
|
+
dsn_secret: str,
|
|
68
|
+
name: str,
|
|
69
|
+
owner_user_id: typing.Optional[str] = OMIT,
|
|
70
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
71
|
+
) -> HttpResponse[Base]:
|
|
72
|
+
"""
|
|
73
|
+
Parameters
|
|
74
|
+
----------
|
|
75
|
+
dsn_secret : str
|
|
76
|
+
|
|
77
|
+
name : str
|
|
78
|
+
|
|
79
|
+
owner_user_id : typing.Optional[str]
|
|
80
|
+
|
|
81
|
+
request_options : typing.Optional[RequestOptions]
|
|
82
|
+
Request-specific configuration.
|
|
83
|
+
|
|
84
|
+
Returns
|
|
85
|
+
-------
|
|
86
|
+
HttpResponse[Base]
|
|
87
|
+
The created base.
|
|
88
|
+
"""
|
|
89
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
90
|
+
"base/bases",
|
|
91
|
+
method="POST",
|
|
92
|
+
json={
|
|
93
|
+
"dsn_secret": dsn_secret,
|
|
94
|
+
"name": name,
|
|
95
|
+
"owner_user_id": owner_user_id,
|
|
96
|
+
},
|
|
97
|
+
headers={
|
|
98
|
+
"content-type": "application/json",
|
|
99
|
+
},
|
|
100
|
+
request_options=request_options,
|
|
101
|
+
omit=OMIT,
|
|
102
|
+
)
|
|
103
|
+
try:
|
|
104
|
+
if 200 <= _response.status_code < 300:
|
|
105
|
+
_data = typing.cast(
|
|
106
|
+
Base,
|
|
107
|
+
parse_obj_as(
|
|
108
|
+
type_=Base, # type: ignore
|
|
109
|
+
object_=_response.json(),
|
|
110
|
+
),
|
|
111
|
+
)
|
|
112
|
+
return HttpResponse(response=_response, data=_data)
|
|
113
|
+
if _response.status_code == 400:
|
|
114
|
+
raise BadRequestError(
|
|
115
|
+
headers=dict(_response.headers),
|
|
116
|
+
body=typing.cast(
|
|
117
|
+
Error,
|
|
118
|
+
parse_obj_as(
|
|
119
|
+
type_=Error, # type: ignore
|
|
120
|
+
object_=_response.json(),
|
|
121
|
+
),
|
|
122
|
+
),
|
|
123
|
+
)
|
|
124
|
+
if _response.status_code == 403:
|
|
125
|
+
raise ForbiddenError(
|
|
126
|
+
headers=dict(_response.headers),
|
|
127
|
+
body=typing.cast(
|
|
128
|
+
Error,
|
|
129
|
+
parse_obj_as(
|
|
130
|
+
type_=Error, # type: ignore
|
|
131
|
+
object_=_response.json(),
|
|
132
|
+
),
|
|
133
|
+
),
|
|
134
|
+
)
|
|
135
|
+
_response_json = _response.json()
|
|
136
|
+
except JSONDecodeError:
|
|
137
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
138
|
+
except ValidationError as e:
|
|
139
|
+
raise ParsingError(
|
|
140
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
141
|
+
)
|
|
142
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
143
|
+
|
|
144
|
+
def get_base(self, base_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[Base]:
|
|
145
|
+
"""
|
|
146
|
+
Parameters
|
|
147
|
+
----------
|
|
148
|
+
base_id : str
|
|
149
|
+
|
|
150
|
+
request_options : typing.Optional[RequestOptions]
|
|
151
|
+
Request-specific configuration.
|
|
152
|
+
|
|
153
|
+
Returns
|
|
154
|
+
-------
|
|
155
|
+
HttpResponse[Base]
|
|
156
|
+
The base.
|
|
157
|
+
"""
|
|
158
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
159
|
+
f"base/bases/{encode_path_param(base_id)}",
|
|
160
|
+
method="GET",
|
|
161
|
+
request_options=request_options,
|
|
162
|
+
)
|
|
163
|
+
try:
|
|
164
|
+
if 200 <= _response.status_code < 300:
|
|
165
|
+
_data = typing.cast(
|
|
166
|
+
Base,
|
|
167
|
+
parse_obj_as(
|
|
168
|
+
type_=Base, # type: ignore
|
|
169
|
+
object_=_response.json(),
|
|
170
|
+
),
|
|
171
|
+
)
|
|
172
|
+
return HttpResponse(response=_response, data=_data)
|
|
173
|
+
if _response.status_code == 403:
|
|
174
|
+
raise ForbiddenError(
|
|
175
|
+
headers=dict(_response.headers),
|
|
176
|
+
body=typing.cast(
|
|
177
|
+
Error,
|
|
178
|
+
parse_obj_as(
|
|
179
|
+
type_=Error, # type: ignore
|
|
180
|
+
object_=_response.json(),
|
|
181
|
+
),
|
|
182
|
+
),
|
|
183
|
+
)
|
|
184
|
+
_response_json = _response.json()
|
|
185
|
+
except JSONDecodeError:
|
|
186
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
187
|
+
except ValidationError as e:
|
|
188
|
+
raise ParsingError(
|
|
189
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
190
|
+
)
|
|
191
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class AsyncRawBasesClient:
|
|
195
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
196
|
+
self._client_wrapper = client_wrapper
|
|
197
|
+
|
|
198
|
+
async def list_bases(
|
|
199
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
200
|
+
) -> AsyncHttpResponse[ListBasesResponse]:
|
|
201
|
+
"""
|
|
202
|
+
Parameters
|
|
203
|
+
----------
|
|
204
|
+
request_options : typing.Optional[RequestOptions]
|
|
205
|
+
Request-specific configuration.
|
|
206
|
+
|
|
207
|
+
Returns
|
|
208
|
+
-------
|
|
209
|
+
AsyncHttpResponse[ListBasesResponse]
|
|
210
|
+
The caller's bases (a machine caller, as deployment-root, gets the full list).
|
|
211
|
+
"""
|
|
212
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
213
|
+
"base/bases",
|
|
214
|
+
method="GET",
|
|
215
|
+
request_options=request_options,
|
|
216
|
+
)
|
|
217
|
+
try:
|
|
218
|
+
if 200 <= _response.status_code < 300:
|
|
219
|
+
_data = typing.cast(
|
|
220
|
+
ListBasesResponse,
|
|
221
|
+
parse_obj_as(
|
|
222
|
+
type_=ListBasesResponse, # type: ignore
|
|
223
|
+
object_=_response.json(),
|
|
224
|
+
),
|
|
225
|
+
)
|
|
226
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
227
|
+
_response_json = _response.json()
|
|
228
|
+
except JSONDecodeError:
|
|
229
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
230
|
+
except ValidationError as e:
|
|
231
|
+
raise ParsingError(
|
|
232
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
233
|
+
)
|
|
234
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
235
|
+
|
|
236
|
+
async def create_base(
|
|
237
|
+
self,
|
|
238
|
+
*,
|
|
239
|
+
dsn_secret: str,
|
|
240
|
+
name: str,
|
|
241
|
+
owner_user_id: typing.Optional[str] = OMIT,
|
|
242
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
243
|
+
) -> AsyncHttpResponse[Base]:
|
|
244
|
+
"""
|
|
245
|
+
Parameters
|
|
246
|
+
----------
|
|
247
|
+
dsn_secret : str
|
|
248
|
+
|
|
249
|
+
name : str
|
|
250
|
+
|
|
251
|
+
owner_user_id : typing.Optional[str]
|
|
252
|
+
|
|
253
|
+
request_options : typing.Optional[RequestOptions]
|
|
254
|
+
Request-specific configuration.
|
|
255
|
+
|
|
256
|
+
Returns
|
|
257
|
+
-------
|
|
258
|
+
AsyncHttpResponse[Base]
|
|
259
|
+
The created base.
|
|
260
|
+
"""
|
|
261
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
262
|
+
"base/bases",
|
|
263
|
+
method="POST",
|
|
264
|
+
json={
|
|
265
|
+
"dsn_secret": dsn_secret,
|
|
266
|
+
"name": name,
|
|
267
|
+
"owner_user_id": owner_user_id,
|
|
268
|
+
},
|
|
269
|
+
headers={
|
|
270
|
+
"content-type": "application/json",
|
|
271
|
+
},
|
|
272
|
+
request_options=request_options,
|
|
273
|
+
omit=OMIT,
|
|
274
|
+
)
|
|
275
|
+
try:
|
|
276
|
+
if 200 <= _response.status_code < 300:
|
|
277
|
+
_data = typing.cast(
|
|
278
|
+
Base,
|
|
279
|
+
parse_obj_as(
|
|
280
|
+
type_=Base, # type: ignore
|
|
281
|
+
object_=_response.json(),
|
|
282
|
+
),
|
|
283
|
+
)
|
|
284
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
285
|
+
if _response.status_code == 400:
|
|
286
|
+
raise BadRequestError(
|
|
287
|
+
headers=dict(_response.headers),
|
|
288
|
+
body=typing.cast(
|
|
289
|
+
Error,
|
|
290
|
+
parse_obj_as(
|
|
291
|
+
type_=Error, # type: ignore
|
|
292
|
+
object_=_response.json(),
|
|
293
|
+
),
|
|
294
|
+
),
|
|
295
|
+
)
|
|
296
|
+
if _response.status_code == 403:
|
|
297
|
+
raise ForbiddenError(
|
|
298
|
+
headers=dict(_response.headers),
|
|
299
|
+
body=typing.cast(
|
|
300
|
+
Error,
|
|
301
|
+
parse_obj_as(
|
|
302
|
+
type_=Error, # type: ignore
|
|
303
|
+
object_=_response.json(),
|
|
304
|
+
),
|
|
305
|
+
),
|
|
306
|
+
)
|
|
307
|
+
_response_json = _response.json()
|
|
308
|
+
except JSONDecodeError:
|
|
309
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
310
|
+
except ValidationError as e:
|
|
311
|
+
raise ParsingError(
|
|
312
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
313
|
+
)
|
|
314
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
315
|
+
|
|
316
|
+
async def get_base(
|
|
317
|
+
self, base_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
318
|
+
) -> AsyncHttpResponse[Base]:
|
|
319
|
+
"""
|
|
320
|
+
Parameters
|
|
321
|
+
----------
|
|
322
|
+
base_id : str
|
|
323
|
+
|
|
324
|
+
request_options : typing.Optional[RequestOptions]
|
|
325
|
+
Request-specific configuration.
|
|
326
|
+
|
|
327
|
+
Returns
|
|
328
|
+
-------
|
|
329
|
+
AsyncHttpResponse[Base]
|
|
330
|
+
The base.
|
|
331
|
+
"""
|
|
332
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
333
|
+
f"base/bases/{encode_path_param(base_id)}",
|
|
334
|
+
method="GET",
|
|
335
|
+
request_options=request_options,
|
|
336
|
+
)
|
|
337
|
+
try:
|
|
338
|
+
if 200 <= _response.status_code < 300:
|
|
339
|
+
_data = typing.cast(
|
|
340
|
+
Base,
|
|
341
|
+
parse_obj_as(
|
|
342
|
+
type_=Base, # type: ignore
|
|
343
|
+
object_=_response.json(),
|
|
344
|
+
),
|
|
345
|
+
)
|
|
346
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
347
|
+
if _response.status_code == 403:
|
|
348
|
+
raise ForbiddenError(
|
|
349
|
+
headers=dict(_response.headers),
|
|
350
|
+
body=typing.cast(
|
|
351
|
+
Error,
|
|
352
|
+
parse_obj_as(
|
|
353
|
+
type_=Error, # type: ignore
|
|
354
|
+
object_=_response.json(),
|
|
355
|
+
),
|
|
356
|
+
),
|
|
357
|
+
)
|
|
358
|
+
_response_json = _response.json()
|
|
359
|
+
except JSONDecodeError:
|
|
360
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
361
|
+
except ValidationError as e:
|
|
362
|
+
raise ParsingError(
|
|
363
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
364
|
+
)
|
|
365
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
from importlib import import_module
|
|
7
|
+
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from .list_bases_response import ListBasesResponse
|
|
10
|
+
_dynamic_imports: typing.Dict[str, str] = {"ListBasesResponse": ".list_bases_response"}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def __getattr__(attr_name: str) -> typing.Any:
|
|
14
|
+
module_name = _dynamic_imports.get(attr_name)
|
|
15
|
+
if module_name is None:
|
|
16
|
+
raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
|
|
17
|
+
try:
|
|
18
|
+
module = import_module(module_name, __package__)
|
|
19
|
+
if module_name == f".{attr_name}":
|
|
20
|
+
return module
|
|
21
|
+
else:
|
|
22
|
+
return getattr(module, attr_name)
|
|
23
|
+
except ImportError as e:
|
|
24
|
+
raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
|
|
25
|
+
except AttributeError as e:
|
|
26
|
+
raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def __dir__():
|
|
30
|
+
lazy_attrs = list(_dynamic_imports.keys())
|
|
31
|
+
return sorted(lazy_attrs)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
__all__ = ["ListBasesResponse"]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
from ...types.base import Base
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ListBasesResponse(UniversalBaseModel):
|
|
11
|
+
bases: typing.List[Base]
|
|
12
|
+
|
|
13
|
+
if IS_PYDANTIC_V2:
|
|
14
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
15
|
+
else:
|
|
16
|
+
|
|
17
|
+
class Config:
|
|
18
|
+
frozen = True
|
|
19
|
+
smart_union = True
|
|
20
|
+
extra = pydantic.Extra.allow
|