53
53
PARAMETER ,
54
54
PARAMETER_LIST ,
55
55
UPSERT_PARAMETER ,
56
+ UPDATE_ENTITYV2 ,
56
57
)
57
58
58
59
class JupiterOneClient :
@@ -1070,7 +1071,9 @@ def create_alert_rule(
1070
1071
1071
1072
def delete_alert_rule (self , rule_id : str = None ):
1072
1073
"""Delete a single Alert Rule configured in J1 account"""
1073
- variables = {"id" : rule_id }
1074
+ variables = {
1075
+ "id" : rule_id
1076
+ }
1074
1077
1075
1078
response = self ._execute_query (DELETE_RULE_INSTANCE , variables = variables )
1076
1079
@@ -1195,7 +1198,9 @@ def update_alert_rule(
1195
1198
1196
1199
def evaluate_alert_rule (self , rule_id : str = None ):
1197
1200
"""Run an Evaluation for a defined Alert Rule configured in J1 account"""
1198
- variables = {"id" : rule_id }
1201
+ variables = {
1202
+ "id" : rule_id
1203
+ }
1199
1204
1200
1205
response = self ._execute_query (EVALUATE_RULE_INSTANCE , variables = variables )
1201
1206
return response
@@ -1215,7 +1220,9 @@ def list_alert_rule_evaluation_results(self, rule_id: str = None):
1215
1220
1216
1221
def fetch_evaluation_result_download_url (self , raw_data_key : str = None ):
1217
1222
"""Fetch evaluation result Download URL for Alert Rule configured in J1 account"""
1218
- variables = {"rawDataKey" : raw_data_key }
1223
+ variables = {
1224
+ "rawDataKey" : raw_data_key
1225
+ }
1219
1226
1220
1227
response = self ._execute_query (GET_RAW_DATA_DOWNLOAD_URL , variables = variables )
1221
1228
return response
@@ -1236,7 +1243,12 @@ def list_questions(self):
1236
1243
"""List all defined Questions configured in J1 account Questions Library"""
1237
1244
results = []
1238
1245
1239
- data = {"query" : QUESTIONS , "flags" : {"variableResultSize" : True }}
1246
+ data = {
1247
+ "query" : QUESTIONS ,
1248
+ "flags" : {
1249
+ "variableResultSize" : True
1250
+ }
1251
+ }
1240
1252
1241
1253
r = requests .post (
1242
1254
url = self .graphql_url , headers = self .headers , json = data , verify = True
@@ -1270,7 +1282,9 @@ def get_compliance_framework_item_details(self, item_id: str = None):
1270
1282
1271
1283
def get_parameter_details (self , name : str = None ):
1272
1284
"""Fetch Details of a configured Parameter in J1 account"""
1273
- variables = {"name" : name }
1285
+ variables = {
1286
+ "name" : name
1287
+ }
1274
1288
1275
1289
response = self ._execute_query (PARAMETER , variables = variables )
1276
1290
return response
@@ -1310,7 +1324,28 @@ def create_update_parameter(
1310
1324
secret : bool = False ,
1311
1325
):
1312
1326
"""Create or Update Account Parameter in J1 account"""
1313
- variables = {"name" : name , "value" : value , "secret" : secret }
1327
+ variables = {
1328
+ "name" : name ,
1329
+ "value" : value ,
1330
+ "secret" : secret
1331
+ }
1314
1332
1315
1333
response = self ._execute_query (UPSERT_PARAMETER , variables = variables )
1316
1334
return response
1335
+
1336
+ def update_entity_v2 (self , entity_id : str = None , properties : Dict = None ) -> Dict :
1337
+ """
1338
+ Update an existing entity by adding new or updating existing properties.
1339
+
1340
+ args:
1341
+ entity_id (str): The _id of the entity to update
1342
+ properties (dict): Dictionary of key/value entity properties
1343
+ """
1344
+ properties ['_id' ] = entity_id
1345
+
1346
+ variables = {
1347
+ "entity" : properties ,
1348
+ }
1349
+
1350
+ response = self ._execute_query (UPDATE_ENTITYV2 , variables = variables )
1351
+ return response ["data" ]["updateEntityV2" ]
0 commit comments