1818from groundlight_openapi_client .api .edge_api import EdgeApi
1919from groundlight_openapi_client .api .notes_api import NotesApi
2020from groundlight_openapi_client import Action
21- from groundlight_openapi_client import ActionList
22- from groundlight_openapi_client import ActionRequest
2321from groundlight_openapi_client import BoundingBoxModeConfiguration
2422from groundlight_openapi_client import ChannelEnum
2523from groundlight_openapi_client import Condition
4139from groundlight .internalapi import _generate_request_id
4240from groundlight .optional_imports import Image , np
4341from groundlight .splint import ModeEnumSplint
42+ from groundlight_openapi_client .models .detector_creation_input_request_mode_configuration import DetectorCreationInputRequestModeConfiguration
4443
4544from .client import DEFAULT_REQUEST_TIMEOUT , Groundlight , GroundlightClientError , logger
4645
@@ -188,7 +187,7 @@ def create_alert( # pylint: disable=too-many-locals, too-many-arguments # noqa
188187 detector : Union [str , Detector ],
189188 name ,
190189 condition : Condition ,
191- actions : Optional [Union [Action , List [Action ], ActionList ]] = None ,
190+ actions : Optional [Union [Action , List [Action ]]] = None ,
192191 webhook_actions : Optional [Union [WebhookAction , List [WebhookAction ]]] = None ,
193192 * ,
194193 enabled : bool = True ,
@@ -248,16 +247,14 @@ def create_alert( # pylint: disable=too-many-locals, too-many-arguments # noqa
248247 """
249248 if isinstance (actions , Action ):
250249 actions = [actions ]
251- elif isinstance (actions , ActionList ):
252- actions = actions .root
253250 if isinstance (detector , Detector ):
254251 detector = detector .id
255252 if isinstance (webhook_actions , WebhookAction ):
256253 webhook_actions = [webhook_actions ]
257254 # translate pydantic type to the openapi type
258255 actions = (
259256 [
260- ActionRequest (
257+ Action (
261258 channel = ChannelEnum (action .channel ), recipient = action .recipient , include_image = action .include_image
262259 )
263260 for action in actions
@@ -296,7 +293,7 @@ def create_alert( # pylint: disable=too-many-locals, too-many-arguments # noqa
296293 human_review_required = human_review_required ,
297294 webhook_action = webhook_actions ,
298295 )
299- return Rule . model_validate ( self .actions_api .create_rule (detector , rule_input ). to_dict () )
296+ return self .actions_api .create_rule (detector , rule_input )
300297
301298 def create_rule ( # pylint: disable=too-many-locals # noqa: PLR0913
302299 self ,
@@ -384,7 +381,7 @@ def create_rule( # pylint: disable=too-many-locals # noqa: PLR0913
384381 channel = ChannelEnum (channel .upper ())
385382 if isinstance (condition_parameters , str ):
386383 condition_parameters = json .loads (condition_parameters ) # type: ignore
387- action = ActionRequest (
384+ action = Action (
388385 channel = channel , # type: ignore
389386 recipient = recipient ,
390387 include_image = include_image ,
@@ -402,7 +399,7 @@ def create_rule( # pylint: disable=too-many-locals # noqa: PLR0913
402399 snooze_time_unit = snooze_time_unit ,
403400 human_review_required = human_review_required ,
404401 )
405- return Rule . model_validate ( self .actions_api .create_rule (det_id , rule_input ). to_dict () )
402+ return self .actions_api .create_rule (det_id , rule_input )
406403
407404 def get_rule (self , action_id : int ) -> Rule :
408405 """
@@ -696,7 +693,7 @@ def create_bounding_box_detector( # noqa: PLR0913 # pylint: disable=too-many-ar
696693 else :
697694 mode_config = BoundingBoxModeConfiguration (max_num_bboxes = max_num_bboxes , class_name = class_name )
698695
699- detector_creation_input .mode_configuration = mode_config
696+ detector_creation_input .mode_configuration = DetectorCreationInputRequestModeConfiguration ( mode_config )
700697 obj = self .detectors_api .create_detector (detector_creation_input , _request_timeout = DEFAULT_REQUEST_TIMEOUT )
701698 return Detector .parse_obj (obj .to_dict ())
702699
@@ -750,7 +747,7 @@ def create_text_recognition_detector( # noqa: PLR0913 # pylint: disable=too-man
750747 detector_creation_input .mode = ModeEnumSplint .TEXT
751748 mode_config = TextModeConfiguration ()
752749
753- detector_creation_input .mode_configuration = mode_config
750+ detector_creation_input .mode_configuration = DetectorCreationInputRequestModeConfiguration ( mode_config )
754751 obj = self .detectors_api .create_detector (detector_creation_input , _request_timeout = DEFAULT_REQUEST_TIMEOUT )
755752 return Detector .parse_obj (obj .to_dict ())
756753
0 commit comments