22
33from __future__ import annotations
44
5+ from typing_extensions import Literal
6+
57import httpx
68
79from ..._types import NOT_GIVEN , Body , Query , Headers , NotGiven
1416 async_to_raw_response_wrapper ,
1517 async_to_streamed_response_wrapper ,
1618)
17- from ...types .apps import invocation_create_params
19+ from ...types .apps import invocation_create_params , invocation_update_params
1820from ..._base_client import make_request_options
1921from ...types .apps .invocation_create_response import InvocationCreateResponse
22+ from ...types .apps .invocation_update_response import InvocationUpdateResponse
2023from ...types .apps .invocation_retrieve_response import InvocationRetrieveResponse
2124
2225__all__ = ["InvocationsResource" , "AsyncInvocationsResource" ]
@@ -48,6 +51,7 @@ def create(
4851 action_name : str ,
4952 app_name : str ,
5053 version : str ,
54+ async_ : bool | NotGiven = NOT_GIVEN ,
5155 payload : str | NotGiven = NOT_GIVEN ,
5256 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5357 # The extra values given here take precedence over values defined on the client or passed to this method.
@@ -66,6 +70,9 @@ def create(
6670
6771 version: Version of the application
6872
73+ async_: If true, invoke asynchronously. When set, the API responds 202 Accepted with
74+ status "queued".
75+
6976 payload: Input data for the action, sent as a JSON string.
7077
7178 extra_headers: Send extra headers
@@ -83,6 +90,7 @@ def create(
8390 "action_name" : action_name ,
8491 "app_name" : app_name ,
8592 "version" : version ,
93+ "async_" : async_ ,
8694 "payload" : payload ,
8795 },
8896 invocation_create_params .InvocationCreateParams ,
@@ -126,6 +134,52 @@ def retrieve(
126134 cast_to = InvocationRetrieveResponse ,
127135 )
128136
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+
129183
130184class AsyncInvocationsResource (AsyncAPIResource ):
131185 @cached_property
@@ -153,6 +207,7 @@ async def create(
153207 action_name : str ,
154208 app_name : str ,
155209 version : str ,
210+ async_ : bool | NotGiven = NOT_GIVEN ,
156211 payload : str | NotGiven = NOT_GIVEN ,
157212 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
158213 # 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(
171226
172227 version: Version of the application
173228
229+ async_: If true, invoke asynchronously. When set, the API responds 202 Accepted with
230+ status "queued".
231+
174232 payload: Input data for the action, sent as a JSON string.
175233
176234 extra_headers: Send extra headers
@@ -188,6 +246,7 @@ async def create(
188246 "action_name" : action_name ,
189247 "app_name" : app_name ,
190248 "version" : version ,
249+ "async_" : async_ ,
191250 "payload" : payload ,
192251 },
193252 invocation_create_params .InvocationCreateParams ,
@@ -231,6 +290,52 @@ async def retrieve(
231290 cast_to = InvocationRetrieveResponse ,
232291 )
233292
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+
234339
235340class InvocationsResourceWithRawResponse :
236341 def __init__ (self , invocations : InvocationsResource ) -> None :
@@ -242,6 +347,9 @@ def __init__(self, invocations: InvocationsResource) -> None:
242347 self .retrieve = to_raw_response_wrapper (
243348 invocations .retrieve ,
244349 )
350+ self .update = to_raw_response_wrapper (
351+ invocations .update ,
352+ )
245353
246354
247355class AsyncInvocationsResourceWithRawResponse :
@@ -254,6 +362,9 @@ def __init__(self, invocations: AsyncInvocationsResource) -> None:
254362 self .retrieve = async_to_raw_response_wrapper (
255363 invocations .retrieve ,
256364 )
365+ self .update = async_to_raw_response_wrapper (
366+ invocations .update ,
367+ )
257368
258369
259370class InvocationsResourceWithStreamingResponse :
@@ -266,6 +377,9 @@ def __init__(self, invocations: InvocationsResource) -> None:
266377 self .retrieve = to_streamed_response_wrapper (
267378 invocations .retrieve ,
268379 )
380+ self .update = to_streamed_response_wrapper (
381+ invocations .update ,
382+ )
269383
270384
271385class AsyncInvocationsResourceWithStreamingResponse :
@@ -278,3 +392,6 @@ def __init__(self, invocations: AsyncInvocationsResource) -> None:
278392 self .retrieve = async_to_streamed_response_wrapper (
279393 invocations .retrieve ,
280394 )
395+ self .update = async_to_streamed_response_wrapper (
396+ invocations .update ,
397+ )
0 commit comments