alchemy-python 0.1.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.
Files changed (172) hide show
  1. alchemy/.fern/metadata.json +18 -0
  2. alchemy/CONTRIBUTING.md +125 -0
  3. alchemy/__init__.py +380 -0
  4. alchemy/_default_clients.py +30 -0
  5. alchemy/auth/__init__.py +4 -0
  6. alchemy/auth/client.py +767 -0
  7. alchemy/auth/raw_client.py +866 -0
  8. alchemy/client.py +717 -0
  9. alchemy/core/__init__.py +127 -0
  10. alchemy/core/api_error.py +23 -0
  11. alchemy/core/client_wrapper.py +155 -0
  12. alchemy/core/datetime_utils.py +70 -0
  13. alchemy/core/file.py +67 -0
  14. alchemy/core/force_multipart.py +18 -0
  15. alchemy/core/http_client.py +940 -0
  16. alchemy/core/http_response.py +63 -0
  17. alchemy/core/http_sse/__init__.py +42 -0
  18. alchemy/core/http_sse/_api.py +455 -0
  19. alchemy/core/http_sse/_decoders.py +74 -0
  20. alchemy/core/http_sse/_exceptions.py +7 -0
  21. alchemy/core/http_sse/_models.py +17 -0
  22. alchemy/core/jsonable_encoder.py +133 -0
  23. alchemy/core/logging.py +107 -0
  24. alchemy/core/oauth_token_provider.py +73 -0
  25. alchemy/core/parse_error.py +36 -0
  26. alchemy/core/pydantic_utilities.py +486 -0
  27. alchemy/core/query_encoder.py +58 -0
  28. alchemy/core/remove_none_from_dict.py +11 -0
  29. alchemy/core/request_options.py +40 -0
  30. alchemy/core/serialization.py +347 -0
  31. alchemy/environment.py +7 -0
  32. alchemy/function/__init__.py +34 -0
  33. alchemy/function/client.py +808 -0
  34. alchemy/function/raw_client.py +903 -0
  35. alchemy/function/version/__init__.py +4 -0
  36. alchemy/function/version/client.py +364 -0
  37. alchemy/function/version/raw_client.py +410 -0
  38. alchemy/host/__init__.py +4 -0
  39. alchemy/host/client.py +227 -0
  40. alchemy/host/raw_client.py +242 -0
  41. alchemy/instance/__init__.py +4 -0
  42. alchemy/instance/client.py +136 -0
  43. alchemy/instance/raw_client.py +141 -0
  44. alchemy/invocation/__init__.py +4 -0
  45. alchemy/invocation/client.py +570 -0
  46. alchemy/invocation/raw_client.py +636 -0
  47. alchemy/member/__init__.py +4 -0
  48. alchemy/member/client.py +441 -0
  49. alchemy/member/raw_client.py +504 -0
  50. alchemy/metrics/__init__.py +4 -0
  51. alchemy/metrics/client.py +428 -0
  52. alchemy/metrics/raw_client.py +478 -0
  53. alchemy/py.typed +0 -0
  54. alchemy/raw_client.py +138 -0
  55. alchemy/reference.md +3300 -0
  56. alchemy/runtime/__init__.py +4 -0
  57. alchemy/runtime/client.py +141 -0
  58. alchemy/runtime/raw_client.py +140 -0
  59. alchemy/service_account/__init__.py +4 -0
  60. alchemy/service_account/client.py +429 -0
  61. alchemy/service_account/raw_client.py +490 -0
  62. alchemy/template/__init__.py +4 -0
  63. alchemy/template/client.py +141 -0
  64. alchemy/template/raw_client.py +140 -0
  65. alchemy/types/__init__.py +344 -0
  66. alchemy/types/auth_v1accept_invite_response.py +5 -0
  67. alchemy/types/auth_v1create_service_account_response.py +34 -0
  68. alchemy/types/auth_v1get_auth_config_request.py +5 -0
  69. alchemy/types/auth_v1get_auth_config_response.py +53 -0
  70. alchemy/types/auth_v1get_session_request.py +9 -0
  71. alchemy/types/auth_v1get_session_response.py +28 -0
  72. alchemy/types/auth_v1get_token_response.py +29 -0
  73. alchemy/types/auth_v1invite_member_response.py +29 -0
  74. alchemy/types/auth_v1list_members_request.py +5 -0
  75. alchemy/types/auth_v1list_members_response.py +34 -0
  76. alchemy/types/auth_v1list_service_accounts_request.py +5 -0
  77. alchemy/types/auth_v1list_service_accounts_response.py +29 -0
  78. alchemy/types/auth_v1login_response.py +5 -0
  79. alchemy/types/auth_v1logout_request.py +8 -0
  80. alchemy/types/auth_v1logout_response.py +5 -0
  81. alchemy/types/auth_v1member.py +31 -0
  82. alchemy/types/auth_v1register_response.py +23 -0
  83. alchemy/types/auth_v1remove_member_response.py +5 -0
  84. alchemy/types/auth_v1remove_service_account_response.py +5 -0
  85. alchemy/types/auth_v1role.py +5 -0
  86. alchemy/types/auth_v1rotate_service_account_secret_response.py +31 -0
  87. alchemy/types/auth_v1service_account.py +35 -0
  88. alchemy/types/auth_v1set_member_role_response.py +5 -0
  89. alchemy/types/connect_error.py +38 -0
  90. alchemy/types/connect_error_code.py +25 -0
  91. alchemy/types/connect_error_details_any.py +36 -0
  92. alchemy/types/connect_protocol_version.py +5 -0
  93. alchemy/types/connect_timeout_header.py +6 -0
  94. alchemy/types/functions_v1arrow_contract.py +50 -0
  95. alchemy/types/functions_v1contract.py +8 -0
  96. alchemy/types/functions_v1contract_arrow.py +20 -0
  97. alchemy/types/functions_v1contract_json_schema.py +26 -0
  98. alchemy/types/functions_v1contract_violation.py +32 -0
  99. alchemy/types/functions_v1create_function_response.py +22 -0
  100. alchemy/types/functions_v1create_function_version_response.py +20 -0
  101. alchemy/types/functions_v1delete_function_response.py +5 -0
  102. alchemy/types/functions_v1function.py +100 -0
  103. alchemy/types/functions_v1function_error.py +30 -0
  104. alchemy/types/functions_v1function_error_kind.py +15 -0
  105. alchemy/types/functions_v1function_spec.py +58 -0
  106. alchemy/types/functions_v1function_version.py +81 -0
  107. alchemy/types/functions_v1function_version_status.py +13 -0
  108. alchemy/types/functions_v1get_function_response.py +20 -0
  109. alchemy/types/functions_v1get_function_version_response.py +20 -0
  110. alchemy/types/functions_v1get_host_request.py +5 -0
  111. alchemy/types/functions_v1get_host_response.py +20 -0
  112. alchemy/types/functions_v1get_invocation_logs_request.py +31 -0
  113. alchemy/types/functions_v1get_invocation_logs_response.py +24 -0
  114. alchemy/types/functions_v1get_invocation_response.py +20 -0
  115. alchemy/types/functions_v1get_version_request.py +5 -0
  116. alchemy/types/functions_v1get_version_response.py +25 -0
  117. alchemy/types/functions_v1host.py +58 -0
  118. alchemy/types/functions_v1instance.py +54 -0
  119. alchemy/types/functions_v1instance_status.py +14 -0
  120. alchemy/types/functions_v1invocation.py +106 -0
  121. alchemy/types/functions_v1invocation_protocol.py +8 -0
  122. alchemy/types/functions_v1invocation_stats.py +41 -0
  123. alchemy/types/functions_v1invocation_status.py +18 -0
  124. alchemy/types/functions_v1invoke_async_response.py +34 -0
  125. alchemy/types/functions_v1invoke_response.py +8 -0
  126. alchemy/types/functions_v1invoke_response_error.py +20 -0
  127. alchemy/types/functions_v1invoke_response_output.py +19 -0
  128. alchemy/types/functions_v1json_schema_contract.py +28 -0
  129. alchemy/types/functions_v1list_function_versions_response.py +22 -0
  130. alchemy/types/functions_v1list_functions_response.py +22 -0
  131. alchemy/types/functions_v1list_hosts_request.py +5 -0
  132. alchemy/types/functions_v1list_hosts_response.py +23 -0
  133. alchemy/types/functions_v1list_instances_response.py +20 -0
  134. alchemy/types/functions_v1list_invocations_response.py +22 -0
  135. alchemy/types/functions_v1list_runtimes_request.py +5 -0
  136. alchemy/types/functions_v1list_runtimes_response.py +22 -0
  137. alchemy/types/functions_v1list_templates_request.py +5 -0
  138. alchemy/types/functions_v1list_templates_response.py +20 -0
  139. alchemy/types/functions_v1network.py +5 -0
  140. alchemy/types/functions_v1pagination_request.py +31 -0
  141. alchemy/types/functions_v1pagination_response.py +33 -0
  142. alchemy/types/functions_v1resources.py +28 -0
  143. alchemy/types/functions_v1runtime.py +59 -0
  144. alchemy/types/functions_v1runtime_starters.py +29 -0
  145. alchemy/types/functions_v1source.py +31 -0
  146. alchemy/types/functions_v1source_file.py +28 -0
  147. alchemy/types/functions_v1source_layer.py +27 -0
  148. alchemy/types/functions_v1source_limits.py +30 -0
  149. alchemy/types/functions_v1start_kind.py +8 -0
  150. alchemy/types/functions_v1tail_invocations_request.py +32 -0
  151. alchemy/types/functions_v1tail_invocations_response.py +34 -0
  152. alchemy/types/functions_v1template.py +94 -0
  153. alchemy/types/functions_v1template_source.py +27 -0
  154. alchemy/types/functions_v1update_function_response.py +20 -0
  155. alchemy/types/google_protobuf_list_value.py +10 -0
  156. alchemy/types/google_protobuf_null_value.py +5 -0
  157. alchemy/types/google_protobuf_struct.py +10 -0
  158. alchemy/types/google_protobuf_value.py +5 -0
  159. alchemy/types/metrics_v1aggregate_row.py +24 -0
  160. alchemy/types/metrics_v1get_queue_response.py +25 -0
  161. alchemy/types/metrics_v1metric.py +16 -0
  162. alchemy/types/metrics_v1metric_dimension.py +14 -0
  163. alchemy/types/metrics_v1metric_filter.py +26 -0
  164. alchemy/types/metrics_v1metric_granularity.py +13 -0
  165. alchemy/types/metrics_v1query_aggregate_response.py +20 -0
  166. alchemy/types/metrics_v1query_timeseries_response.py +20 -0
  167. alchemy/types/metrics_v1timeseries.py +28 -0
  168. alchemy/types/metrics_v1timeseries_point.py +28 -0
  169. alchemy_python-0.1.0.dist-info/METADATA +196 -0
  170. alchemy_python-0.1.0.dist-info/RECORD +172 -0
  171. alchemy_python-0.1.0.dist-info/WHEEL +4 -0
  172. alchemy_python-0.1.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,808 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing
