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,206 @@
|
|
|
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.binding_state_response import BindingStateResponse
|
|
8
|
+
from .raw_client import AsyncRawSyncStateClient, RawSyncStateClient
|
|
9
|
+
from .types.sync_state_input_bindings_value import SyncStateInputBindingsValue
|
|
10
|
+
|
|
11
|
+
# this is used as the default value for optional parameters
|
|
12
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class SyncStateClient:
|
|
16
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
17
|
+
self._raw_client = RawSyncStateClient(client_wrapper=client_wrapper)
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def with_raw_response(self) -> RawSyncStateClient:
|
|
21
|
+
"""
|
|
22
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
RawSyncStateClient
|
|
27
|
+
"""
|
|
28
|
+
return self._raw_client
|
|
29
|
+
|
|
30
|
+
def get_sync_state(
|
|
31
|
+
self, base_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
32
|
+
) -> BindingStateResponse:
|
|
33
|
+
"""
|
|
34
|
+
Parameters
|
|
35
|
+
----------
|
|
36
|
+
base_id : str
|
|
37
|
+
|
|
38
|
+
request_options : typing.Optional[RequestOptions]
|
|
39
|
+
Request-specific configuration.
|
|
40
|
+
|
|
41
|
+
Returns
|
|
42
|
+
-------
|
|
43
|
+
BindingStateResponse
|
|
44
|
+
Per-binding sync state.
|
|
45
|
+
|
|
46
|
+
Examples
|
|
47
|
+
--------
|
|
48
|
+
from base_client import BaseAPIClient
|
|
49
|
+
|
|
50
|
+
client = BaseAPIClient(
|
|
51
|
+
base_url="https://yourhost.com/path/to/api",
|
|
52
|
+
)
|
|
53
|
+
client.sync_state.get_sync_state(
|
|
54
|
+
base_id="base_id",
|
|
55
|
+
)
|
|
56
|
+
"""
|
|
57
|
+
_response = self._raw_client.get_sync_state(base_id, request_options=request_options)
|
|
58
|
+
return _response.data
|
|
59
|
+
|
|
60
|
+
def report_sync_state(
|
|
61
|
+
self,
|
|
62
|
+
base_id: str,
|
|
63
|
+
*,
|
|
64
|
+
bindings: typing.Dict[str, SyncStateInputBindingsValue],
|
|
65
|
+
version: float,
|
|
66
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
67
|
+
) -> None:
|
|
68
|
+
"""
|
|
69
|
+
Parameters
|
|
70
|
+
----------
|
|
71
|
+
base_id : str
|
|
72
|
+
|
|
73
|
+
bindings : typing.Dict[str, SyncStateInputBindingsValue]
|
|
74
|
+
|
|
75
|
+
version : float
|
|
76
|
+
|
|
77
|
+
request_options : typing.Optional[RequestOptions]
|
|
78
|
+
Request-specific configuration.
|
|
79
|
+
|
|
80
|
+
Returns
|
|
81
|
+
-------
|
|
82
|
+
None
|
|
83
|
+
|
|
84
|
+
Examples
|
|
85
|
+
--------
|
|
86
|
+
from base_client import BaseAPIClient
|
|
87
|
+
from base_client.sync_state import SyncStateInputBindingsValue
|
|
88
|
+
|
|
89
|
+
client = BaseAPIClient(
|
|
90
|
+
base_url="https://yourhost.com/path/to/api",
|
|
91
|
+
)
|
|
92
|
+
client.sync_state.report_sync_state(
|
|
93
|
+
base_id="base_id",
|
|
94
|
+
bindings={"key": SyncStateInputBindingsValue()},
|
|
95
|
+
version=1.1,
|
|
96
|
+
)
|
|
97
|
+
"""
|
|
98
|
+
_response = self._raw_client.report_sync_state(
|
|
99
|
+
base_id, bindings=bindings, version=version, request_options=request_options
|
|
100
|
+
)
|
|
101
|
+
return _response.data
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class AsyncSyncStateClient:
|
|
105
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
106
|
+
self._raw_client = AsyncRawSyncStateClient(client_wrapper=client_wrapper)
|
|
107
|
+
|
|
108
|
+
@property
|
|
109
|
+
def with_raw_response(self) -> AsyncRawSyncStateClient:
|
|
110
|
+
"""
|
|
111
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
112
|
+
|
|
113
|
+
Returns
|
|
114
|
+
-------
|
|
115
|
+
AsyncRawSyncStateClient
|
|
116
|
+
"""
|
|
117
|
+
return self._raw_client
|
|
118
|
+
|
|
119
|
+
async def get_sync_state(
|
|
120
|
+
self, base_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
121
|
+
) -> BindingStateResponse:
|
|
122
|
+
"""
|
|
123
|
+
Parameters
|
|
124
|
+
----------
|
|
125
|
+
base_id : str
|
|
126
|
+
|
|
127
|
+
request_options : typing.Optional[RequestOptions]
|
|
128
|
+
Request-specific configuration.
|
|
129
|
+
|
|
130
|
+
Returns
|
|
131
|
+
-------
|
|
132
|
+
BindingStateResponse
|
|
133
|
+
Per-binding sync state.
|
|
134
|
+
|
|
135
|
+
Examples
|
|
136
|
+
--------
|
|
137
|
+
import asyncio
|
|
138
|
+
|
|
139
|
+
from base_client import AsyncBaseAPIClient
|
|
140
|
+
|
|
141
|
+
client = AsyncBaseAPIClient(
|
|
142
|
+
base_url="https://yourhost.com/path/to/api",
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
async def main() -> None:
|
|
147
|
+
await client.sync_state.get_sync_state(
|
|
148
|
+
base_id="base_id",
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
asyncio.run(main())
|
|
153
|
+
"""
|
|
154
|
+
_response = await self._raw_client.get_sync_state(base_id, request_options=request_options)
|
|
155
|
+
return _response.data
|
|
156
|
+
|
|
157
|
+
async def report_sync_state(
|
|
158
|
+
self,
|
|
159
|
+
base_id: str,
|
|
160
|
+
*,
|
|
161
|
+
bindings: typing.Dict[str, SyncStateInputBindingsValue],
|
|
162
|
+
version: float,
|
|
163
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
164
|
+
) -> None:
|
|
165
|
+
"""
|
|
166
|
+
Parameters
|
|
167
|
+
----------
|
|
168
|
+
base_id : str
|
|
169
|
+
|
|
170
|
+
bindings : typing.Dict[str, SyncStateInputBindingsValue]
|
|
171
|
+
|
|
172
|
+
version : float
|
|
173
|
+
|
|
174
|
+
request_options : typing.Optional[RequestOptions]
|
|
175
|
+
Request-specific configuration.
|
|
176
|
+
|
|
177
|
+
Returns
|
|
178
|
+
-------
|
|
179
|
+
None
|
|
180
|
+
|
|
181
|
+
Examples
|
|
182
|
+
--------
|
|
183
|
+
import asyncio
|
|
184
|
+
|
|
185
|
+
from base_client import AsyncBaseAPIClient
|
|
186
|
+
from base_client.sync_state import SyncStateInputBindingsValue
|
|
187
|
+
|
|
188
|
+
client = AsyncBaseAPIClient(
|
|
189
|
+
base_url="https://yourhost.com/path/to/api",
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
async def main() -> None:
|
|
194
|
+
await client.sync_state.report_sync_state(
|
|
195
|
+
base_id="base_id",
|
|
196
|
+
bindings={"key": SyncStateInputBindingsValue()},
|
|
197
|
+
version=1.1,
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
asyncio.run(main())
|
|
202
|
+
"""
|
|
203
|
+
_response = await self._raw_client.report_sync_state(
|
|
204
|
+
base_id, bindings=bindings, version=version, request_options=request_options
|
|
205
|
+
)
|
|
206
|
+
return _response.data
|
|
@@ -0,0 +1,280 @@
|
|
|
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 ..core.serialization import convert_and_respect_annotation_metadata
|
|
14
|
+
from ..errors.bad_request_error import BadRequestError
|
|
15
|
+
from ..errors.forbidden_error import ForbiddenError
|
|
16
|
+
from ..types.binding_state_response import BindingStateResponse
|
|
17
|
+
from ..types.error import Error
|
|
18
|
+
from .types.sync_state_input_bindings_value import SyncStateInputBindingsValue
|
|
19
|
+
from pydantic import ValidationError
|
|
20
|
+
|
|
21
|
+
# this is used as the default value for optional parameters
|
|
22
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class RawSyncStateClient:
|
|
26
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
27
|
+
self._client_wrapper = client_wrapper
|
|
28
|
+
|
|
29
|
+
def get_sync_state(
|
|
30
|
+
self, base_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
31
|
+
) -> HttpResponse[BindingStateResponse]:
|
|
32
|
+
"""
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
base_id : str
|
|
36
|
+
|
|
37
|
+
request_options : typing.Optional[RequestOptions]
|
|
38
|
+
Request-specific configuration.
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
HttpResponse[BindingStateResponse]
|
|
43
|
+
Per-binding sync state.
|
|
44
|
+
"""
|
|
45
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
46
|
+
f"base/bases/{encode_path_param(base_id)}/sync-state",
|
|
47
|
+
method="GET",
|
|
48
|
+
request_options=request_options,
|
|
49
|
+
)
|
|
50
|
+
try:
|
|
51
|
+
if 200 <= _response.status_code < 300:
|
|
52
|
+
_data = typing.cast(
|
|
53
|
+
BindingStateResponse,
|
|
54
|
+
parse_obj_as(
|
|
55
|
+
type_=BindingStateResponse, # type: ignore
|
|
56
|
+
object_=_response.json(),
|
|
57
|
+
),
|
|
58
|
+
)
|
|
59
|
+
return HttpResponse(response=_response, data=_data)
|
|
60
|
+
if _response.status_code == 403:
|
|
61
|
+
raise ForbiddenError(
|
|
62
|
+
headers=dict(_response.headers),
|
|
63
|
+
body=typing.cast(
|
|
64
|
+
Error,
|
|
65
|
+
parse_obj_as(
|
|
66
|
+
type_=Error, # type: ignore
|
|
67
|
+
object_=_response.json(),
|
|
68
|
+
),
|
|
69
|
+
),
|
|
70
|
+
)
|
|
71
|
+
_response_json = _response.json()
|
|
72
|
+
except JSONDecodeError:
|
|
73
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
74
|
+
except ValidationError as e:
|
|
75
|
+
raise ParsingError(
|
|
76
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
77
|
+
)
|
|
78
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
79
|
+
|
|
80
|
+
def report_sync_state(
|
|
81
|
+
self,
|
|
82
|
+
base_id: str,
|
|
83
|
+
*,
|
|
84
|
+
bindings: typing.Dict[str, SyncStateInputBindingsValue],
|
|
85
|
+
version: float,
|
|
86
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
87
|
+
) -> HttpResponse[None]:
|
|
88
|
+
"""
|
|
89
|
+
Parameters
|
|
90
|
+
----------
|
|
91
|
+
base_id : str
|
|
92
|
+
|
|
93
|
+
bindings : typing.Dict[str, SyncStateInputBindingsValue]
|
|
94
|
+
|
|
95
|
+
version : float
|
|
96
|
+
|
|
97
|
+
request_options : typing.Optional[RequestOptions]
|
|
98
|
+
Request-specific configuration.
|
|
99
|
+
|
|
100
|
+
Returns
|
|
101
|
+
-------
|
|
102
|
+
HttpResponse[None]
|
|
103
|
+
"""
|
|
104
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
105
|
+
f"base/bases/{encode_path_param(base_id)}/sync-state",
|
|
106
|
+
method="POST",
|
|
107
|
+
json={
|
|
108
|
+
"bindings": convert_and_respect_annotation_metadata(
|
|
109
|
+
object_=bindings, annotation=typing.Dict[str, SyncStateInputBindingsValue], direction="write"
|
|
110
|
+
),
|
|
111
|
+
"version": version,
|
|
112
|
+
},
|
|
113
|
+
headers={
|
|
114
|
+
"content-type": "application/json",
|
|
115
|
+
},
|
|
116
|
+
request_options=request_options,
|
|
117
|
+
omit=OMIT,
|
|
118
|
+
)
|
|
119
|
+
try:
|
|
120
|
+
if 200 <= _response.status_code < 300:
|
|
121
|
+
return HttpResponse(response=_response, data=None)
|
|
122
|
+
if _response.status_code == 400:
|
|
123
|
+
raise BadRequestError(
|
|
124
|
+
headers=dict(_response.headers),
|
|
125
|
+
body=typing.cast(
|
|
126
|
+
Error,
|
|
127
|
+
parse_obj_as(
|
|
128
|
+
type_=Error, # type: ignore
|
|
129
|
+
object_=_response.json(),
|
|
130
|
+
),
|
|
131
|
+
),
|
|
132
|
+
)
|
|
133
|
+
if _response.status_code == 403:
|
|
134
|
+
raise ForbiddenError(
|
|
135
|
+
headers=dict(_response.headers),
|
|
136
|
+
body=typing.cast(
|
|
137
|
+
Error,
|
|
138
|
+
parse_obj_as(
|
|
139
|
+
type_=Error, # type: ignore
|
|
140
|
+
object_=_response.json(),
|
|
141
|
+
),
|
|
142
|
+
),
|
|
143
|
+
)
|
|
144
|
+
_response_json = _response.json()
|
|
145
|
+
except JSONDecodeError:
|
|
146
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
147
|
+
except ValidationError as e:
|
|
148
|
+
raise ParsingError(
|
|
149
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
150
|
+
)
|
|
151
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
class AsyncRawSyncStateClient:
|
|
155
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
156
|
+
self._client_wrapper = client_wrapper
|
|
157
|
+
|
|
158
|
+
async def get_sync_state(
|
|
159
|
+
self, base_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
160
|
+
) -> AsyncHttpResponse[BindingStateResponse]:
|
|
161
|
+
"""
|
|
162
|
+
Parameters
|
|
163
|
+
----------
|
|
164
|
+
base_id : str
|
|
165
|
+
|
|
166
|
+
request_options : typing.Optional[RequestOptions]
|
|
167
|
+
Request-specific configuration.
|
|
168
|
+
|
|
169
|
+
Returns
|
|
170
|
+
-------
|
|
171
|
+
AsyncHttpResponse[BindingStateResponse]
|
|
172
|
+
Per-binding sync state.
|
|
173
|
+
"""
|
|
174
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
175
|
+
f"base/bases/{encode_path_param(base_id)}/sync-state",
|
|
176
|
+
method="GET",
|
|
177
|
+
request_options=request_options,
|
|
178
|
+
)
|
|
179
|
+
try:
|
|
180
|
+
if 200 <= _response.status_code < 300:
|
|
181
|
+
_data = typing.cast(
|
|
182
|
+
BindingStateResponse,
|
|
183
|
+
parse_obj_as(
|
|
184
|
+
type_=BindingStateResponse, # type: ignore
|
|
185
|
+
object_=_response.json(),
|
|
186
|
+
),
|
|
187
|
+
)
|
|
188
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
189
|
+
if _response.status_code == 403:
|
|
190
|
+
raise ForbiddenError(
|
|
191
|
+
headers=dict(_response.headers),
|
|
192
|
+
body=typing.cast(
|
|
193
|
+
Error,
|
|
194
|
+
parse_obj_as(
|
|
195
|
+
type_=Error, # type: ignore
|
|
196
|
+
object_=_response.json(),
|
|
197
|
+
),
|
|
198
|
+
),
|
|
199
|
+
)
|
|
200
|
+
_response_json = _response.json()
|
|
201
|
+
except JSONDecodeError:
|
|
202
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
203
|
+
except ValidationError as e:
|
|
204
|
+
raise ParsingError(
|
|
205
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
206
|
+
)
|
|
207
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
208
|
+
|
|
209
|
+
async def report_sync_state(
|
|
210
|
+
self,
|
|
211
|
+
base_id: str,
|
|
212
|
+
*,
|
|
213
|
+
bindings: typing.Dict[str, SyncStateInputBindingsValue],
|
|
214
|
+
version: float,
|
|
215
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
216
|
+
) -> AsyncHttpResponse[None]:
|
|
217
|
+
"""
|
|
218
|
+
Parameters
|
|
219
|
+
----------
|
|
220
|
+
base_id : str
|
|
221
|
+
|
|
222
|
+
bindings : typing.Dict[str, SyncStateInputBindingsValue]
|
|
223
|
+
|
|
224
|
+
version : float
|
|
225
|
+
|
|
226
|
+
request_options : typing.Optional[RequestOptions]
|
|
227
|
+
Request-specific configuration.
|
|
228
|
+
|
|
229
|
+
Returns
|
|
230
|
+
-------
|
|
231
|
+
AsyncHttpResponse[None]
|
|
232
|
+
"""
|
|
233
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
234
|
+
f"base/bases/{encode_path_param(base_id)}/sync-state",
|
|
235
|
+
method="POST",
|
|
236
|
+
json={
|
|
237
|
+
"bindings": convert_and_respect_annotation_metadata(
|
|
238
|
+
object_=bindings, annotation=typing.Dict[str, SyncStateInputBindingsValue], direction="write"
|
|
239
|
+
),
|
|
240
|
+
"version": version,
|
|
241
|
+
},
|
|
242
|
+
headers={
|
|
243
|
+
"content-type": "application/json",
|
|
244
|
+
},
|
|
245
|
+
request_options=request_options,
|
|
246
|
+
omit=OMIT,
|
|
247
|
+
)
|
|
248
|
+
try:
|
|
249
|
+
if 200 <= _response.status_code < 300:
|
|
250
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
251
|
+
if _response.status_code == 400:
|
|
252
|
+
raise BadRequestError(
|
|
253
|
+
headers=dict(_response.headers),
|
|
254
|
+
body=typing.cast(
|
|
255
|
+
Error,
|
|
256
|
+
parse_obj_as(
|
|
257
|
+
type_=Error, # type: ignore
|
|
258
|
+
object_=_response.json(),
|
|
259
|
+
),
|
|
260
|
+
),
|
|
261
|
+
)
|
|
262
|
+
if _response.status_code == 403:
|
|
263
|
+
raise ForbiddenError(
|
|
264
|
+
headers=dict(_response.headers),
|
|
265
|
+
body=typing.cast(
|
|
266
|
+
Error,
|
|
267
|
+
parse_obj_as(
|
|
268
|
+
type_=Error, # type: ignore
|
|
269
|
+
object_=_response.json(),
|
|
270
|
+
),
|
|
271
|
+
),
|
|
272
|
+
)
|
|
273
|
+
_response_json = _response.json()
|
|
274
|
+
except JSONDecodeError:
|
|
275
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
276
|
+
except ValidationError as e:
|
|
277
|
+
raise ParsingError(
|
|
278
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
279
|
+
)
|
|
280
|
+
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 .sync_state_input_bindings_value import SyncStateInputBindingsValue
|
|
10
|
+
_dynamic_imports: typing.Dict[str, str] = {"SyncStateInputBindingsValue": ".sync_state_input_bindings_value"}
|
|
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__ = ["SyncStateInputBindingsValue"]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
import pydantic
|
|
7
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
8
|
+
from ...types.run_status import RunStatus
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SyncStateInputBindingsValue(UniversalBaseModel):
|
|
12
|
+
frontier: typing.Optional[dt.datetime] = None
|
|
13
|
+
last_run: typing.Optional[dt.datetime] = None
|
|
14
|
+
last_run_status: typing.Optional[RunStatus] = None
|
|
15
|
+
|
|
16
|
+
if IS_PYDANTIC_V2:
|
|
17
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
18
|
+
else:
|
|
19
|
+
|
|
20
|
+
class Config:
|
|
21
|
+
frozen = True
|
|
22
|
+
smart_union = True
|
|
23
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def _has_httpx_aiohttp() -> bool:
|
|
5
|
+
"""Check if httpx_aiohttp is importable."""
|
|
6
|
+
try:
|
|
7
|
+
import httpx_aiohttp # type: ignore[import-not-found] # noqa: F401
|
|
8
|
+
|
|
9
|
+
return True
|
|
10
|
+
except ImportError:
|
|
11
|
+
return False
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def pytest_collection_modifyitems(config: pytest.Config, items: list) -> None:
|
|
15
|
+
"""Auto-skip @pytest.mark.aiohttp tests when httpx_aiohttp is not installed."""
|
|
16
|
+
if _has_httpx_aiohttp():
|
|
17
|
+
return
|
|
18
|
+
skip_aiohttp = pytest.mark.skip(reason="httpx_aiohttp not installed")
|
|
19
|
+
for item in items:
|
|
20
|
+
if "aiohttp" in item.keywords:
|
|
21
|
+
item.add_marker(skip_aiohttp)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import importlib
|
|
2
|
+
import sys
|
|
3
|
+
import unittest
|
|
4
|
+
from unittest import mock
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TestMakeDefaultAsyncClientWithoutAiohttp(unittest.TestCase):
|
|
11
|
+
"""Tests for _make_default_async_client when httpx_aiohttp is NOT installed."""
|
|
12
|
+
|
|
13
|
+
def test_returns_httpx_async_client(self) -> None:
|
|
14
|
+
"""When httpx_aiohttp is not installed, returns plain httpx.AsyncClient."""
|
|
15
|
+
with mock.patch.dict(sys.modules, {"httpx_aiohttp": None}):
|
|
16
|
+
from base_client.client import _make_default_async_client
|
|
17
|
+
|
|
18
|
+
client = _make_default_async_client(timeout=60, follow_redirects=True)
|
|
19
|
+
self.assertIsInstance(client, httpx.AsyncClient)
|
|
20
|
+
self.assertEqual(client.timeout.read, 60)
|
|
21
|
+
self.assertTrue(client.follow_redirects)
|
|
22
|
+
|
|
23
|
+
def test_follow_redirects_none(self) -> None:
|
|
24
|
+
"""When follow_redirects is None, omits it from httpx.AsyncClient."""
|
|
25
|
+
with mock.patch.dict(sys.modules, {"httpx_aiohttp": None}):
|
|
26
|
+
from base_client.client import _make_default_async_client
|
|
27
|
+
|
|
28
|
+
client = _make_default_async_client(timeout=60, follow_redirects=None)
|
|
29
|
+
self.assertIsInstance(client, httpx.AsyncClient)
|
|
30
|
+
self.assertFalse(client.follow_redirects)
|
|
31
|
+
|
|
32
|
+
def test_explicit_httpx_client_bypasses_autodetect(self) -> None:
|
|
33
|
+
"""When user passes httpx_client explicitly, _make_default_async_client is not called."""
|
|
34
|
+
|
|
35
|
+
explicit_client = httpx.AsyncClient(timeout=120)
|
|
36
|
+
with mock.patch("base_client.client._make_default_async_client") as mock_make:
|
|
37
|
+
# Replicate the generated conditional: httpx_client if httpx_client is not None else _make_default_async_client(...)
|
|
38
|
+
result = explicit_client if explicit_client is not None else mock_make(timeout=60, follow_redirects=True)
|
|
39
|
+
mock_make.assert_not_called()
|
|
40
|
+
self.assertIs(result, explicit_client)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@pytest.mark.aiohttp
|
|
44
|
+
class TestMakeDefaultAsyncClientWithAiohttp(unittest.TestCase):
|
|
45
|
+
"""Tests for _make_default_async_client when httpx_aiohttp IS installed."""
|
|
46
|
+
|
|
47
|
+
def test_returns_aiohttp_client(self) -> None:
|
|
48
|
+
"""When httpx_aiohttp is installed, returns HttpxAiohttpClient."""
|
|
49
|
+
import httpx_aiohttp # type: ignore[import-not-found]
|
|
50
|
+
from base_client.client import _make_default_async_client
|
|
51
|
+
|
|
52
|
+
client = _make_default_async_client(timeout=60, follow_redirects=True)
|
|
53
|
+
self.assertIsInstance(client, httpx_aiohttp.HttpxAiohttpClient)
|
|
54
|
+
self.assertEqual(client.timeout.read, 60)
|
|
55
|
+
self.assertTrue(client.follow_redirects)
|
|
56
|
+
|
|
57
|
+
def test_follow_redirects_none(self) -> None:
|
|
58
|
+
"""When httpx_aiohttp is installed and follow_redirects is None, omits it."""
|
|
59
|
+
import httpx_aiohttp # type: ignore[import-not-found]
|
|
60
|
+
from base_client.client import _make_default_async_client
|
|
61
|
+
|
|
62
|
+
client = _make_default_async_client(timeout=60, follow_redirects=None)
|
|
63
|
+
self.assertIsInstance(client, httpx_aiohttp.HttpxAiohttpClient)
|
|
64
|
+
self.assertFalse(client.follow_redirects)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class TestDefaultClientsWithoutAiohttp(unittest.TestCase):
|
|
68
|
+
"""Tests for _default_clients.py convenience classes (no aiohttp)."""
|
|
69
|
+
|
|
70
|
+
def test_default_async_httpx_client_defaults(self) -> None:
|
|
71
|
+
"""DefaultAsyncHttpxClient applies SDK defaults."""
|
|
72
|
+
from base_client._default_clients import SDK_DEFAULT_TIMEOUT, DefaultAsyncHttpxClient
|
|
73
|
+
|
|
74
|
+
client = DefaultAsyncHttpxClient()
|
|
75
|
+
self.assertIsInstance(client, httpx.AsyncClient)
|
|
76
|
+
self.assertEqual(client.timeout.read, SDK_DEFAULT_TIMEOUT)
|
|
77
|
+
self.assertTrue(client.follow_redirects)
|
|
78
|
+
|
|
79
|
+
def test_default_async_httpx_client_overrides(self) -> None:
|
|
80
|
+
"""DefaultAsyncHttpxClient allows overriding defaults."""
|
|
81
|
+
from base_client._default_clients import DefaultAsyncHttpxClient
|
|
82
|
+
|
|
83
|
+
client = DefaultAsyncHttpxClient(timeout=30, follow_redirects=False)
|
|
84
|
+
self.assertEqual(client.timeout.read, 30)
|
|
85
|
+
self.assertFalse(client.follow_redirects)
|
|
86
|
+
|
|
87
|
+
def test_default_aiohttp_client_raises_without_package(self) -> None:
|
|
88
|
+
"""DefaultAioHttpClient raises RuntimeError when httpx_aiohttp not installed."""
|
|
89
|
+
import base_client._default_clients
|
|
90
|
+
|
|
91
|
+
with mock.patch.dict(sys.modules, {"httpx_aiohttp": None}):
|
|
92
|
+
importlib.reload(base_client._default_clients)
|
|
93
|
+
|
|
94
|
+
with self.assertRaises(RuntimeError) as ctx:
|
|
95
|
+
base_client._default_clients.DefaultAioHttpClient()
|
|
96
|
+
self.assertIn("pip install base_client[aiohttp]", str(ctx.exception))
|
|
97
|
+
|
|
98
|
+
importlib.reload(base_client._default_clients)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@pytest.mark.aiohttp
|
|
102
|
+
class TestDefaultClientsWithAiohttp(unittest.TestCase):
|
|
103
|
+
"""Tests for _default_clients.py when httpx_aiohttp IS installed."""
|
|
104
|
+
|
|
105
|
+
def test_default_aiohttp_client_defaults(self) -> None:
|
|
106
|
+
"""DefaultAioHttpClient works when httpx_aiohttp is installed."""
|
|
107
|
+
import httpx_aiohttp # type: ignore[import-not-found]
|
|
108
|
+
from base_client._default_clients import SDK_DEFAULT_TIMEOUT, DefaultAioHttpClient
|
|
109
|
+
|
|
110
|
+
client = DefaultAioHttpClient()
|
|
111
|
+
self.assertIsInstance(client, httpx_aiohttp.HttpxAiohttpClient)
|
|
112
|
+
self.assertEqual(client.timeout.read, SDK_DEFAULT_TIMEOUT)
|
|
113
|
+
self.assertTrue(client.follow_redirects)
|