@@ -61,6 +61,7 @@ def custom_sql_creator(
6161 ) -> alpha_DQRule :
6262 validate_required_fields (
6363 [
64+ "client" ,
6465 "rule_name" ,
6566 "asset" ,
6667 "threshold_compare_operator" ,
@@ -70,6 +71,7 @@ def custom_sql_creator(
7071 "custom_sql" ,
7172 ],
7273 [
74+ client ,
7375 rule_name ,
7476 asset ,
7577 threshold_compare_operator ,
@@ -110,13 +112,15 @@ def table_level_rule_creator(
110112 ) -> alpha_DQRule :
111113 validate_required_fields (
112114 [
115+ "client" ,
113116 "rule_type" ,
114117 "asset" ,
115118 "threshold_compare_operator" ,
116119 "threshold_value" ,
117120 "alert_priority" ,
118121 ],
119122 [
123+ client ,
120124 rule_type ,
121125 asset ,
122126 threshold_compare_operator ,
@@ -159,6 +163,7 @@ def column_level_rule_creator(
159163 ) -> alpha_DQRule :
160164 validate_required_fields (
161165 [
166+ "client" ,
162167 "rule_type" ,
163168 "asset" ,
164169 "column" ,
@@ -167,6 +172,7 @@ def column_level_rule_creator(
167172 "alert_priority" ,
168173 ],
169174 [
175+ client ,
170176 rule_type ,
171177 asset ,
172178 column ,
@@ -212,8 +218,8 @@ def updater(
212218 from pyatlan .model .fluent_search import FluentSearch
213219
214220 validate_required_fields (
215- ["qualified_name" ],
216- [qualified_name ],
221+ ["client" , " qualified_name" ],
222+ [client , qualified_name ],
217223 )
218224 request = (
219225 FluentSearch ()
@@ -235,6 +241,11 @@ def updater(
235241
236242 results = client .asset .search (request )
237243
244+ if results .count != 1 :
245+ raise ValueError (
246+ f"Expected exactly 1 asset for qualified_name: { qualified_name } , "
247+ f"but found: { results .count } "
248+ )
238249 search_result = results .current_page ()[0 ]
239250
240251 retrieved_custom_sql = search_result .alpha_dq_rule_custom_s_q_l # type: ignore[attr-defined]
@@ -246,9 +257,27 @@ def updater(
246257 retrieved_asset = search_result .alpha_dq_rule_base_dataset # type: ignore[attr-defined]
247258 retrieved_template_rule_name = search_result .alpha_dq_rule_template_name # type: ignore[attr-defined]
248259 retrieved_template = search_result .alpha_dq_rule_template # type: ignore[attr-defined]
249- retrieved_threshold_compare_operator = search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object .alpha_dq_rule_threshold_compare_operator # type: ignore[attr-defined]
250- retrieved_threshold_value = search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object .alpha_dq_rule_threshold_value # type: ignore[attr-defined]
251- retrieved_threshold_unit = search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object .alpha_dq_rule_threshold_unit # type: ignore[attr-defined]
260+ retrieved_threshold_compare_operator = (
261+ search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object .alpha_dq_rule_threshold_compare_operator # type: ignore[attr-defined]
262+ if search_result .alpha_dq_rule_config_arguments is not None # type: ignore[attr-defined]
263+ and search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object # type: ignore[attr-defined]
264+ is not None
265+ else None
266+ )
267+ retrieved_threshold_value = (
268+ search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object .alpha_dq_rule_threshold_value # type: ignore[attr-defined]
269+ if search_result .alpha_dq_rule_config_arguments is not None # type: ignore[attr-defined]
270+ and search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object # type: ignore[attr-defined]
271+ is not None
272+ else None
273+ ) # type: ignore[attr-defined]
274+ retrieved_threshold_unit = (
275+ search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object .alpha_dq_rule_threshold_unit # type: ignore[attr-defined]
276+ if search_result .alpha_dq_rule_config_arguments is not None # type: ignore[attr-defined]
277+ and search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object # type: ignore[attr-defined]
278+ is not None
279+ else None
280+ ) # type: ignore[attr-defined]
252281
253282 config_arguments_raw = alpha_DQRule .Attributes ._generate_config_arguments_raw (
254283 is_alert_enabled = True ,
@@ -1053,30 +1082,32 @@ def creator(
10531082 custom_sql : Optional [str ] = None ,
10541083 description : Optional [str ] = None ,
10551084 ) -> alpha_DQRule .Attributes :
1056- template_config = client .template_config_cache .get_template_config (
1085+ template_config = client .dq_template_config_cache .get_template_config (
10571086 rule_type
10581087 )
10591088
10601089 if template_config is None :
10611090 raise ErrorCode .DQ_RULE_NOT_FOUND .exception_with_parameters (rule_type )
10621091
1063- template_rule_name = template_config [ "name" ]
1064- template_qualified_name = template_config [ "qualified_name" ]
1092+ template_rule_name = template_config . get ( "name" )
1093+ template_qualified_name = template_config . get ( "qualified_name" )
10651094
10661095 if dimension is None :
1067- dimension = template_config [ "dimension" ]
1096+ dimension = template_config . get ( "dimension" )
10681097
10691098 if threshold_unit is None :
1070- threashold_object = template_config [
1071- "config"
1072- ].alpha_dq_rule_template_config_threshold_object
1073- threashold_object_json = json .loads (threashold_object )
1074- properties = threashold_object_json .get ("properties" , {})
1075- threshold_unit_field = properties .get (
1076- "alpha_dqRuleTemplateConfigThresholdUnit" , {}
1077- )
1078- default_value = threshold_unit_field .get ("default" )
1079- threshold_unit = default_value
1099+ config = template_config .get ("config" )
1100+ if config is not None :
1101+ threashold_object = (
1102+ config .alpha_dq_rule_template_config_threshold_object
1103+ )
1104+ threashold_object_json = json .loads (threashold_object )
1105+ properties = threashold_object_json .get ("properties" , {})
1106+ threshold_unit_field = properties .get (
1107+ "alpha_dqRuleTemplateConfigThresholdUnit" , {}
1108+ )
1109+ default_value = threshold_unit_field .get ("default" )
1110+ threshold_unit = default_value
10801111
10811112 config_arguments_raw = (
10821113 alpha_DQRule .Attributes ._generate_config_arguments_raw (
@@ -1112,7 +1143,7 @@ def creator(
11121143 alpha_dq_rule_dimension = dimension ,
11131144 alpha_dq_rule_template_name = template_rule_name ,
11141145 alpha_dq_rule_template = alpha_DQRuleTemplate .ref_by_qualified_name (
1115- qualified_name = template_qualified_name
1146+ qualified_name = template_qualified_name # type: ignore
11161147 ),
11171148 )
11181149
0 commit comments