2
2
3
3
from __future__ import annotations
4
4
5
+ from typing_extensions import Literal
6
+
5
7
import httpx
6
8
7
9
from ..._types import NOT_GIVEN , Body , Query , Headers , NotGiven
14
16
async_to_raw_response_wrapper ,
15
17
async_to_streamed_response_wrapper ,
16
18
)
17
- from ...types .apps import invocation_create_params
19
+ from ...types .apps import invocation_create_params , invocation_update_params
18
20
from ..._base_client import make_request_options
19
21
from ...types .apps .invocation_create_response import InvocationCreateResponse
22
+ from ...types .apps .invocation_update_response import InvocationUpdateResponse
20
23
from ...types .apps .invocation_retrieve_response import InvocationRetrieveResponse
21
24
22
25
__all__ = ["InvocationsResource" , "AsyncInvocationsResource" ]
@@ -48,6 +51,7 @@ def create(
48
51
action_name : str ,
49
52
app_name : str ,
50
53
version : str ,
54
+ async_ : bool | NotGiven = NOT_GIVEN ,
51
55
payload : str | NotGiven = NOT_GIVEN ,
52
56
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
53
57
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -66,6 +70,9 @@ def create(
66
70
67
71
version: Version of the application
68
72
73
+ async_: If true, invoke asynchronously. When set, the API responds 202 Accepted with
74
+ status "queued".
75
+
69
76
payload: Input data for the action, sent as a JSON string.
70
77
71
78
extra_headers: Send extra headers
@@ -83,6 +90,7 @@ def create(
83
90
"action_name" : action_name ,
84
91
"app_name" : app_name ,
85
92
"version" : version ,
93
+ "async_" : async_ ,
86
94
"payload" : payload ,
87
95
},
88
96
invocation_create_params .InvocationCreateParams ,
@@ -126,6 +134,52 @@ def retrieve(
126
134
cast_to = InvocationRetrieveResponse ,
127
135
)
128
136
137
+ def update (
138
+ self ,
139
+ id : str ,
140
+ * ,
141
+ status : Literal ["succeeded" , "failed" ],
142
+ output : str | NotGiven = NOT_GIVEN ,
143
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
144
+ # The extra values given here take precedence over values defined on the client or passed to this method.
145
+ extra_headers : Headers | None = None ,
146
+ extra_query : Query | None = None ,
147
+ extra_body : Body | None = None ,
148
+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
149
+ ) -> InvocationUpdateResponse :
150
+ """
151
+ Update invocation status or output
152
+
153
+ Args:
154
+ status: New status for the invocation.
155
+
156
+ output: Updated output of the invocation rendered as JSON string.
157
+
158
+ extra_headers: Send extra headers
159
+
160
+ extra_query: Add additional query parameters to the request
161
+
162
+ extra_body: Add additional JSON properties to the request
163
+
164
+ timeout: Override the client-level default timeout for this request, in seconds
165
+ """
166
+ if not id :
167
+ raise ValueError (f"Expected a non-empty value for `id` but received { id !r} " )
168
+ return self ._patch (
169
+ f"/invocations/{ id } " ,
170
+ body = maybe_transform (
171
+ {
172
+ "status" : status ,
173
+ "output" : output ,
174
+ },
175
+ invocation_update_params .InvocationUpdateParams ,
176
+ ),
177
+ options = make_request_options (
178
+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
179
+ ),
180
+ cast_to = InvocationUpdateResponse ,
181
+ )
182
+
129
183
130
184
class AsyncInvocationsResource (AsyncAPIResource ):
131
185
@cached_property
@@ -153,6 +207,7 @@ async def create(
153
207
action_name : str ,
154
208
app_name : str ,
155
209
version : str ,
210
+ async_ : bool | NotGiven = NOT_GIVEN ,
156
211
payload : str | NotGiven = NOT_GIVEN ,
157
212
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
158
213
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -171,6 +226,9 @@ async def create(
171
226
172
227
version: Version of the application
173
228
229
+ async_: If true, invoke asynchronously. When set, the API responds 202 Accepted with
230
+ status "queued".
231
+
174
232
payload: Input data for the action, sent as a JSON string.
175
233
176
234
extra_headers: Send extra headers
@@ -188,6 +246,7 @@ async def create(
188
246
"action_name" : action_name ,
189
247
"app_name" : app_name ,
190
248
"version" : version ,
249
+ "async_" : async_ ,
191
250
"payload" : payload ,
192
251
},
193
252
invocation_create_params .InvocationCreateParams ,
@@ -231,6 +290,52 @@ async def retrieve(
231
290
cast_to = InvocationRetrieveResponse ,
232
291
)
233
292
293
+ async def update (
294
+ self ,
295
+ id : str ,
296
+ * ,
297
+ status : Literal ["succeeded" , "failed" ],
298
+ output : str | NotGiven = NOT_GIVEN ,
299
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
300
+ # The extra values given here take precedence over values defined on the client or passed to this method.
301
+ extra_headers : Headers | None = None ,
302
+ extra_query : Query | None = None ,
303
+ extra_body : Body | None = None ,
304
+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
305
+ ) -> InvocationUpdateResponse :
306
+ """
307
+ Update invocation status or output
308
+
309
+ Args:
310
+ status: New status for the invocation.
311
+
312
+ output: Updated output of the invocation rendered as JSON string.
313
+
314
+ extra_headers: Send extra headers
315
+
316
+ extra_query: Add additional query parameters to the request
317
+
318
+ extra_body: Add additional JSON properties to the request
319
+
320
+ timeout: Override the client-level default timeout for this request, in seconds
321
+ """
322
+ if not id :
323
+ raise ValueError (f"Expected a non-empty value for `id` but received { id !r} " )
324
+ return await self ._patch (
325
+ f"/invocations/{ id } " ,
326
+ body = await async_maybe_transform (
327
+ {
328
+ "status" : status ,
329
+ "output" : output ,
330
+ },
331
+ invocation_update_params .InvocationUpdateParams ,
332
+ ),
333
+ options = make_request_options (
334
+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
335
+ ),
336
+ cast_to = InvocationUpdateResponse ,
337
+ )
338
+
234
339
235
340
class InvocationsResourceWithRawResponse :
236
341
def __init__ (self , invocations : InvocationsResource ) -> None :
@@ -242,6 +347,9 @@ def __init__(self, invocations: InvocationsResource) -> None:
242
347
self .retrieve = to_raw_response_wrapper (
243
348
invocations .retrieve ,
244
349
)
350
+ self .update = to_raw_response_wrapper (
351
+ invocations .update ,
352
+ )
245
353
246
354
247
355
class AsyncInvocationsResourceWithRawResponse :
@@ -254,6 +362,9 @@ def __init__(self, invocations: AsyncInvocationsResource) -> None:
254
362
self .retrieve = async_to_raw_response_wrapper (
255
363
invocations .retrieve ,
256
364
)
365
+ self .update = async_to_raw_response_wrapper (
366
+ invocations .update ,
367
+ )
257
368
258
369
259
370
class InvocationsResourceWithStreamingResponse :
@@ -266,6 +377,9 @@ def __init__(self, invocations: InvocationsResource) -> None:
266
377
self .retrieve = to_streamed_response_wrapper (
267
378
invocations .retrieve ,
268
379
)
380
+ self .update = to_streamed_response_wrapper (
381
+ invocations .update ,
382
+ )
269
383
270
384
271
385
class AsyncInvocationsResourceWithStreamingResponse :
@@ -278,3 +392,6 @@ def __init__(self, invocations: AsyncInvocationsResource) -> None:
278
392
self .retrieve = async_to_streamed_response_wrapper (
279
393
invocations .retrieve ,
280
394
)
395
+ self .update = async_to_streamed_response_wrapper (
396
+ invocations .update ,
397
+ )
0 commit comments