@@ -75,6 +75,26 @@ def __init__(self, func: Callable[..., Any], script_file: str):
75
75
self .http_type = 'function'
76
76
self ._is_http_function = False
77
77
78
+ def __str__ (self ):
79
+ """Return the function.json representation of the function"""
80
+ return self .get_function_json ()
81
+
82
+ def __call__ (self , * args , ** kwargs ):
83
+ """This would allow the Function object to be directly callable and runnable
84
+ directly using the interpreter locally.
85
+
86
+ Example:
87
+ @app.route(route="http_trigger")
88
+ def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
89
+ return "Hello, World!"
90
+
91
+ print(http_trigger(None))
92
+
93
+ ➜ python function_app.py
94
+ Hello, World!
95
+ """
96
+ return self ._func (* args , ** kwargs )
97
+
78
98
def add_binding (self , binding : Binding ) -> None :
79
99
"""Add a binding instance to the function.
80
100
@@ -201,17 +221,15 @@ def get_function_json(self) -> str:
201
221
"""
202
222
return json .dumps (self .get_dict_repr (), cls = StringifyEnumJsonEncoder )
203
223
204
- def __str__ (self ):
205
- return self .get_function_json ()
206
-
207
224
208
225
class FunctionBuilder (object ):
209
226
210
227
def __init__ (self , func , function_script_file ):
211
228
self ._function = Function (func , function_script_file )
212
229
213
230
def __call__ (self , * args , ** kwargs ):
214
- pass
231
+ """Call the Function object directly"""
232
+ return self ._function (* args , ** kwargs )
215
233
216
234
def configure_http_type (self , http_type : str ) -> 'FunctionBuilder' :
217
235
self ._function .set_http_type (http_type )
0 commit comments