@@ -35,7 +35,7 @@ def process_resource(azion_resources: AzionResource, resource: Dict[str, Any]):
35
35
return []
36
36
37
37
# Extract edge_hostname and origin_hostname
38
- main_setting_name = global_settings .get ("attributes" , {}).get ("main_setting_name" , None )
38
+ main_setting_name = global_settings .get ("attributes" , {}).get ("main_setting_name" )
39
39
edge_hostname = global_settings .get ("attributes" , {}).get ("edge_hostname" , "" )
40
40
origin_hostname = global_settings .get ("attributes" , {}).get ("origin_hostname" , "" )
41
41
@@ -51,11 +51,13 @@ def process_resource(azion_resources: AzionResource, resource: Dict[str, Any]):
51
51
for instance_name , instance_data in resource_data .items ():
52
52
logging .info (f"Processing Akamai instance: { instance_name } " )
53
53
try :
54
- convert_akamai_to_azion (azion_resources ,
55
- instance_data ,
56
- main_setting_name ,
57
- edge_hostname ,
58
- origin_hostname )
54
+ convert_akamai_to_azion (
55
+ azion_resources ,
56
+ instance_data ,
57
+ main_setting_name ,
58
+ edge_hostname ,
59
+ origin_hostname
60
+ )
59
61
except KeyError as e :
60
62
logging .error (f"Missing expected key during processing of { instance_name } : { e } " )
61
63
except TypeError as e :
@@ -124,7 +126,14 @@ def process_rules(azion_resources: AzionResource, rules: Any, main_setting_name:
124
126
logging .info ("[Akamai Rules] Processing rules finished." )
125
127
126
128
127
- def process_rule_behaviors (azion_resources : AzionResource , rule : Dict [str , Any ], main_setting_name : str , origin_hostname : str , index : int , normalized_name : str ):
129
+ def process_rule_behaviors (
130
+ azion_resources : AzionResource ,
131
+ rule : Dict [str , Any ],
132
+ main_setting_name : str ,
133
+ origin_hostname : str ,
134
+ index : int ,
135
+ normalized_name : str
136
+ ):
128
137
"""
129
138
Processes the list of behaviors rules and converts them into Azion resources.
130
139
@@ -134,7 +143,7 @@ def process_rule_behaviors(azion_resources: AzionResource, rule: Dict[str, Any],
134
143
main_setting_name (str): The main setting name for Azion configuration.
135
144
origin_hostname (str): The origin hostname for Azion configuration.
136
145
"""
137
- behaviors = rule .get ("behaviors" , None )
146
+ behaviors = rule .get ("behaviors" )
138
147
if behaviors is None :
139
148
logging .warning ("[Akamai Rules] No behaviors found in rules. Skipping rule processing." )
140
149
return
@@ -183,7 +192,14 @@ def process_rule_behaviors(azion_resources: AzionResource, rule: Dict[str, Any],
183
192
logging .info (f"[Akamai Rules] Processing behaviors for rules '{ normalized_name } '. Finished." )
184
193
185
194
186
- def process_rule_children (azion_resources : AzionResource , children : List [Dict [str , Any ]], main_setting_name : str , origin_hostname : str , parent_rule_index : int , parent_rule_name : str ):
195
+ def process_rule_children (
196
+ azion_resources : AzionResource ,
197
+ children : List [Dict [str , Any ]],
198
+ main_setting_name : str ,
199
+ origin_hostname : str ,
200
+ parent_rule_index : int ,
201
+ parent_rule_name : str
202
+ ):
187
203
"""
188
204
Processes the list of children rules and converts them into Azion resources.
189
205
@@ -210,7 +226,12 @@ def process_rule_children(azion_resources: AzionResource, children: List[Dict[st
210
226
context ["rule_name" ] = rule_name
211
227
context ["rule_index" ] = child_index
212
228
213
- logging .info (f"[Akamai Rules][Children] Rule name: '{ rule_name } ', parent rule: '{ parent_rule_name } ', parent_index: { parent_rule_index } , index: { child_index } " )
229
+ logging .info (
230
+ f"[Akamai Rules][Children] Rule name: '{ rule_name } ', "
231
+ f"parent rule: '{ parent_rule_name } ', "
232
+ f"parent_index: { parent_rule_index } , "
233
+ f"index: { child_index } "
234
+ )
214
235
try :
215
236
behaviors = rule .get ("behaviors" , [])
216
237
for behavior in behaviors :
@@ -270,7 +291,12 @@ def process_rule_children(azion_resources: AzionResource, children: List[Dict[st
270
291
logging .info (f"[Akamai Rules][Children] Processing children rules from rule '{ parent_rule_name } '. Finished." )
271
292
272
293
273
- def create_main_resources (azion_resources : AzionResource , attributes : Dict [str , Any ], main_setting_name : str , origin_hostname : str ):
294
+ def create_main_resources (
295
+ azion_resources : AzionResource ,
296
+ attributes : Dict [str , Any ],
297
+ main_setting_name : str ,
298
+ origin_hostname : str
299
+ ):
274
300
"""
275
301
Creates the main setting, origin, and domain resources.
276
302
@@ -291,6 +317,7 @@ def create_main_resources(azion_resources: AzionResource, attributes: Dict[str,
291
317
logging .error (f"Error creating main resources: { e } " )
292
318
raise
293
319
320
+
294
321
def process_waf_behavior (azion_resources : AzionResource , attributes : Dict [str , Any ]):
295
322
"""
296
323
Adds WAF rule to Azion resources if available.
@@ -308,7 +335,13 @@ def process_waf_behavior(azion_resources: AzionResource, attributes: Dict[str, A
308
335
logging .error (f"Error processing WAF rule: { e } " )
309
336
310
337
311
- def convert_akamai_to_azion (azion_resources : AzionResource , attributes : Dict [str , Any ], main_setting_name : str , edge_hostname : str , origin_hostname : str ):
338
+ def convert_akamai_to_azion (
339
+ azion_resources : AzionResource ,
340
+ attributes : Dict [str , Any ],
341
+ main_setting_name : str ,
342
+ edge_hostname : str ,
343
+ origin_hostname : str
344
+ ):
312
345
"""
313
346
Converts Akamai property to Azion resources, including handling rules of different formats.
314
347
0 commit comments