@@ -36,7 +36,7 @@ def alert_rule_examples(j1):
3636 severity = "HIGH" ,
3737 j1ql = "FIND Database WITH encrypted = false"
3838 )
39- print (f"Created basic alert rule: { basic_rule ['rule' ][ '_id ' ]} \n " )
39+ print (f"Created basic alert rule: { basic_rule ['id ' ]} \n " )
4040
4141 # 2. Complex alert rule with multiple conditions
4242 print ("2. Creating a complex alert rule:" )
@@ -55,7 +55,7 @@ def alert_rule_examples(j1):
5555 AND u.tag.Role != 'admin'
5656 """
5757 )
58- print (f"Created complex alert rule: { complex_rule ['rule' ][ '_id ' ]} \n " )
58+ print (f"Created complex alert rule: { complex_rule ['id ' ]} \n " )
5959
6060 return basic_rule , complex_rule
6161
@@ -135,7 +135,7 @@ def alert_rule_with_actions_examples(j1):
135135 j1ql = "FIND Finding WITH severity = 'HIGH'" ,
136136 action_configs = webhook_action_config
137137 )
138- print (f"Created webhook alert rule: { webhook_rule ['rule' ][ '_id ' ]} \n " )
138+ print (f"Created webhook alert rule: { webhook_rule ['id ' ]} \n " )
139139
140140 # Create alert rule with multiple actions
141141 print ("2. Creating alert rule with multiple actions:" )
@@ -149,7 +149,7 @@ def alert_rule_with_actions_examples(j1):
149149 j1ql = "FIND Finding WITH severity = ('HIGH' OR 'CRITICAL')" ,
150150 action_configs = multiple_actions
151151 )
152- print (f"Created multi-action alert rule: { multi_action_rule ['rule' ][ '_id ' ]} \n " )
152+ print (f"Created multi-action alert rule: { multi_action_rule ['id ' ]} \n " )
153153
154154 return webhook_rule , multi_action_rule
155155
@@ -162,16 +162,16 @@ def alert_rule_management_examples(j1, rule_id):
162162 print ("1. Getting alert rule details:" )
163163 try :
164164 rule_details = j1 .get_alert_rule_details (rule_id = rule_id )
165- print (f"Rule: { rule_details ['rule' ][ ' name' ]} " )
166- print (f"Description: { rule_details ['rule' ][ ' description' ]} " )
167- print (f"J1QL: { rule_details [ 'rule' ][ 'j1ql' ] } " )
168- print (f"Severity: { rule_details [ 'rule' ][ 'severity' ] } " )
169- print (f"Polling Interval: { rule_details [ 'rule' ][ 'pollingInterval' ] } " )
165+ print (f"Rule: { rule_details ['name' ]} " )
166+ print (f"Description: { rule_details ['description' ]} " )
167+ print (f"J1QL: { rule_details . get ( 'j1ql' , 'N/A' ) } " )
168+ print (f"Severity: { rule_details . get ( 'severity' , 'N/A' ) } " )
169+ print (f"Polling Interval: { rule_details . get ( 'pollingInterval' , 'N/A' ) } " )
170170
171171 # Check action configurations
172- if 'actionConfigs' in rule_details [ 'rule' ] :
172+ if 'actionConfigs' in rule_details :
173173 print ("Action Configurations:" )
174- for action in rule_details ['rule' ][ ' actionConfigs' ]:
174+ for action in rule_details ['actionConfigs' ]:
175175 print (f" Type: { action ['type' ]} " )
176176 if action ['type' ] == 'WEBHOOK' :
177177 print (f" Endpoint: { action ['endpoint' ]} " )
@@ -208,7 +208,7 @@ def alert_rule_management_examples(j1, rule_id):
208208 tag_op = "OVERWRITE" ,
209209 severity = "INFO"
210210 )
211- print (f"Updated alert rule: { updated_rule ['rule' ][ '_id ' ]} " )
211+ print (f"Updated alert rule: { updated_rule ['id ' ]} " )
212212 except Exception as e :
213213 print (f"Error updating alert rule: { e } " )
214214 print ()
@@ -240,7 +240,7 @@ def smartclass_examples(j1):
240240 smartclass_name = 'ProductionServers' ,
241241 smartclass_description = 'All production servers across cloud providers'
242242 )
243- smartclass_id = smartclass ['smartclass' ][ '_id ' ]
243+ smartclass_id = smartclass ['id ' ]
244244 print (f"Created SmartClass: { smartclass_id } \n " )
245245
246246 # 2. Add queries to SmartClass
@@ -267,8 +267,8 @@ def smartclass_examples(j1):
267267 print ("3. Getting SmartClass details:" )
268268 try :
269269 smartclass_details = j1 .get_smartclass_details (smartclass_id = smartclass_id )
270- print (f"SmartClass: { smartclass_details ['smartclass' ][ 'name ' ]} " )
271- print (f"Description: { smartclass_details ['smartclass' ][ ' description' ]} " )
270+ print (f"SmartClass: { smartclass_details ['tagName ' ]} " )
271+ print (f"Description: { smartclass_details ['description' ]} " )
272272 print (f"Queries: { len (smartclass_details .get ('queries' , []))} " )
273273
274274 # List all queries in the SmartClass
@@ -410,7 +410,7 @@ def main():
410410 webhook_rule , multi_action_rule = alert_rule_with_actions_examples (j1 )
411411
412412 # Alert rule management (using the basic rule)
413- alert_rule_management_examples (j1 , basic_rule ['rule' ][ '_id ' ])
413+ alert_rule_management_examples (j1 , basic_rule ['id ' ])
414414
415415 # SmartClass examples
416416 smartclass_id = smartclass_examples (j1 )
@@ -419,7 +419,7 @@ def main():
419419 natural_language_to_j1ql_examples (j1 )
420420
421421 # Alert rule evaluation examples
422- alert_rule_evaluation_examples (j1 , basic_rule ['rule' ][ '_id ' ])
422+ alert_rule_evaluation_examples (j1 , basic_rule ['id ' ])
423423
424424 # Compliance framework examples
425425 compliance_framework_examples (j1 )
0 commit comments