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.
- alchemy/.fern/metadata.json +18 -0
- alchemy/CONTRIBUTING.md +125 -0
- alchemy/__init__.py +380 -0
- alchemy/_default_clients.py +30 -0
- alchemy/auth/__init__.py +4 -0
- alchemy/auth/client.py +767 -0
- alchemy/auth/raw_client.py +866 -0
- alchemy/client.py +717 -0
- alchemy/core/__init__.py +127 -0
- alchemy/core/api_error.py +23 -0
- alchemy/core/client_wrapper.py +155 -0
- alchemy/core/datetime_utils.py +70 -0
- alchemy/core/file.py +67 -0
- alchemy/core/force_multipart.py +18 -0
- alchemy/core/http_client.py +940 -0
- alchemy/core/http_response.py +63 -0
- alchemy/core/http_sse/__init__.py +42 -0
- alchemy/core/http_sse/_api.py +455 -0
- alchemy/core/http_sse/_decoders.py +74 -0
- alchemy/core/http_sse/_exceptions.py +7 -0
- alchemy/core/http_sse/_models.py +17 -0
- alchemy/core/jsonable_encoder.py +133 -0
- alchemy/core/logging.py +107 -0
- alchemy/core/oauth_token_provider.py +73 -0
- alchemy/core/parse_error.py +36 -0
- alchemy/core/pydantic_utilities.py +486 -0
- alchemy/core/query_encoder.py +58 -0
- alchemy/core/remove_none_from_dict.py +11 -0
- alchemy/core/request_options.py +40 -0
- alchemy/core/serialization.py +347 -0
- alchemy/environment.py +7 -0
- alchemy/function/__init__.py +34 -0
- alchemy/function/client.py +808 -0
- alchemy/function/raw_client.py +903 -0
- alchemy/function/version/__init__.py +4 -0
- alchemy/function/version/client.py +364 -0
- alchemy/function/version/raw_client.py +410 -0
- alchemy/host/__init__.py +4 -0
- alchemy/host/client.py +227 -0
- alchemy/host/raw_client.py +242 -0
- alchemy/instance/__init__.py +4 -0
- alchemy/instance/client.py +136 -0
- alchemy/instance/raw_client.py +141 -0
- alchemy/invocation/__init__.py +4 -0
- alchemy/invocation/client.py +570 -0
- alchemy/invocation/raw_client.py +636 -0
- alchemy/member/__init__.py +4 -0
- alchemy/member/client.py +441 -0
- alchemy/member/raw_client.py +504 -0
- alchemy/metrics/__init__.py +4 -0
- alchemy/metrics/client.py +428 -0
- alchemy/metrics/raw_client.py +478 -0
- alchemy/py.typed +0 -0
- alchemy/raw_client.py +138 -0
- alchemy/reference.md +3300 -0
- alchemy/runtime/__init__.py +4 -0
- alchemy/runtime/client.py +141 -0
- alchemy/runtime/raw_client.py +140 -0
- alchemy/service_account/__init__.py +4 -0
- alchemy/service_account/client.py +429 -0
- alchemy/service_account/raw_client.py +490 -0
- alchemy/template/__init__.py +4 -0
- alchemy/template/client.py +141 -0
- alchemy/template/raw_client.py +140 -0
- alchemy/types/__init__.py +344 -0
- alchemy/types/auth_v1accept_invite_response.py +5 -0
- alchemy/types/auth_v1create_service_account_response.py +34 -0
- alchemy/types/auth_v1get_auth_config_request.py +5 -0
- alchemy/types/auth_v1get_auth_config_response.py +53 -0
- alchemy/types/auth_v1get_session_request.py +9 -0
- alchemy/types/auth_v1get_session_response.py +28 -0
- alchemy/types/auth_v1get_token_response.py +29 -0
- alchemy/types/auth_v1invite_member_response.py +29 -0
- alchemy/types/auth_v1list_members_request.py +5 -0
- alchemy/types/auth_v1list_members_response.py +34 -0
- alchemy/types/auth_v1list_service_accounts_request.py +5 -0
- alchemy/types/auth_v1list_service_accounts_response.py +29 -0
- alchemy/types/auth_v1login_response.py +5 -0
- alchemy/types/auth_v1logout_request.py +8 -0
- alchemy/types/auth_v1logout_response.py +5 -0
- alchemy/types/auth_v1member.py +31 -0
- alchemy/types/auth_v1register_response.py +23 -0
- alchemy/types/auth_v1remove_member_response.py +5 -0
- alchemy/types/auth_v1remove_service_account_response.py +5 -0
- alchemy/types/auth_v1role.py +5 -0
- alchemy/types/auth_v1rotate_service_account_secret_response.py +31 -0
- alchemy/types/auth_v1service_account.py +35 -0
- alchemy/types/auth_v1set_member_role_response.py +5 -0
- alchemy/types/connect_error.py +38 -0
- alchemy/types/connect_error_code.py +25 -0
- alchemy/types/connect_error_details_any.py +36 -0
- alchemy/types/connect_protocol_version.py +5 -0
- alchemy/types/connect_timeout_header.py +6 -0
- alchemy/types/functions_v1arrow_contract.py +50 -0
- alchemy/types/functions_v1contract.py +8 -0
- alchemy/types/functions_v1contract_arrow.py +20 -0
- alchemy/types/functions_v1contract_json_schema.py +26 -0
- alchemy/types/functions_v1contract_violation.py +32 -0
- alchemy/types/functions_v1create_function_response.py +22 -0
- alchemy/types/functions_v1create_function_version_response.py +20 -0
- alchemy/types/functions_v1delete_function_response.py +5 -0
- alchemy/types/functions_v1function.py +100 -0
- alchemy/types/functions_v1function_error.py +30 -0
- alchemy/types/functions_v1function_error_kind.py +15 -0
- alchemy/types/functions_v1function_spec.py +58 -0
- alchemy/types/functions_v1function_version.py +81 -0
- alchemy/types/functions_v1function_version_status.py +13 -0
- alchemy/types/functions_v1get_function_response.py +20 -0
- alchemy/types/functions_v1get_function_version_response.py +20 -0
- alchemy/types/functions_v1get_host_request.py +5 -0
- alchemy/types/functions_v1get_host_response.py +20 -0
- alchemy/types/functions_v1get_invocation_logs_request.py +31 -0
- alchemy/types/functions_v1get_invocation_logs_response.py +24 -0
- alchemy/types/functions_v1get_invocation_response.py +20 -0
- alchemy/types/functions_v1get_version_request.py +5 -0
- alchemy/types/functions_v1get_version_response.py +25 -0
- alchemy/types/functions_v1host.py +58 -0
- alchemy/types/functions_v1instance.py +54 -0
- alchemy/types/functions_v1instance_status.py +14 -0
- alchemy/types/functions_v1invocation.py +106 -0
- alchemy/types/functions_v1invocation_protocol.py +8 -0
- alchemy/types/functions_v1invocation_stats.py +41 -0
- alchemy/types/functions_v1invocation_status.py +18 -0
- alchemy/types/functions_v1invoke_async_response.py +34 -0
- alchemy/types/functions_v1invoke_response.py +8 -0
- alchemy/types/functions_v1invoke_response_error.py +20 -0
- alchemy/types/functions_v1invoke_response_output.py +19 -0
- alchemy/types/functions_v1json_schema_contract.py +28 -0
- alchemy/types/functions_v1list_function_versions_response.py +22 -0
- alchemy/types/functions_v1list_functions_response.py +22 -0
- alchemy/types/functions_v1list_hosts_request.py +5 -0
- alchemy/types/functions_v1list_hosts_response.py +23 -0
- alchemy/types/functions_v1list_instances_response.py +20 -0
- alchemy/types/functions_v1list_invocations_response.py +22 -0
- alchemy/types/functions_v1list_runtimes_request.py +5 -0
- alchemy/types/functions_v1list_runtimes_response.py +22 -0
- alchemy/types/functions_v1list_templates_request.py +5 -0
- alchemy/types/functions_v1list_templates_response.py +20 -0
- alchemy/types/functions_v1network.py +5 -0
- alchemy/types/functions_v1pagination_request.py +31 -0
- alchemy/types/functions_v1pagination_response.py +33 -0
- alchemy/types/functions_v1resources.py +28 -0
- alchemy/types/functions_v1runtime.py +59 -0
- alchemy/types/functions_v1runtime_starters.py +29 -0
- alchemy/types/functions_v1source.py +31 -0
- alchemy/types/functions_v1source_file.py +28 -0
- alchemy/types/functions_v1source_layer.py +27 -0
- alchemy/types/functions_v1source_limits.py +30 -0
- alchemy/types/functions_v1start_kind.py +8 -0
- alchemy/types/functions_v1tail_invocations_request.py +32 -0
- alchemy/types/functions_v1tail_invocations_response.py +34 -0
- alchemy/types/functions_v1template.py +94 -0
- alchemy/types/functions_v1template_source.py +27 -0
- alchemy/types/functions_v1update_function_response.py +20 -0
- alchemy/types/google_protobuf_list_value.py +10 -0
- alchemy/types/google_protobuf_null_value.py +5 -0
- alchemy/types/google_protobuf_struct.py +10 -0
- alchemy/types/google_protobuf_value.py +5 -0
- alchemy/types/metrics_v1aggregate_row.py +24 -0
- alchemy/types/metrics_v1get_queue_response.py +25 -0
- alchemy/types/metrics_v1metric.py +16 -0
- alchemy/types/metrics_v1metric_dimension.py +14 -0
- alchemy/types/metrics_v1metric_filter.py +26 -0
- alchemy/types/metrics_v1metric_granularity.py +13 -0
- alchemy/types/metrics_v1query_aggregate_response.py +20 -0
- alchemy/types/metrics_v1query_timeseries_response.py +20 -0
- alchemy/types/metrics_v1timeseries.py +28 -0
- alchemy/types/metrics_v1timeseries_point.py +28 -0
- alchemy_python-0.1.0.dist-info/METADATA +196 -0
- alchemy_python-0.1.0.dist-info/RECORD +172 -0
- alchemy_python-0.1.0.dist-info/WHEEL +4 -0
- alchemy_python-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,636 @@
|
|
|
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.parse_error import ParsingError
|
|
10
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
11
|
+
from ..core.request_options import RequestOptions
|
|
12
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
13
|
+
from ..types.connect_timeout_header import ConnectTimeoutHeader
|
|
14
|
+
from ..types.functions_v1get_invocation_response import FunctionsV1GetInvocationResponse
|
|
15
|
+
from ..types.functions_v1invocation_status import FunctionsV1InvocationStatus
|
|
16
|
+
from ..types.functions_v1invoke_async_response import FunctionsV1InvokeAsyncResponse
|
|
17
|
+
from ..types.functions_v1invoke_response import FunctionsV1InvokeResponse
|
|
18
|
+
from ..types.functions_v1list_invocations_response import FunctionsV1ListInvocationsResponse
|
|
19
|
+
from ..types.functions_v1pagination_request import FunctionsV1PaginationRequest
|
|
20
|
+
from ..types.functions_v1start_kind import FunctionsV1StartKind
|
|
21
|
+
from pydantic import ValidationError
|
|
22
|
+
|
|
23
|
+
# this is used as the default value for optional parameters
|
|
24
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class RawInvocationClient:
|
|
28
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
29
|
+
self._client_wrapper = client_wrapper
|
|
30
|
+
|
|
31
|
+
def get(
|
|
32
|
+
self,
|
|
33
|
+
*,
|
|
34
|
+
connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
|
|
35
|
+
id: typing.Optional[str] = OMIT,
|
|
36
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
37
|
+
) -> HttpResponse[FunctionsV1GetInvocationResponse]:
|
|
38
|
+
"""
|
|
39
|
+
Invocations; the persisted record of every Invoke, newest first.
|
|
40
|
+
|
|
41
|
+
Parameters
|
|
42
|
+
----------
|
|
43
|
+
connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
|
|
44
|
+
Define the timeout, in ms
|
|
45
|
+
|
|
46
|
+
id : typing.Optional[str]
|
|
47
|
+
|
|
48
|
+
request_options : typing.Optional[RequestOptions]
|
|
49
|
+
Request-specific configuration.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
HttpResponse[FunctionsV1GetInvocationResponse]
|
|
54
|
+
Success
|
|
55
|
+
"""
|
|
56
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
57
|
+
"functions.v1.FunctionsService/GetInvocation",
|
|
58
|
+
method="POST",
|
|
59
|
+
json={
|
|
60
|
+
"id": id,
|
|
61
|
+
},
|
|
62
|
+
headers={
|
|
63
|
+
"content-type": "application/json",
|
|
64
|
+
"Connect-Timeout-Ms": str(connect_timeout_ms) if connect_timeout_ms is not None else None,
|
|
65
|
+
},
|
|
66
|
+
request_options=request_options,
|
|
67
|
+
omit=OMIT,
|
|
68
|
+
)
|
|
69
|
+
try:
|
|
70
|
+
if 200 <= _response.status_code < 300:
|
|
71
|
+
_data = typing.cast(
|
|
72
|
+
FunctionsV1GetInvocationResponse,
|
|
73
|
+
parse_obj_as(
|
|
74
|
+
type_=FunctionsV1GetInvocationResponse, # type: ignore
|
|
75
|
+
object_=_response.json(),
|
|
76
|
+
),
|
|
77
|
+
)
|
|
78
|
+
return HttpResponse(response=_response, data=_data)
|
|
79
|
+
_response_json = _response.json()
|
|
80
|
+
except JSONDecodeError:
|
|
81
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
82
|
+
except ValidationError as e:
|
|
83
|
+
raise ParsingError(
|
|
84
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
85
|
+
)
|
|
86
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
87
|
+
|
|
88
|
+
def invoke(
|
|
89
|
+
self,
|
|
90
|
+
*,
|
|
91
|
+
connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
|
|
92
|
+
function_id: typing.Optional[str] = OMIT,
|
|
93
|
+
version: typing.Optional[str] = OMIT,
|
|
94
|
+
input: typing.Optional[str] = OMIT,
|
|
95
|
+
idempotency_key: typing.Optional[str] = OMIT,
|
|
96
|
+
retries: typing.Optional[int] = OMIT,
|
|
97
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
98
|
+
) -> HttpResponse[FunctionsV1InvokeResponse]:
|
|
99
|
+
"""
|
|
100
|
+
Invocation; validate input, run one version against it, validate output.
|
|
101
|
+
An RPC error means the function did not produce a result: the request was
|
|
102
|
+
rejected (unknown function, input violates the contract, no capacity) or
|
|
103
|
+
the platform failed. Input violations are INVALID_ARGUMENT with one
|
|
104
|
+
ContractViolation error detail each. If the function ran, the RPC
|
|
105
|
+
succeeds and the response carries its output or a FunctionError. A
|
|
106
|
+
function that raised, crashed or timed out, or a platform that could
|
|
107
|
+
not run it, runs again up to the call's or the function's retries, with
|
|
108
|
+
exponential backoff, while the call's deadline leaves room. An input
|
|
109
|
+
that violates the contract never runs again.
|
|
110
|
+
|
|
111
|
+
Parameters
|
|
112
|
+
----------
|
|
113
|
+
connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
|
|
114
|
+
Define the timeout, in ms
|
|
115
|
+
|
|
116
|
+
function_id : typing.Optional[str]
|
|
117
|
+
|
|
118
|
+
version : typing.Optional[str]
|
|
119
|
+
|
|
120
|
+
input : typing.Optional[str]
|
|
121
|
+
|
|
122
|
+
idempotency_key : typing.Optional[str]
|
|
123
|
+
idempotency_key makes the call safe to retry. Within the server's
|
|
124
|
+
idempotency window, every call to the same function with the same key
|
|
125
|
+
returns the invocation the first call started, with its output or
|
|
126
|
+
error, instead of running again. The key is released, so that a retry
|
|
127
|
+
runs, only when the platform never sent the invocation to a host. A
|
|
128
|
+
call a host took but never reported on has an unknown outcome and holds
|
|
129
|
+
the key: a retry gets ABORTED, and a new key runs again.
|
|
130
|
+
|
|
131
|
+
retries : typing.Optional[int]
|
|
132
|
+
retries, when set, is how many more times this call runs after a failed
|
|
133
|
+
attempt instead of the function's retries.
|
|
134
|
+
|
|
135
|
+
request_options : typing.Optional[RequestOptions]
|
|
136
|
+
Request-specific configuration.
|
|
137
|
+
|
|
138
|
+
Returns
|
|
139
|
+
-------
|
|
140
|
+
HttpResponse[FunctionsV1InvokeResponse]
|
|
141
|
+
Success
|
|
142
|
+
"""
|
|
143
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
144
|
+
"functions.v1.FunctionsService/Invoke",
|
|
145
|
+
method="POST",
|
|
146
|
+
json={
|
|
147
|
+
"functionId": function_id,
|
|
148
|
+
"version": version,
|
|
149
|
+
"input": input,
|
|
150
|
+
"idempotencyKey": idempotency_key,
|
|
151
|
+
"retries": retries,
|
|
152
|
+
},
|
|
153
|
+
headers={
|
|
154
|
+
"content-type": "application/json",
|
|
155
|
+
"Connect-Timeout-Ms": str(connect_timeout_ms) if connect_timeout_ms is not None else None,
|
|
156
|
+
},
|
|
157
|
+
request_options=request_options,
|
|
158
|
+
omit=OMIT,
|
|
159
|
+
)
|
|
160
|
+
try:
|
|
161
|
+
if 200 <= _response.status_code < 300:
|
|
162
|
+
_data = typing.cast(
|
|
163
|
+
FunctionsV1InvokeResponse,
|
|
164
|
+
parse_obj_as(
|
|
165
|
+
type_=FunctionsV1InvokeResponse, # type: ignore
|
|
166
|
+
object_=_response.json(),
|
|
167
|
+
),
|
|
168
|
+
)
|
|
169
|
+
return HttpResponse(response=_response, data=_data)
|
|
170
|
+
_response_json = _response.json()
|
|
171
|
+
except JSONDecodeError:
|
|
172
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
173
|
+
except ValidationError as e:
|
|
174
|
+
raise ParsingError(
|
|
175
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
176
|
+
)
|
|
177
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
178
|
+
|
|
179
|
+
def invoke_async(
|
|
180
|
+
self,
|
|
181
|
+
*,
|
|
182
|
+
connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
|
|
183
|
+
function_id: typing.Optional[str] = OMIT,
|
|
184
|
+
version: typing.Optional[str] = OMIT,
|
|
185
|
+
input: typing.Optional[str] = OMIT,
|
|
186
|
+
idempotency_key: typing.Optional[str] = OMIT,
|
|
187
|
+
retries: typing.Optional[int] = OMIT,
|
|
188
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
189
|
+
) -> HttpResponse[FunctionsV1InvokeAsyncResponse]:
|
|
190
|
+
"""
|
|
191
|
+
InvokeAsync queues the invocation and returns its id without waiting.
|
|
192
|
+
The output is dropped. It retries as Invoke does. An idempotency_key
|
|
193
|
+
seen within the window returns the invocation it queued.
|
|
194
|
+
|
|
195
|
+
Parameters
|
|
196
|
+
----------
|
|
197
|
+
connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
|
|
198
|
+
Define the timeout, in ms
|
|
199
|
+
|
|
200
|
+
function_id : typing.Optional[str]
|
|
201
|
+
|
|
202
|
+
version : typing.Optional[str]
|
|
203
|
+
|
|
204
|
+
input : typing.Optional[str]
|
|
205
|
+
|
|
206
|
+
idempotency_key : typing.Optional[str]
|
|
207
|
+
|
|
208
|
+
retries : typing.Optional[int]
|
|
209
|
+
|
|
210
|
+
request_options : typing.Optional[RequestOptions]
|
|
211
|
+
Request-specific configuration.
|
|
212
|
+
|
|
213
|
+
Returns
|
|
214
|
+
-------
|
|
215
|
+
HttpResponse[FunctionsV1InvokeAsyncResponse]
|
|
216
|
+
Success
|
|
217
|
+
"""
|
|
218
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
219
|
+
"functions.v1.FunctionsService/InvokeAsync",
|
|
220
|
+
method="POST",
|
|
221
|
+
json={
|
|
222
|
+
"functionId": function_id,
|
|
223
|
+
"version": version,
|
|
224
|
+
"input": input,
|
|
225
|
+
"idempotencyKey": idempotency_key,
|
|
226
|
+
"retries": retries,
|
|
227
|
+
},
|
|
228
|
+
headers={
|
|
229
|
+
"content-type": "application/json",
|
|
230
|
+
"Connect-Timeout-Ms": str(connect_timeout_ms) if connect_timeout_ms is not None else None,
|
|
231
|
+
},
|
|
232
|
+
request_options=request_options,
|
|
233
|
+
omit=OMIT,
|
|
234
|
+
)
|
|
235
|
+
try:
|
|
236
|
+
if 200 <= _response.status_code < 300:
|
|
237
|
+
_data = typing.cast(
|
|
238
|
+
FunctionsV1InvokeAsyncResponse,
|
|
239
|
+
parse_obj_as(
|
|
240
|
+
type_=FunctionsV1InvokeAsyncResponse, # type: ignore
|
|
241
|
+
object_=_response.json(),
|
|
242
|
+
),
|
|
243
|
+
)
|
|
244
|
+
return HttpResponse(response=_response, data=_data)
|
|
245
|
+
_response_json = _response.json()
|
|
246
|
+
except JSONDecodeError:
|
|
247
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
248
|
+
except ValidationError as e:
|
|
249
|
+
raise ParsingError(
|
|
250
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
251
|
+
)
|
|
252
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
253
|
+
|
|
254
|
+
def list(
|
|
255
|
+
self,
|
|
256
|
+
*,
|
|
257
|
+
connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
|
|
258
|
+
function_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
259
|
+
statuses: typing.Optional[typing.Sequence[FunctionsV1InvocationStatus]] = OMIT,
|
|
260
|
+
start_kinds: typing.Optional[typing.Sequence[FunctionsV1StartKind]] = OMIT,
|
|
261
|
+
pagination: typing.Optional[FunctionsV1PaginationRequest] = OMIT,
|
|
262
|
+
since_ms: typing.Optional[str] = OMIT,
|
|
263
|
+
until_ms: typing.Optional[str] = OMIT,
|
|
264
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
265
|
+
) -> HttpResponse[FunctionsV1ListInvocationsResponse]:
|
|
266
|
+
"""
|
|
267
|
+
Parameters
|
|
268
|
+
----------
|
|
269
|
+
connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
|
|
270
|
+
Define the timeout, in ms
|
|
271
|
+
|
|
272
|
+
function_ids : typing.Optional[typing.Sequence[str]]
|
|
273
|
+
Empty lists match everything.
|
|
274
|
+
|
|
275
|
+
statuses : typing.Optional[typing.Sequence[FunctionsV1InvocationStatus]]
|
|
276
|
+
|
|
277
|
+
start_kinds : typing.Optional[typing.Sequence[FunctionsV1StartKind]]
|
|
278
|
+
|
|
279
|
+
pagination : typing.Optional[FunctionsV1PaginationRequest]
|
|
280
|
+
|
|
281
|
+
since_ms : typing.Optional[str]
|
|
282
|
+
|
|
283
|
+
until_ms : typing.Optional[str]
|
|
284
|
+
|
|
285
|
+
request_options : typing.Optional[RequestOptions]
|
|
286
|
+
Request-specific configuration.
|
|
287
|
+
|
|
288
|
+
Returns
|
|
289
|
+
-------
|
|
290
|
+
HttpResponse[FunctionsV1ListInvocationsResponse]
|
|
291
|
+
Success
|
|
292
|
+
"""
|
|
293
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
294
|
+
"functions.v1.FunctionsService/ListInvocations",
|
|
295
|
+
method="POST",
|
|
296
|
+
json={
|
|
297
|
+
"functionIds": function_ids,
|
|
298
|
+
"statuses": statuses,
|
|
299
|
+
"startKinds": start_kinds,
|
|
300
|
+
"pagination": convert_and_respect_annotation_metadata(
|
|
301
|
+
object_=pagination, annotation=FunctionsV1PaginationRequest, direction="write"
|
|
302
|
+
),
|
|
303
|
+
"sinceMs": since_ms,
|
|
304
|
+
"untilMs": until_ms,
|
|
305
|
+
},
|
|
306
|
+
headers={
|
|
307
|
+
"content-type": "application/json",
|
|
308
|
+
"Connect-Timeout-Ms": str(connect_timeout_ms) if connect_timeout_ms is not None else None,
|
|
309
|
+
},
|
|
310
|
+
request_options=request_options,
|
|
311
|
+
omit=OMIT,
|
|
312
|
+
)
|
|
313
|
+
try:
|
|
314
|
+
if 200 <= _response.status_code < 300:
|
|
315
|
+
_data = typing.cast(
|
|
316
|
+
FunctionsV1ListInvocationsResponse,
|
|
317
|
+
parse_obj_as(
|
|
318
|
+
type_=FunctionsV1ListInvocationsResponse, # type: ignore
|
|
319
|
+
object_=_response.json(),
|
|
320
|
+
),
|
|
321
|
+
)
|
|
322
|
+
return HttpResponse(response=_response, data=_data)
|
|
323
|
+
_response_json = _response.json()
|
|
324
|
+
except JSONDecodeError:
|
|
325
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
326
|
+
except ValidationError as e:
|
|
327
|
+
raise ParsingError(
|
|
328
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
329
|
+
)
|
|
330
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
class AsyncRawInvocationClient:
|
|
334
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
335
|
+
self._client_wrapper = client_wrapper
|
|
336
|
+
|
|
337
|
+
async def get(
|
|
338
|
+
self,
|
|
339
|
+
*,
|
|
340
|
+
connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
|
|
341
|
+
id: typing.Optional[str] = OMIT,
|
|
342
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
343
|
+
) -> AsyncHttpResponse[FunctionsV1GetInvocationResponse]:
|
|
344
|
+
"""
|
|
345
|
+
Invocations; the persisted record of every Invoke, newest first.
|
|
346
|
+
|
|
347
|
+
Parameters
|
|
348
|
+
----------
|
|
349
|
+
connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
|
|
350
|
+
Define the timeout, in ms
|
|
351
|
+
|
|
352
|
+
id : typing.Optional[str]
|
|
353
|
+
|
|
354
|
+
request_options : typing.Optional[RequestOptions]
|
|
355
|
+
Request-specific configuration.
|
|
356
|
+
|
|
357
|
+
Returns
|
|
358
|
+
-------
|
|
359
|
+
AsyncHttpResponse[FunctionsV1GetInvocationResponse]
|
|
360
|
+
Success
|
|
361
|
+
"""
|
|
362
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
363
|
+
"functions.v1.FunctionsService/GetInvocation",
|
|
364
|
+
method="POST",
|
|
365
|
+
json={
|
|
366
|
+
"id": id,
|
|
367
|
+
},
|
|
368
|
+
headers={
|
|
369
|
+
"content-type": "application/json",
|
|
370
|
+
"Connect-Timeout-Ms": str(connect_timeout_ms) if connect_timeout_ms is not None else None,
|
|
371
|
+
},
|
|
372
|
+
request_options=request_options,
|
|
373
|
+
omit=OMIT,
|
|
374
|
+
)
|
|
375
|
+
try:
|
|
376
|
+
if 200 <= _response.status_code < 300:
|
|
377
|
+
_data = typing.cast(
|
|
378
|
+
FunctionsV1GetInvocationResponse,
|
|
379
|
+
parse_obj_as(
|
|
380
|
+
type_=FunctionsV1GetInvocationResponse, # type: ignore
|
|
381
|
+
object_=_response.json(),
|
|
382
|
+
),
|
|
383
|
+
)
|
|
384
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
385
|
+
_response_json = _response.json()
|
|
386
|
+
except JSONDecodeError:
|
|
387
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
388
|
+
except ValidationError as e:
|
|
389
|
+
raise ParsingError(
|
|
390
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
391
|
+
)
|
|
392
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
393
|
+
|
|
394
|
+
async def invoke(
|
|
395
|
+
self,
|
|
396
|
+
*,
|
|
397
|
+
connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
|
|
398
|
+
function_id: typing.Optional[str] = OMIT,
|
|
399
|
+
version: typing.Optional[str] = OMIT,
|
|
400
|
+
input: typing.Optional[str] = OMIT,
|
|
401
|
+
idempotency_key: typing.Optional[str] = OMIT,
|
|
402
|
+
retries: typing.Optional[int] = OMIT,
|
|
403
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
404
|
+
) -> AsyncHttpResponse[FunctionsV1InvokeResponse]:
|
|
405
|
+
"""
|
|
406
|
+
Invocation; validate input, run one version against it, validate output.
|
|
407
|
+
An RPC error means the function did not produce a result: the request was
|
|
408
|
+
rejected (unknown function, input violates the contract, no capacity) or
|
|
409
|
+
the platform failed. Input violations are INVALID_ARGUMENT with one
|
|
410
|
+
ContractViolation error detail each. If the function ran, the RPC
|
|
411
|
+
succeeds and the response carries its output or a FunctionError. A
|
|
412
|
+
function that raised, crashed or timed out, or a platform that could
|
|
413
|
+
not run it, runs again up to the call's or the function's retries, with
|
|
414
|
+
exponential backoff, while the call's deadline leaves room. An input
|
|
415
|
+
that violates the contract never runs again.
|
|
416
|
+
|
|
417
|
+
Parameters
|
|
418
|
+
----------
|
|
419
|
+
connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
|
|
420
|
+
Define the timeout, in ms
|
|
421
|
+
|
|
422
|
+
function_id : typing.Optional[str]
|
|
423
|
+
|
|
424
|
+
version : typing.Optional[str]
|
|
425
|
+
|
|
426
|
+
input : typing.Optional[str]
|
|
427
|
+
|
|
428
|
+
idempotency_key : typing.Optional[str]
|
|
429
|
+
idempotency_key makes the call safe to retry. Within the server's
|
|
430
|
+
idempotency window, every call to the same function with the same key
|
|
431
|
+
returns the invocation the first call started, with its output or
|
|
432
|
+
error, instead of running again. The key is released, so that a retry
|
|
433
|
+
runs, only when the platform never sent the invocation to a host. A
|
|
434
|
+
call a host took but never reported on has an unknown outcome and holds
|
|
435
|
+
the key: a retry gets ABORTED, and a new key runs again.
|
|
436
|
+
|
|
437
|
+
retries : typing.Optional[int]
|
|
438
|
+
retries, when set, is how many more times this call runs after a failed
|
|
439
|
+
attempt instead of the function's retries.
|
|
440
|
+
|
|
441
|
+
request_options : typing.Optional[RequestOptions]
|
|
442
|
+
Request-specific configuration.
|
|
443
|
+
|
|
444
|
+
Returns
|
|
445
|
+
-------
|
|
446
|
+
AsyncHttpResponse[FunctionsV1InvokeResponse]
|
|
447
|
+
Success
|
|
448
|
+
"""
|
|
449
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
450
|
+
"functions.v1.FunctionsService/Invoke",
|
|
451
|
+
method="POST",
|
|
452
|
+
json={
|
|
453
|
+
"functionId": function_id,
|
|
454
|
+
"version": version,
|
|
455
|
+
"input": input,
|
|
456
|
+
"idempotencyKey": idempotency_key,
|
|
457
|
+
"retries": retries,
|
|
458
|
+
},
|
|
459
|
+
headers={
|
|
460
|
+
"content-type": "application/json",
|
|
461
|
+
"Connect-Timeout-Ms": str(connect_timeout_ms) if connect_timeout_ms is not None else None,
|
|
462
|
+
},
|
|
463
|
+
request_options=request_options,
|
|
464
|
+
omit=OMIT,
|
|
465
|
+
)
|
|
466
|
+
try:
|
|
467
|
+
if 200 <= _response.status_code < 300:
|
|
468
|
+
_data = typing.cast(
|
|
469
|
+
FunctionsV1InvokeResponse,
|
|
470
|
+
parse_obj_as(
|
|
471
|
+
type_=FunctionsV1InvokeResponse, # type: ignore
|
|
472
|
+
object_=_response.json(),
|
|
473
|
+
),
|
|
474
|
+
)
|
|
475
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
476
|
+
_response_json = _response.json()
|
|
477
|
+
except JSONDecodeError:
|
|
478
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
479
|
+
except ValidationError as e:
|
|
480
|
+
raise ParsingError(
|
|
481
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
482
|
+
)
|
|
483
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
484
|
+
|
|
485
|
+
async def invoke_async(
|
|
486
|
+
self,
|
|
487
|
+
*,
|
|
488
|
+
connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
|
|
489
|
+
function_id: typing.Optional[str] = OMIT,
|
|
490
|
+
version: typing.Optional[str] = OMIT,
|
|
491
|
+
input: typing.Optional[str] = OMIT,
|
|
492
|
+
idempotency_key: typing.Optional[str] = OMIT,
|
|
493
|
+
retries: typing.Optional[int] = OMIT,
|
|
494
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
495
|
+
) -> AsyncHttpResponse[FunctionsV1InvokeAsyncResponse]:
|
|
496
|
+
"""
|
|
497
|
+
InvokeAsync queues the invocation and returns its id without waiting.
|
|
498
|
+
The output is dropped. It retries as Invoke does. An idempotency_key
|
|
499
|
+
seen within the window returns the invocation it queued.
|
|
500
|
+
|
|
501
|
+
Parameters
|
|
502
|
+
----------
|
|
503
|
+
connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
|
|
504
|
+
Define the timeout, in ms
|
|
505
|
+
|
|
506
|
+
function_id : typing.Optional[str]
|
|
507
|
+
|
|
508
|
+
version : typing.Optional[str]
|
|
509
|
+
|
|
510
|
+
input : typing.Optional[str]
|
|
511
|
+
|
|
512
|
+
idempotency_key : typing.Optional[str]
|
|
513
|
+
|
|
514
|
+
retries : typing.Optional[int]
|
|
515
|
+
|
|
516
|
+
request_options : typing.Optional[RequestOptions]
|
|
517
|
+
Request-specific configuration.
|
|
518
|
+
|
|
519
|
+
Returns
|
|
520
|
+
-------
|
|
521
|
+
AsyncHttpResponse[FunctionsV1InvokeAsyncResponse]
|
|
522
|
+
Success
|
|
523
|
+
"""
|
|
524
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
525
|
+
"functions.v1.FunctionsService/InvokeAsync",
|
|
526
|
+
method="POST",
|
|
527
|
+
json={
|
|
528
|
+
"functionId": function_id,
|
|
529
|
+
"version": version,
|
|
530
|
+
"input": input,
|
|
531
|
+
"idempotencyKey": idempotency_key,
|
|
532
|
+
"retries": retries,
|
|
533
|
+
},
|
|
534
|
+
headers={
|
|
535
|
+
"content-type": "application/json",
|
|
536
|
+
"Connect-Timeout-Ms": str(connect_timeout_ms) if connect_timeout_ms is not None else None,
|
|
537
|
+
},
|
|
538
|
+
request_options=request_options,
|
|
539
|
+
omit=OMIT,
|
|
540
|
+
)
|
|
541
|
+
try:
|
|
542
|
+
if 200 <= _response.status_code < 300:
|
|
543
|
+
_data = typing.cast(
|
|
544
|
+
FunctionsV1InvokeAsyncResponse,
|
|
545
|
+
parse_obj_as(
|
|
546
|
+
type_=FunctionsV1InvokeAsyncResponse, # type: ignore
|
|
547
|
+
object_=_response.json(),
|
|
548
|
+
),
|
|
549
|
+
)
|
|
550
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
551
|
+
_response_json = _response.json()
|
|
552
|
+
except JSONDecodeError:
|
|
553
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
554
|
+
except ValidationError as e:
|
|
555
|
+
raise ParsingError(
|
|
556
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
557
|
+
)
|
|
558
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
559
|
+
|
|
560
|
+
async def list(
|
|
561
|
+
self,
|
|
562
|
+
*,
|
|
563
|
+
connect_timeout_ms: typing.Optional[ConnectTimeoutHeader] = None,
|
|
564
|
+
function_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
565
|
+
statuses: typing.Optional[typing.Sequence[FunctionsV1InvocationStatus]] = OMIT,
|
|
566
|
+
start_kinds: typing.Optional[typing.Sequence[FunctionsV1StartKind]] = OMIT,
|
|
567
|
+
pagination: typing.Optional[FunctionsV1PaginationRequest] = OMIT,
|
|
568
|
+
since_ms: typing.Optional[str] = OMIT,
|
|
569
|
+
until_ms: typing.Optional[str] = OMIT,
|
|
570
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
571
|
+
) -> AsyncHttpResponse[FunctionsV1ListInvocationsResponse]:
|
|
572
|
+
"""
|
|
573
|
+
Parameters
|
|
574
|
+
----------
|
|
575
|
+
connect_timeout_ms : typing.Optional[ConnectTimeoutHeader]
|
|
576
|
+
Define the timeout, in ms
|
|
577
|
+
|
|
578
|
+
function_ids : typing.Optional[typing.Sequence[str]]
|
|
579
|
+
Empty lists match everything.
|
|
580
|
+
|
|
581
|
+
statuses : typing.Optional[typing.Sequence[FunctionsV1InvocationStatus]]
|
|
582
|
+
|
|
583
|
+
start_kinds : typing.Optional[typing.Sequence[FunctionsV1StartKind]]
|
|
584
|
+
|
|
585
|
+
pagination : typing.Optional[FunctionsV1PaginationRequest]
|
|
586
|
+
|
|
587
|
+
since_ms : typing.Optional[str]
|
|
588
|
+
|
|
589
|
+
until_ms : typing.Optional[str]
|
|
590
|
+
|
|
591
|
+
request_options : typing.Optional[RequestOptions]
|
|
592
|
+
Request-specific configuration.
|
|
593
|
+
|
|
594
|
+
Returns
|
|
595
|
+
-------
|
|
596
|
+
AsyncHttpResponse[FunctionsV1ListInvocationsResponse]
|
|
597
|
+
Success
|
|
598
|
+
"""
|
|
599
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
600
|
+
"functions.v1.FunctionsService/ListInvocations",
|
|
601
|
+
method="POST",
|
|
602
|
+
json={
|
|
603
|
+
"functionIds": function_ids,
|
|
604
|
+
"statuses": statuses,
|
|
605
|
+
"startKinds": start_kinds,
|
|
606
|
+
"pagination": convert_and_respect_annotation_metadata(
|
|
607
|
+
object_=pagination, annotation=FunctionsV1PaginationRequest, direction="write"
|
|
608
|
+
),
|
|
609
|
+
"sinceMs": since_ms,
|
|
610
|
+
"untilMs": until_ms,
|
|
611
|
+
},
|
|
612
|
+
headers={
|
|
613
|
+
"content-type": "application/json",
|
|
614
|
+
"Connect-Timeout-Ms": str(connect_timeout_ms) if connect_timeout_ms is not None else None,
|
|
615
|
+
},
|
|
616
|
+
request_options=request_options,
|
|
617
|
+
omit=OMIT,
|
|
618
|
+
)
|
|
619
|
+
try:
|
|
620
|
+
if 200 <= _response.status_code < 300:
|
|
621
|
+
_data = typing.cast(
|
|
622
|
+
FunctionsV1ListInvocationsResponse,
|
|
623
|
+
parse_obj_as(
|
|
624
|
+
type_=FunctionsV1ListInvocationsResponse, # type: ignore
|
|
625
|
+
object_=_response.json(),
|
|
626
|
+
),
|
|
627
|
+
)
|
|
628
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
629
|
+
_response_json = _response.json()
|
|
630
|
+
except JSONDecodeError:
|
|
631
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
632
|
+
except ValidationError as e:
|
|
633
|
+
raise ParsingError(
|
|
634
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
635
|
+
)
|
|
636
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|