1- from typing import AsyncIterator , Dict , Iterator , List , Literal , Optional , Union
1+ from typing import Any , AsyncIterator , Dict , Iterator , List , Literal , Optional , Union
22from uuid import UUID
33
44from asknews_sdk .api .base import BaseAPI
@@ -256,7 +256,10 @@ def get_autofilter(
256256 return FilterParamsResponse .model_validate (response .content )
257257
258258 def create_alert (
259- self , payload : CreateAlertRequest , * , http_headers : Optional [Dict ] = None
259+ self ,
260+ payload : Union [CreateAlertRequest , Dict [str , Any ]],
261+ * ,
262+ http_headers : Optional [Dict ] = None ,
260263 ) -> AlertResponse :
261264 """
262265 Create an alert.
@@ -273,7 +276,9 @@ def create_alert(
273276 response = self .client .request (
274277 method = "POST" ,
275278 endpoint = "/v1/chat/alerts" ,
276- body = payload .model_dump (mode = "json" ),
279+ body = payload .model_dump (mode = "json" )
280+ if isinstance (payload , CreateAlertRequest )
281+ else payload ,
277282 headers = {
278283 ** (http_headers or {}),
279284 "Content-Type" : CreateAlertRequest .__content_type__ ,
@@ -344,7 +349,7 @@ def list_alerts(
344349 def update_alert (
345350 self ,
346351 alert_id : Union [UUID , str ],
347- payload : UpdateAlertRequest ,
352+ payload : Union [ UpdateAlertRequest , Dict [ str , Any ]] ,
348353 * ,
349354 http_headers : Optional [Dict ] = None ,
350355 ) -> AlertResponse :
@@ -365,7 +370,9 @@ def update_alert(
365370 response = self .client .request (
366371 method = "PUT" ,
367372 endpoint = f"/v1/chat/alerts/{ alert_id } " ,
368- body = payload .model_dump (mode = "json" , exclude_unset = True , exclude_defaults = True ),
373+ body = payload .model_dump (mode = "json" , exclude_unset = True , exclude_defaults = True )
374+ if isinstance (payload , UpdateAlertRequest )
375+ else payload ,
369376 headers = {
370377 ** (http_headers or {}),
371378 "Content-Type" : UpdateAlertRequest .__content_type__ ,
@@ -641,7 +648,10 @@ async def get_autofilter(
641648 return FilterParamsResponse .model_validate (response .content )
642649
643650 async def create_alert (
644- self , payload : CreateAlertRequest , * , http_headers : Optional [Dict ] = None
651+ self ,
652+ payload : Union [CreateAlertRequest , Dict [str , Any ]],
653+ * ,
654+ http_headers : Optional [Dict ] = None ,
645655 ) -> AlertResponse :
646656 """
647657 Create an alert.
@@ -658,7 +668,9 @@ async def create_alert(
658668 response = await self .client .request (
659669 method = "POST" ,
660670 endpoint = "/v1/chat/alerts" ,
661- body = payload .model_dump (mode = "json" ),
671+ body = payload .model_dump (mode = "json" )
672+ if isinstance (payload , CreateAlertRequest )
673+ else payload ,
662674 headers = {
663675 ** (http_headers or {}),
664676 "Content-Type" : CreateAlertRequest .__content_type__ ,
@@ -729,7 +741,7 @@ async def list_alerts(
729741 async def update_alert (
730742 self ,
731743 alert_id : Union [UUID , str ],
732- payload : UpdateAlertRequest ,
744+ payload : Union [ UpdateAlertRequest , Dict [ str , Any ]] ,
733745 * ,
734746 http_headers : Optional [Dict ] = None ,
735747 ) -> AlertResponse :
@@ -750,7 +762,9 @@ async def update_alert(
750762 response = await self .client .request (
751763 method = "PUT" ,
752764 endpoint = f"/v1/chat/alerts/{ alert_id } " ,
753- body = payload .model_dump (mode = "json" , exclude_unset = True , exclude_defaults = True ),
765+ body = payload .model_dump (mode = "json" , exclude_unset = True , exclude_defaults = True )
766+ if isinstance (payload , UpdateAlertRequest )
767+ else payload ,
754768 headers = {
755769 ** (http_headers or {}),
756770 "Content-Type" : UpdateAlertRequest .__content_type__ ,
0 commit comments