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