6
+
7
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
+ from ..core.request_options import RequestOptions
9
+ from ..types.connect_timeout_header import ConnectTimeoutHeader
10
+ from ..types.functions_v1create_function_response import FunctionsV1CreateFunctionResponse
11
+ from ..types.functions_v1delete_function_response import FunctionsV1DeleteFunctionResponse
12
+ from ..types.functions_v1function_spec import FunctionsV1FunctionSpec
13
+ from ..types.functions_v1get_function_response import FunctionsV1GetFunctionResponse
14
+ from ..types.functions_v1list_functions_response import FunctionsV1ListFunctionsResponse
15
+ from ..types.functions_v1network import FunctionsV1Network
16
+ from ..types.functions_v1pagination_request import FunctionsV1PaginationRequest
17
+ from ..types.functions_v1resources import FunctionsV1Resources
18
+ from ..types.functions_v1update_function_response import FunctionsV1UpdateFunctionResponse
19
+ from .raw_client import AsyncRawFunctionClient, RawFunctionClient
20
+
21
+ if typing.TYPE_CHECKING:
22
+ from .version.client import AsyncVersionClient, VersionClient
23
+ # this is used as the default value for optional parameters
24
+ OMIT = typing.cast(typing.Any, ...)
25
+
26
+
27
+ class FunctionClient:
28
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
29
+ self._raw_client = RawFunctionClient(client_wrapper=client_wrapper)
30
+ self._client_wrapper = client_wrapper
31
+ self._version: typing.Optional[VersionClient] = None
32
+
33
+ @property
34
+ def with_raw_response(self) -> RawFunctionClient:
35
+ """
36
+ Retrieves a raw implementation of this client that returns raw responses.
37
+
38
+ Returns
39
+ -------
40
+ RawFunctionClient
41
+ """
42
+ return self._raw_client
43
+
44
+ def create(
45
+ self,
46
+ *,
47
+ connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
48
+ name: typing.Optional[str] = OMIT,
49
+ description: typing.Optional[str] = OMIT,
50
+ spec: typing.Optional[FunctionsV1FunctionSpec] = OMIT,
51
+ secret_values: typing.Optional[typing.Dict[str, str]] = OMIT,
52
+ timeout_ms: typing.Optional[str] = OMIT,
53
+ max_concurrency: typing.Optional[int] = OMIT,
54
+ resources: typing.Optional[FunctionsV1Resources] = OMIT,
55
+ retries: typing.Optional[int] = OMIT,
56
+ network: typing.Optional[FunctionsV1Network] = OMIT,
57
+ request_options: typing.Optional[RequestOptions] = None,
58
+ ) -> FunctionsV1CreateFunctionResponse:
59
+ """
60
+ Functions; the stable handle callers invoke.
61
+
62
+ Parameters
63
+ ----------
64
+ connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
65
+ Define the timeout, in ms
66
+
67
+ name : typing.Optional[str]
68
+
69
+ description : typing.Optional[str]
70
+
71
+ spec : typing.Optional[FunctionsV1FunctionSpec]
72
+
73
+ secret_values : typing.Optional[typing.Dict[str, str]]
74
+ secret_values are secrets to create for this version, variable name to
75
+ value. Each is stored under the tenant as a new secret of its own, so a
76
+ later version never changes what this one reads, and named in
77
+ spec.secrets.
78
+
79
+ timeout_ms : typing.Optional[str]
80
+ timeout_ms, max_concurrency and resources are as on Function. Zero
81
+ values take the server defaults.
82
+
83
+ max_concurrency : typing.Optional[int]
84
+
85
+ resources : typing.Optional[FunctionsV1Resources]
86
+
87
+ retries : typing.Optional[int]
88
+ retries is as on Function. Unset takes the default of 2.
89
+
90
+ network : typing.Optional[FunctionsV1Network]
91
+
92
+ request_options : typing.Optional[RequestOptions]
93
+ Request-specific configuration.
94
+
95
+ Returns
96
+ -------
97
+ FunctionsV1CreateFunctionResponse
98
+ Success
99
+
100
+ Examples
101
+ --------
102
+ from alchemy import Alchemy
103
+
104
+ client = Alchemy(
105
+ client_id="YOUR_CLIENT_ID",
106
+ client_secret="YOUR_CLIENT_SECRET",
107
+ )
108
+ client.function.create(
109
+ connect_timeout_ms=1000.0,
110
+ )
111
+ """
112
+ _response = self._raw_client.create(
113
+ connect_timeout_ms=connect_timeout_ms,
114
+ name=name,
115
+ description=description,
116
+ spec=spec,
117
+ secret_values=secret_values,
118
+ timeout_ms=timeout_ms,
119
+ max_concurrency=max_concurrency,
120
+ resources=resources,
121
+ retries=retries,
122
+ network=network,
123
+ request_options=request_options,
124
+ )
125
+ return _response.data
126
+
127
+ def delete(
128
+ self,
129
+ *,
130
+ connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
131
+ id: typing.Optional[str] = OMIT,
132
+ request_options: typing.Optional[RequestOptions] = None,
133
+ ) -> FunctionsV1DeleteFunctionResponse:
134
+ """
135
+ Parameters
136
+ ----------
137
+ connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
138
+ Define the timeout, in ms
139
+
140
+ id : typing.Optional[str]
141
+
142
+ request_options : typing.Optional[RequestOptions]
143
+ Request-specific configuration.
144
+
145
+ Returns
146
+ -------
147
+ FunctionsV1DeleteFunctionResponse
148
+ Success
149
+
150
+ Examples
151
+ --------
152
+ from alchemy import Alchemy
153
+
154
+ client = Alchemy(
155
+ client_id="YOUR_CLIENT_ID",
156
+ client_secret="YOUR_CLIENT_SECRET",
157
+ )
158
+ client.function.delete(
159
+ connect_timeout_ms=1000.0,
160
+ )
161
+ """
162
+ _response = self._raw_client.delete(
163
+ connect_timeout_ms=connect_timeout_ms, id=id, request_options=request_options
164
+ )
165
+ return _response.data
166
+
167
+ def get(
168
+ self,
169
+ *,
170
+ connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
171
+ id: typing.Optional[str] = OMIT,
172
+ include_versions: typing.Optional[bool] = OMIT,
173
+ request_options: typing.Optional[RequestOptions] = None,
174
+ ) -> FunctionsV1GetFunctionResponse:
175
+ """
176
+ Parameters
177
+ ----------
178
+ connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
179
+ Define the timeout, in ms
180
+
181
+ id : typing.Optional[str]
182
+
183
+ include_versions : typing.Optional[bool]
184
+
185
+ request_options : typing.Optional[RequestOptions]
186
+ Request-specific configuration.
187
+
188
+ Returns
189
+ -------
190
+ FunctionsV1GetFunctionResponse
191
+ Success
192
+
193
+ Examples
194
+ --------
195
+ from alchemy import Alchemy
196
+
197
+ client = Alchemy(
198
+ client_id="YOUR_CLIENT_ID",
199
+ client_secret="YOUR_CLIENT_SECRET",
200
+ )
201
+ client.function.get(
202
+ connect_timeout_ms=1000.0,
203
+ )
204
+ """
205
+ _response = self._raw_client.get(
206
+ connect_timeout_ms=connect_timeout_ms,
207
+ id=id,
208
+ include_versions=include_versions,
209
+ request_options=request_options,
210
+ )
211
+ return _response.data
212
+
213
+ def list(
214
+ self,
215
+ *,
216
+ connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
217
+ pagination: typing.Optional[FunctionsV1PaginationRequest] = OMIT,
218
+ search: typing.Optional[str] = OMIT,
219
+ request_options: typing.Optional[RequestOptions] = None,
220
+ ) -> FunctionsV1ListFunctionsResponse:
221
+ """
222
+ Parameters
223
+ ----------
224
+ connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
225
+ Define the timeout, in ms
226
+
227
+ pagination : typing.Optional[FunctionsV1PaginationRequest]
228
+
229
+ search : typing.Optional[str]
230
+
231
+ request_options : typing.Optional[RequestOptions]
232
+ Request-specific configuration.
233
+
234
+ Returns
235
+ -------
236
+ FunctionsV1ListFunctionsResponse
237
+ Success
238
+
239
+ Examples
240
+ --------
241
+ from alchemy import Alchemy
242
+
243
+ client = Alchemy(
244
+ client_id="YOUR_CLIENT_ID",
245
+ client_secret="YOUR_CLIENT_SECRET",
246
+ )
247
+ client.function.list(
248
+ connect_timeout_ms=1000.0,
249
+ )
250
+ """
251
+ _response = self._raw_client.list(
252
+ connect_timeout_ms=connect_timeout_ms, pagination=pagination, search=search, request_options=request_options
253
+ )
254
+ return _response.data
255
+
256
+ def update(
257
+ self,
258
+ *,
259
+ connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
260
+ function_id: typing.Optional[str] = OMIT,
261
+ name: typing.Optional[str] = OMIT,
262
+ description: typing.Optional[str] = OMIT,
263
+ timeout_ms: typing.Optional[str] = OMIT,
264
+ max_concurrency: typing.Optional[int] = OMIT,
265
+ resources: typing.Optional[FunctionsV1Resources] = OMIT,
266
+ retries: typing.Optional[int] = OMIT,
267
+ network: typing.Optional[FunctionsV1Network] = OMIT,
268
+ request_options: typing.Optional[RequestOptions] = None,
269
+ ) -> FunctionsV1UpdateFunctionResponse:
270
+ """
271
+ Parameters
272
+ ----------
273
+ connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
274
+ Define the timeout, in ms
275
+
276
+ function_id : typing.Optional[str]
277
+
278
+ name : typing.Optional[str]
279
+
280
+ description : typing.Optional[str]
281
+
282
+ timeout_ms : typing.Optional[str]
283
+
284
+ max_concurrency : typing.Optional[int]
285
+
286
+ resources : typing.Optional[FunctionsV1Resources]
287
+
288
+ retries : typing.Optional[int]
289
+
290
+ network : typing.Optional[FunctionsV1Network]
291
+
292
+ request_options : typing.Optional[RequestOptions]
293
+ Request-specific configuration.
294
+
295
+ Returns
296
+ -------
297
+ FunctionsV1UpdateFunctionResponse
298
+ Success
299
+
300
+ Examples
301
+ --------
302
+ from alchemy import Alchemy
303
+
304
+ client = Alchemy(
305
+ client_id="YOUR_CLIENT_ID",
306
+ client_secret="YOUR_CLIENT_SECRET",
307
+ )
308
+ client.function.update(
309
+ connect_timeout_ms=1000.0,
310
+ )
311
+ """
312
+ _response = self._raw_client.update(
313
+ connect_timeout_ms=connect_timeout_ms,
314
+ function_id=function_id,
315
+ name=name,
316
+ description=description,
317
+ timeout_ms=timeout_ms,
318
+ max_concurrency=max_concurrency,
319
+ resources=resources,
320
+ retries=retries,
321
+ network=network,
322
+ request_options=request_options,
323
+ )
324
+ return _response.data
325
+
326
+ def invoke(
327
+ self,
328
+ function: str,
329
+ *,
330
+ request: typing.Any,
331
+ version: typing.Optional[int] = None,
332
+ idempotency_key: typing.Optional[str] = None,
333
+ retries: typing.Optional[int] = None,
334
+ request_options: typing.Optional[RequestOptions] = None,
335
+ ) -> typing.Any:
336
+ """
337
+ Runs a function that has a JSON Schema contract. The request body is the input and the response body is the output, with no envelope.
338
+
339
+ Parameters
340
+ ----------
341
+ function : str
342
+ The function id.
343
+
344
+ request : typing.Any
345
+
346
+ version : typing.Optional[int]
347
+ Pins a version. Absent runs the function's current version.
348
+
349
+ idempotency_key : typing.Optional[str]
350
+ Makes the call safe to retry.
351
+
352
+ retries : typing.Optional[int]
353
+ This call's retries instead of the function's.
354
+
355
+ request_options : typing.Optional[RequestOptions]
356
+ Request-specific configuration.
357
+
358
+ Returns
359
+ -------
360
+ typing.Any
361
+ The function's output.
362
+
363
+ Examples
364
+ --------
365
+ from alchemy import Alchemy
366
+
367
+ client = Alchemy(
368
+ client_id="YOUR_CLIENT_ID",
369
+ client_secret="YOUR_CLIENT_SECRET",
370
+ )
371
+ client.function.invoke(
372
+ function="function",
373
+ request={"key": "value"},
374
+ )
375
+ """
376
+ _response = self._raw_client.invoke(
377
+ function,
378
+ request=request,
379
+ version=version,
380
+ idempotency_key=idempotency_key,
381
+ retries=retries,
382
+ request_options=request_options,
383
+ )
384
+ return _response.data
385
+
386
+ @property
387
+ def version(self):
388
+ if self._version is None:
389
+ from .version.client import VersionClient # noqa: E402
390
+
391
+ self._version = VersionClient(client_wrapper=self._client_wrapper)
392
+ return self._version
393
+
394
+
395
+ class AsyncFunctionClient:
396
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
397
+ self._raw_client = AsyncRawFunctionClient(client_wrapper=client_wrapper)
398
+ self._client_wrapper = client_wrapper
399
+ self._version: typing.Optional[AsyncVersionClient] = None
400
+
401
+ @property
402
+ def with_raw_response(self) -> AsyncRawFunctionClient:
403
+ """
404
+ Retrieves a raw implementation of this client that returns raw responses.
405
+
406
+ Returns
407
+ -------
408
+ AsyncRawFunctionClient
409
+ """
410
+ return self._raw_client
411
+
412
+ async def create(
413
+ self,
414
+ *,
415
+ connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
416
+ name: typing.Optional[str] = OMIT,
417
+ description: typing.Optional[str] = OMIT,
418
+ spec: typing.Optional[FunctionsV1FunctionSpec] = OMIT,
419
+ secret_values: typing.Optional[typing.Dict[str, str]] = OMIT,
420
+ timeout_ms: typing.Optional[str] = OMIT,
421
+ max_concurrency: typing.Optional[int] = OMIT,
422
+ resources: typing.Optional[FunctionsV1Resources] = OMIT,
423
+ retries: typing.Optional[int] = OMIT,
424
+ network: typing.Optional[FunctionsV1Network] = OMIT,
425
+ request_options: typing.Optional[RequestOptions] = None,
426
+ ) -> FunctionsV1CreateFunctionResponse:
427
+ """
428
+ Functions; the stable handle callers invoke.
429
+
430
+ Parameters
431
+ ----------
432
+ connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
433
+ Define the timeout, in ms
434
+
435
+ name : typing.Optional[str]
436
+
437
+ description : typing.Optional[str]
438
+
439
+ spec : typing.Optional[FunctionsV1FunctionSpec]
440
+
441
+ secret_values : typing.Optional[typing.Dict[str, str]]
442
+ secret_values are secrets to create for this version, variable name to
443
+ value. Each is stored under the tenant as a new secret of its own, so a
444
+ later version never changes what this one reads, and named in
445
+ spec.secrets.
446
+
447
+ timeout_ms : typing.Optional[str]
448
+ timeout_ms, max_concurrency and resources are as on Function. Zero
449
+ values take the server defaults.
450
+
451
+ max_concurrency : typing.Optional[int]
452
+
453
+ resources : typing.Optional[FunctionsV1Resources]
454
+
455
+ retries : typing.Optional[int]
456
+ retries is as on Function. Unset takes the default of 2.
457
+
458
+ network : typing.Optional[FunctionsV1Network]
459
+
460
+ request_options : typing.Optional[RequestOptions]
461
+ Request-specific configuration.
462
+
463
+ Returns
464
+ -------
465
+ FunctionsV1CreateFunctionResponse
466
+ Success
467
+
468
+ Examples
469
+ --------
470
+ import asyncio
471
+
472
+ from alchemy import AsyncAlchemy
473
+
474
+ client = AsyncAlchemy(
475
+ client_id="YOUR_CLIENT_ID",
476
+ client_secret="YOUR_CLIENT_SECRET",
477
+ )
478
+
479
+
480
+ async def main() -> None:
481
+ await client.function.create(
482
+ connect_timeout_ms=1000.0,
483
+ )
484
+
485
+
486
+ asyncio.run(main())
487
+ """
488
+ _response = await self._raw_client.create(
489
+ connect_timeout_ms=connect_timeout_ms,
490
+ name=name,
491
+ description=description,
492
+ spec=spec,
493
+ secret_values=secret_values,
494
+ timeout_ms=timeout_ms,
495
+ max_concurrency=max_concurrency,
496
+ resources=resources,
497
+ retries=retries,
498
+ network=network,
499
+ request_options=request_options,
500
+ )
501
+ return _response.data
502
+
503
+ async def delete(
504
+ self,
505
+ *,
506
+ connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
507
+ id: typing.Optional[str] = OMIT,
508
+ request_options: typing.Optional[RequestOptions] = None,
509
+ ) -> FunctionsV1DeleteFunctionResponse:
510
+ """
511
+ Parameters
512
+ ----------
513
+ connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
514
+ Define the timeout, in ms
515
+
516
+ id : typing.Optional[str]
517
+
518
+ request_options : typing.Optional[RequestOptions]
519
+ Request-specific configuration.
520
+
521
+ Returns
522
+ -------
523
+ FunctionsV1DeleteFunctionResponse
524
+ Success
525
+
526
+ Examples
527
+ --------
528
+ import asyncio
529
+
530
+ from alchemy import AsyncAlchemy
531
+
532
+ client = AsyncAlchemy(
533
+ client_id="YOUR_CLIENT_ID",
534
+ client_secret="YOUR_CLIENT_SECRET",
535
+ )
536
+
537
+
538
+ async def main() -> None:
539
+ await client.function.delete(
540
+ connect_timeout_ms=1000.0,
541
+ )
542
+
543
+
544
+ asyncio.run(main())
545
+ """
546
+ _response = await self._raw_client.delete(
547
+ connect_timeout_ms=connect_timeout_ms, id=id, request_options=request_options
548
+ )
549
+ return _response.data
550
+
551
+ async def get(
552
+ self,
553
+ *,
554
+ connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
555
+ id: typing.Optional[str] = OMIT,
556
+ include_versions: typing.Optional[bool] = OMIT,
557
+ request_options: typing.Optional[RequestOptions] = None,
558
+ ) -> FunctionsV1GetFunctionResponse:
559
+ """
560
+ Parameters
561
+ ----------
562
+ connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
563
+ Define the timeout, in ms
564
+
565
+ id : typing.Optional[str]
566
+
567
+ include_versions : typing.Optional[bool]
568
+
569
+ request_options : typing.Optional[RequestOptions]
570
+ Request-specific configuration.
571
+
572
+ Returns
573
+ -------
574
+ FunctionsV1GetFunctionResponse
575
+ Success
576
+
577
+ Examples
578
+ --------
579
+ import asyncio
580
+
581
+ from alchemy import AsyncAlchemy
582
+
583
+ client = AsyncAlchemy(
584
+ client_id="YOUR_CLIENT_ID",
585
+ client_secret="YOUR_CLIENT_SECRET",
586
+ )
587
+
588
+
589
+ async def main() -> None:
590
+ await client.function.get(
591
+ connect_timeout_ms=1000.0,
592
+ )
593
+
594
+
595
+ asyncio.run(main())
596
+ """
597
+ _response = await self._raw_client.get(
598
+ connect_timeout_ms=connect_timeout_ms,
599
+ id=id,
600
+ include_versions=include_versions,
601
+ request_options=request_options,
602
+ )
603
+ return _response.data
604
+
605
+ async def list(
606
+ self,
607
+ *,
608
+ connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
609
+ pagination: typing.Optional[FunctionsV1PaginationRequest] = OMIT,
610
+ search: typing.Optional[str] = OMIT,
611
+ request_options: typing.Optional[RequestOptions] = None,
612
+ ) -> FunctionsV1ListFunctionsResponse:
613
+ """
614
+ Parameters
615
+ ----------
616
+ connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
617
+ Define the timeout, in ms
618
+
619
+ pagination : typing.Optional[FunctionsV1PaginationRequest]
620
+
621
+ search : typing.Optional[str]
622
+
623
+ request_options : typing.Optional[RequestOptions]
624
+ Request-specific configuration.
625
+
626
+ Returns
627
+ -------
628
+ FunctionsV1ListFunctionsResponse
629
+ Success
630
+
631
+ Examples
632
+ --------
633
+ import asyncio
634
+
635
+ from alchemy import AsyncAlchemy
636
+
637
+ client = AsyncAlchemy(
638
+ client_id="YOUR_CLIENT_ID",
639
+ client_secret="YOUR_CLIENT_SECRET",
640
+ )
641
+
642
+
643
+ async def main() -> None:
644
+ await client.function.list(
645
+ connect_timeout_ms=1000.0,
646
+ )
647
+
648
+
649
+ asyncio.run(main())
650
+ """
651
+ _response = await self._raw_client.list(
652
+ connect_timeout_ms=connect_timeout_ms, pagination=pagination, search=search, request_options=request_options
653
+ )
654
+ return _response.data
655
+
656
+ async def update(
657
+ self,
658
+ *,
659
+ connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
660
+ function_id: typing.Optional[str] = OMIT,
661
+ name: typing.Optional[str] = OMIT,
662
+ description: typing.Optional[str] = OMIT,
663
+ timeout_ms: typing.Optional[str] = OMIT,
664
+ max_concurrency: typing.Optional[int] = OMIT,
665
+ resources: typing.Optional[FunctionsV1Resources] = OMIT,
666
+ retries: typing.Optional[int] = OMIT,
667
+ network: typing.Optional[FunctionsV1Network] = OMIT,
668
+ request_options: typing.Optional[RequestOptions] = None,
669
+ ) -> FunctionsV1UpdateFunctionResponse:
670
+ """
671
+ Parameters
672
+ ----------
673
+ connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
674
+ Define the timeout, in ms
675
+
676
+ function_id : typing.Optional[str]
677
+
678
+ name : typing.Optional[str]
679
+
680
+ description : typing.Optional[str]
681
+
682
+ timeout_ms : typing.Optional[str]
683
+
684
+ max_concurrency : typing.Optional[int]
685
+
686
+ resources : typing.Optional[FunctionsV1Resources]
687
+
688
+ retries : typing.Optional[int]
689
+
690
+ network : typing.Optional[FunctionsV1Network]
691
+
692
+ request_options : typing.Optional[RequestOptions]
693
+ Request-specific configuration.
694
+
695
+ Returns
696
+ -------
697
+ FunctionsV1UpdateFunctionResponse
698
+ Success
699
+
700
+ Examples
701
+ --------
702
+ import asyncio
703
+
704
+ from alchemy import AsyncAlchemy
705
+
706
+ client = AsyncAlchemy(
707
+ client_id="YOUR_CLIENT_ID",
708
+ client_secret="YOUR_CLIENT_SECRET",
709
+ )
710
+
711
+
712
+ async def main() -> None:
713
+ await client.function.update(
714
+ connect_timeout_ms=1000.0,
715
+ )
716
+
717
+
718
+ asyncio.run(main())
719
+ """
720
+ _response = await self._raw_client.update(
721
+ connect_timeout_ms=connect_timeout_ms,
722
+ function_id=function_id,
723
+ name=name,
724
+ description=description,
725
+ timeout_ms=timeout_ms,
726
+ max_concurrency=max_concurrency,
727
+ resources=resources,
728
+ retries=retries,
729
+ network=network,
730
+ request_options=request_options,
731
+ )
732
+ return _response.data
733
+
734
+ async def invoke(
735
+ self,
736
+ function: str,
737
+ *,
738
+ request: typing.Any,
739
+ version: typing.Optional[int] = None,
740
+ idempotency_key: typing.Optional[str] = None,
741
+ retries: typing.Optional[int] = None,
742
+ request_options: typing.Optional[RequestOptions] = None,
743
+ ) -> typing.Any:
744
+ """
745
+ Runs a function that has a JSON Schema contract. The request body is the input and the response body is the output, with no envelope.
746
+
747
+ Parameters
748
+ ----------
749
+ function : str
750
+ The function id.
751
+
752
+ request : typing.Any
753
+
754
+ version : typing.Optional[int]
755
+ Pins a version. Absent runs the function's current version.
756
+
757
+ idempotency_key : typing.Optional[str]
758
+ Makes the call safe to retry.
759
+
760
+ retries : typing.Optional[int]
761
+ This call's retries instead of the function's.
762
+
763
+ request_options : typing.Optional[RequestOptions]
764
+ Request-specific configuration.
765
+
766
+ Returns
767
+ -------
768
+ typing.Any
769
+ The function's output.
770
+
771
+ Examples
772
+ --------
773
+ import asyncio
774
+
775
+ from alchemy import AsyncAlchemy
776
+
777
+ client = AsyncAlchemy(
778
+ client_id="YOUR_CLIENT_ID",
779
+ client_secret="YOUR_CLIENT_SECRET",
780
+ )
781
+
782
+
783
+ async def main() -> None:
784
+ await client.function.invoke(
785
+ function="function",
786
+ request={"key": "value"},
787
+ )
788
+
789
+
790
+ asyncio.run(main())
791
+ """
792
+ _response = await self._raw_client.invoke(
793
+ function,
794
+ request=request,
795
+ version=version,
796
+ idempotency_key=idempotency_key,
797
+ retries=retries,
798
+ request_options=request_options,
799
+ )
800
+ return _response.data
801
+
802
+ @property
803
+ def version(self):
804
+ if self._version is None:
805
+ from .version.client import AsyncVersionClient # noqa: E402
806
+
807
+ self._version = AsyncVersionClient(client_wrapper=self._client_wrapper)
808
+ return self._version