2323# from .client import Client
2424from ..module_utils .utils import PayloadMapper
2525from ..module_utils .utils import get_query
26+ from ..module_utils .utils import REST_API_VERSION
2627from .rest_client import RestClient
2728
2829
@@ -105,7 +106,7 @@ def get_by_uuid(
105106 must_exist : bool = False ,
106107 ) -> Optional [EmailAlert ]:
107108 query = get_query (ansible_dict , "uuid" , ansible_hypercore_map = dict (uuid = "uuid" ))
108- hypercore_dict = rest_client .get_record ("/rest/v1 /AlertEmailTarget" , query , must_exist = must_exist )
109+ hypercore_dict = rest_client .get_record (f" { REST_API_VERSION } /AlertEmailTarget" , query , must_exist = must_exist )
109110 alert_email_from_hypercore = cls .from_hypercore (hypercore_dict )
110111 return alert_email_from_hypercore
111112
@@ -121,7 +122,7 @@ def get_by_email(
121122 "email" ,
122123 ansible_hypercore_map = dict (email = "emailAddress" ),
123124 )
124- hypercore_dict = rest_client .get_record ("/rest/v1 /AlertEmailTarget" , query , must_exist = must_exist )
125+ hypercore_dict = rest_client .get_record (f" { REST_API_VERSION } /AlertEmailTarget" , query , must_exist = must_exist )
125126
126127 alert_email_from_hypercore = EmailAlert .from_hypercore (hypercore_dict )
127128 return alert_email_from_hypercore
@@ -137,7 +138,7 @@ def list_by_email(
137138 "email" ,
138139 ansible_hypercore_map = dict (email = "emailAddress" ),
139140 )
140- hypercore_dict_list = rest_client .list_records ("/rest/v1 /AlertEmailTarget" , query )
141+ hypercore_dict_list = rest_client .list_records (f" { REST_API_VERSION } /AlertEmailTarget" , query )
141142
142143 alert_email_from_hypercore_list = [EmailAlert .from_hypercore (hc_dict ) for hc_dict in hypercore_dict_list ]
143144 return alert_email_from_hypercore_list
@@ -149,7 +150,7 @@ def get_state(
149150 ):
150151 state = [
151152 EmailAlert .from_hypercore (hypercore_data = hypercore_dict ).to_ansible ()
152- for hypercore_dict in rest_client .list_records ("/rest/v1 /AlertEmailTarget/" )
153+ for hypercore_dict in rest_client .list_records (f" { REST_API_VERSION } /AlertEmailTarget/" )
153154 ]
154155
155156 return state
@@ -161,7 +162,7 @@ def create(
161162 payload : Dict [Any , Any ],
162163 check_mode : bool = False ,
163164 ):
164- task_tag = rest_client .create_record ("/rest/v1 /AlertEmailTarget/" , payload , check_mode )
165+ task_tag = rest_client .create_record (f" { REST_API_VERSION } /AlertEmailTarget/" , payload , check_mode )
165166 email_alert = cls .get_by_uuid (
166167 dict (uuid = task_tag ["createdUUID" ]),
167168 rest_client ,
@@ -175,18 +176,18 @@ def update(
175176 payload : Dict [Any , Any ],
176177 check_mode : bool = False ,
177178 ) -> None :
178- rest_client .update_record (f"/rest/v1 /AlertEmailTarget/{ self .uuid } " , payload , check_mode )
179+ rest_client .update_record (f"{ REST_API_VERSION } /AlertEmailTarget/{ self .uuid } " , payload , check_mode )
179180
180181 def delete (
181182 self ,
182183 rest_client : RestClient ,
183184 check_mode : bool = False ,
184185 ) -> None :
185- rest_client .delete_record (f"/rest/v1 /AlertEmailTarget/{ self .uuid } " , check_mode )
186+ rest_client .delete_record (f"{ REST_API_VERSION } /AlertEmailTarget/{ self .uuid } " , check_mode )
186187
187188 def test (
188189 self ,
189190 rest_client : RestClient ,
190191 ) -> TypedTaskTag :
191- response = rest_client .client .post (f"/rest/v1 /AlertEmailTarget/{ self .uuid } /test" , None )
192+ response = rest_client .client .post (f"{ REST_API_VERSION } /AlertEmailTarget/{ self .uuid } /test" , None )
192193 return response
0 commit comments