@@ -70,6 +70,7 @@ async def execute_api_call(
7070 out_type : Optional [Type [T ]] = None ,
7171 params : Optional [QueryParamTypes ] = None ,
7272 headers : Optional [HeaderTypes ] = None ,
73+ allow_null_body : bool = False ,
7374 ) -> Optional [T ]:
7475 try :
7576 return await self .__execute_api_call (
@@ -79,7 +80,8 @@ async def execute_api_call(
7980 form_body = form_body ,
8081 out_type = out_type ,
8182 params = params ,
82- headers = headers
83+ headers = headers ,
84+ allow_null_body = allow_null_body
8385 )
8486 except SaicApiException as e :
8587 raise e
@@ -96,12 +98,13 @@ async def __execute_api_call(
9698 out_type : Optional [Type [T ]] = None ,
9799 params : Optional [QueryParamTypes ] = None ,
98100 headers : Optional [HeaderTypes ] = None ,
101+ allow_null_body : bool = False ,
99102 ) -> Optional [T ]:
100103 url = f"{ self .__configuration .base_uri } { path [1 :] if path .startswith ('/' ) else path } "
101104 json_body = asdict (body ) if body else None
102105 req = httpx .Request (method , url , params = params , headers = headers , data = form_body , json = json_body )
103106 response = await self .__api_client .send (req )
104- return await self .__deserialize (req , response , out_type )
107+ return await self .__deserialize (req , response , out_type , allow_null_body )
105108
106109 async def execute_api_call_with_event_id (
107110 self ,
@@ -139,7 +142,8 @@ async def __deserialize(
139142 self ,
140143 request : httpx .Request ,
141144 response : httpx .Response ,
142- data_class : Optional [Type [T ]]
145+ data_class : Optional [Type [T ]],
146+ allow_null_body : bool
143147 ) -> Optional [T ]:
144148
145149 try :
@@ -187,6 +191,8 @@ async def __deserialize(
187191 return json_data ['data' ]
188192 else :
189193 return dacite .from_dict (data_class , json_data ['data' ])
194+ elif allow_null_body :
195+ return None
190196 else :
191197 raise SaicApiException (f"Failed to deserialize response, missing 'data' field: { response .text } " )
192198
0 commit comments