44
55import httpx
66
7- from ...types import function_invoke_sync_params , function_invoke_async_params
87from .openapi import (
98 OpenAPIResource ,
109 AsyncOpenAPIResource ,
1413 AsyncOpenAPIResourceWithStreamingResponse ,
1514)
1615from ..._types import NOT_GIVEN , Body , Query , Headers , NotGiven
17- from ..._utils import (
18- maybe_transform ,
19- async_maybe_transform ,
20- )
2116from ..._compat import cached_property
2217from ..._resource import SyncAPIResource , AsyncAPIResource
2318from ..._response import (
3934)
4035from ...types .function_list import FunctionList
4136from .invocations .invocations import InvocationsResource , AsyncInvocationsResource
42- from ...types .shared .function_invocation_detail import FunctionInvocationDetail
4337
4438__all__ = ["FunctionsResource" , "AsyncFunctionsResource" ]
4539
@@ -80,105 +74,6 @@ def list(
8074 cast_to = FunctionList ,
8175 )
8276
83- def invoke_async (
84- self ,
85- function_name : str ,
86- * ,
87- project_name : str ,
88- request : object ,
89- runloop_meta : function_invoke_async_params .RunloopMeta | NotGiven = NOT_GIVEN ,
90- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
91- # The extra values given here take precedence over values defined on the client or passed to this method.
92- extra_headers : Headers | None = None ,
93- extra_query : Query | None = None ,
94- extra_body : Body | None = None ,
95- timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
96- ) -> FunctionInvocationDetail :
97- """Invoke the remote function asynchronously.
98-
99- This will return a job id that can be
100- used to query the status of the function invocation.
101-
102- Args:
103- request: Json of the request
104-
105- extra_headers: Send extra headers
106-
107- extra_query: Add additional query parameters to the request
108-
109- extra_body: Add additional JSON properties to the request
110-
111- timeout: Override the client-level default timeout for this request, in seconds
112- """
113- if not project_name :
114- raise ValueError (f"Expected a non-empty value for `project_name` but received { project_name !r} " )
115- if not function_name :
116- raise ValueError (f"Expected a non-empty value for `function_name` but received { function_name !r} " )
117- return self ._post (
118- f"/v1/functions/{ project_name } /{ function_name } /invoke_async" ,
119- body = maybe_transform (
120- {
121- "request" : request ,
122- "runloop_meta" : runloop_meta ,
123- },
124- function_invoke_async_params .FunctionInvokeAsyncParams ,
125- ),
126- options = make_request_options (
127- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
128- ),
129- cast_to = FunctionInvocationDetail ,
130- )
131-
132- def invoke_sync (
133- self ,
134- function_name : str ,
135- * ,
136- project_name : str ,
137- request : object ,
138- runloop_meta : function_invoke_sync_params .RunloopMeta | NotGiven = NOT_GIVEN ,
139- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
140- # The extra values given here take precedence over values defined on the client or passed to this method.
141- extra_headers : Headers | None = None ,
142- extra_query : Query | None = None ,
143- extra_body : Body | None = None ,
144- timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
145- ) -> FunctionInvocationDetail :
146- """Invoke the remote function synchronously.
147-
148- This will block until the function
149- completes and return the result. If the function call takes too long, the
150- request will timeout.
151-
152- Args:
153- request: Json of the request
154-
155- extra_headers: Send extra headers
156-
157- extra_query: Add additional query parameters to the request
158-
159- extra_body: Add additional JSON properties to the request
160-
161- timeout: Override the client-level default timeout for this request, in seconds
162- """
163- if not project_name :
164- raise ValueError (f"Expected a non-empty value for `project_name` but received { project_name !r} " )
165- if not function_name :
166- raise ValueError (f"Expected a non-empty value for `function_name` but received { function_name !r} " )
167- return self ._post (
168- f"/v1/functions/{ project_name } /{ function_name } /invoke_sync" ,
169- body = maybe_transform (
170- {
171- "request" : request ,
172- "runloop_meta" : runloop_meta ,
173- },
174- function_invoke_sync_params .FunctionInvokeSyncParams ,
175- ),
176- options = make_request_options (
177- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
178- ),
179- cast_to = FunctionInvocationDetail ,
180- )
181-
18277
18378class AsyncFunctionsResource (AsyncAPIResource ):
18479 @cached_property
@@ -216,105 +111,6 @@ async def list(
216111 cast_to = FunctionList ,
217112 )
218113
219- async def invoke_async (
220- self ,
221- function_name : str ,
222- * ,
223- project_name : str ,
224- request : object ,
225- runloop_meta : function_invoke_async_params .RunloopMeta | NotGiven = NOT_GIVEN ,
226- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
227- # The extra values given here take precedence over values defined on the client or passed to this method.
228- extra_headers : Headers | None = None ,
229- extra_query : Query | None = None ,
230- extra_body : Body | None = None ,
231- timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
232- ) -> FunctionInvocationDetail :
233- """Invoke the remote function asynchronously.
234-
235- This will return a job id that can be
236- used to query the status of the function invocation.
237-
238- Args:
239- request: Json of the request
240-
241- extra_headers: Send extra headers
242-
243- extra_query: Add additional query parameters to the request
244-
245- extra_body: Add additional JSON properties to the request
246-
247- timeout: Override the client-level default timeout for this request, in seconds
248- """
249- if not project_name :
250- raise ValueError (f"Expected a non-empty value for `project_name` but received { project_name !r} " )
251- if not function_name :
252- raise ValueError (f"Expected a non-empty value for `function_name` but received { function_name !r} " )
253- return await self ._post (
254- f"/v1/functions/{ project_name } /{ function_name } /invoke_async" ,
255- body = await async_maybe_transform (
256- {
257- "request" : request ,
258- "runloop_meta" : runloop_meta ,
259- },
260- function_invoke_async_params .FunctionInvokeAsyncParams ,
261- ),
262- options = make_request_options (
263- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
264- ),
265- cast_to = FunctionInvocationDetail ,
266- )
267-
268- async def invoke_sync (
269- self ,
270- function_name : str ,
271- * ,
272- project_name : str ,
273- request : object ,
274- runloop_meta : function_invoke_sync_params .RunloopMeta | NotGiven = NOT_GIVEN ,
275- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
276- # The extra values given here take precedence over values defined on the client or passed to this method.
277- extra_headers : Headers | None = None ,
278- extra_query : Query | None = None ,
279- extra_body : Body | None = None ,
280- timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
281- ) -> FunctionInvocationDetail :
282- """Invoke the remote function synchronously.
283-
284- This will block until the function
285- completes and return the result. If the function call takes too long, the
286- request will timeout.
287-
288- Args:
289- request: Json of the request
290-
291- extra_headers: Send extra headers
292-
293- extra_query: Add additional query parameters to the request
294-
295- extra_body: Add additional JSON properties to the request
296-
297- timeout: Override the client-level default timeout for this request, in seconds
298- """
299- if not project_name :
300- raise ValueError (f"Expected a non-empty value for `project_name` but received { project_name !r} " )
301- if not function_name :
302- raise ValueError (f"Expected a non-empty value for `function_name` but received { function_name !r} " )
303- return await self ._post (
304- f"/v1/functions/{ project_name } /{ function_name } /invoke_sync" ,
305- body = await async_maybe_transform (
306- {
307- "request" : request ,
308- "runloop_meta" : runloop_meta ,
309- },
310- function_invoke_sync_params .FunctionInvokeSyncParams ,
311- ),
312- options = make_request_options (
313- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
314- ),
315- cast_to = FunctionInvocationDetail ,
316- )
317-
318114
319115class FunctionsResourceWithRawResponse :
320116 def __init__ (self , functions : FunctionsResource ) -> None :
@@ -323,12 +119,6 @@ def __init__(self, functions: FunctionsResource) -> None:
323119 self .list = to_raw_response_wrapper (
324120 functions .list ,
325121 )
326- self .invoke_async = to_raw_response_wrapper (
327- functions .invoke_async ,
328- )
329- self .invoke_sync = to_raw_response_wrapper (
330- functions .invoke_sync ,
331- )
332122
333123 @cached_property
334124 def invocations (self ) -> InvocationsResourceWithRawResponse :
@@ -346,12 +136,6 @@ def __init__(self, functions: AsyncFunctionsResource) -> None:
346136 self .list = async_to_raw_response_wrapper (
347137 functions .list ,
348138 )
349- self .invoke_async = async_to_raw_response_wrapper (
350- functions .invoke_async ,
351- )
352- self .invoke_sync = async_to_raw_response_wrapper (
353- functions .invoke_sync ,
354- )
355139
356140 @cached_property
357141 def invocations (self ) -> AsyncInvocationsResourceWithRawResponse :
@@ -369,12 +153,6 @@ def __init__(self, functions: FunctionsResource) -> None:
369153 self .list = to_streamed_response_wrapper (
370154 functions .list ,
371155 )
372- self .invoke_async = to_streamed_response_wrapper (
373- functions .invoke_async ,
374- )
375- self .invoke_sync = to_streamed_response_wrapper (
376- functions .invoke_sync ,
377- )
378156
379157 @cached_property
380158 def invocations (self ) -> InvocationsResourceWithStreamingResponse :
@@ -392,12 +170,6 @@ def __init__(self, functions: AsyncFunctionsResource) -> None:
392170 self .list = async_to_streamed_response_wrapper (
393171 functions .list ,
394172 )
395- self .invoke_async = async_to_streamed_response_wrapper (
396- functions .invoke_async ,
397- )
398- self .invoke_sync = async_to_streamed_response_wrapper (
399- functions .invoke_sync ,
400- )
401173
402174 @cached_property
403175 def invocations (self ) -> AsyncInvocationsResourceWithStreamingResponse :
0 commit comments