| 
2 | 2 | import random  | 
3 | 3 | import time  | 
4 | 4 | import os  | 
 | 5 | +import json  | 
5 | 6 | 
 
  | 
6 | 7 | account = os.environ.get("JUPITERONE_ACCOUNT")  | 
7 | 8 | token = os.environ.get("JUPITERONE_TOKEN")  | 
 | 
332 | 333 |             ]  | 
333 | 334 | }  | 
334 | 335 | 
 
  | 
 | 336 | +create_jira_ticket_action_config = {  | 
 | 337 | +          "integrationInstanceId" : "<GUID>",  | 
 | 338 | +          "type" : "CREATE_JIRA_TICKET",  | 
 | 339 | +          "entityClass" : "Record",  | 
 | 340 | +          "summary" : "Jira Task created via JupiterOne Alert Rule",  | 
 | 341 | +          "issueType" : "Task",  | 
 | 342 | +          "project" : "KEY",  | 
 | 343 | +          "additionalFields" : {  | 
 | 344 | +            "description" : {  | 
 | 345 | +              "type" : "doc",  | 
 | 346 | +              "version" : 1,  | 
 | 347 | +              "content" : [  | 
 | 348 | +                {  | 
 | 349 | +                  "type" : "paragraph",  | 
 | 350 | +                  "content" : [  | 
 | 351 | +                    {  | 
 | 352 | +                      "type" : "text",  | 
 | 353 | +                      "text" : "{{alertWebLink}}\n\n**Affected Items:**\n\n* {{queries.query0.data|mapProperty('displayName')|join('\n* ')}}"  | 
 | 354 | +                    }  | 
 | 355 | +                  ]  | 
 | 356 | +                }  | 
 | 357 | +              ]  | 
 | 358 | +            },  | 
 | 359 | +            "customfield_1234": "text-value",  | 
 | 360 | +            "customfield_5678": {  | 
 | 361 | +                "value": "select-value"  | 
 | 362 | +            },  | 
 | 363 | +            "labels" : [  | 
 | 364 | +              "label1","label2"  | 
 | 365 | +            ],  | 
 | 366 | +          }  | 
 | 367 | +}  | 
 | 368 | + | 
 | 369 | +alert_rule_labels = [  | 
 | 370 | +    {  | 
 | 371 | +        "labelName": "tagkey1",  | 
 | 372 | +        "labelValue": "tagval"  | 
 | 373 | +    },  | 
 | 374 | +    {  | 
 | 375 | +        "labelName": "tagkey2",  | 
 | 376 | +        "labelValue": "tagval"  | 
 | 377 | +    }  | 
 | 378 | +]  | 
 | 379 | + | 
 | 380 | +resource_group_id = "<GUID>"  | 
 | 381 | + | 
335 | 382 | create_alert_rule_r = j1.create_alert_rule(name="create_alert_rule-name",  | 
336 | 383 |                                            description="create_alert_rule-description",  | 
337 | 384 |                                            tags=['tag1', 'tag2'],  | 
 | 385 | +                                           labels=alert_rule_labels,  | 
338 | 386 |                                            polling_interval="DISABLED",  | 
339 | 387 |                                            severity="INFO",  | 
340 |  | -                                           j1ql="find jupiterone_user")  | 
 | 388 | +                                           j1ql="find jupiterone_user",  | 
 | 389 | +                                           action_configs=create_jira_ticket_action_config,  | 
 | 390 | +                                           resource_group_id=resource_group_id)  | 
341 | 391 | print("create_alert_rule()")  | 
342 | 392 | print(create_alert_rule_r)  | 
343 | 393 | 
 
  | 
 | 
380 | 430 |     }  | 
381 | 431 | ]  | 
382 | 432 | 
 
  | 
 | 433 | +alert_rule_config_jira = [  | 
 | 434 | +    {  | 
 | 435 | +          "integrationInstanceId" : "<GUID>",  | 
 | 436 | +          "type" : "CREATE_JIRA_TICKET",  | 
 | 437 | +          "entityClass" : "Record",  | 
 | 438 | +          "summary" : "Jira Task created via JupiterOne Alert Rule",  | 
 | 439 | +          "issueType" : "Task",  | 
 | 440 | +          "project" : "KEY",  | 
 | 441 | +          "additionalFields" : {  | 
 | 442 | +            "description" : {  | 
 | 443 | +              "type" : "doc",  | 
 | 444 | +              "version" : 1,  | 
 | 445 | +              "content" : [  | 
 | 446 | +                {  | 
 | 447 | +                  "type" : "paragraph",  | 
 | 448 | +                  "content" : [  | 
 | 449 | +                    {  | 
 | 450 | +                      "type" : "text",  | 
 | 451 | +                      "text" : "{{alertWebLink}}\n\n**Affected Items:**\n\n* {{queries.query0.data|mapProperty('displayName')|join('\n* ')}}"  | 
 | 452 | +                    }  | 
 | 453 | +                  ]  | 
 | 454 | +                }  | 
 | 455 | +              ]  | 
 | 456 | +            },  | 
 | 457 | +            "customfield_1234": "text-value",  | 
 | 458 | +            "customfield_5678": {  | 
 | 459 | +                "value": "select-value"  | 
 | 460 | +            },  | 
 | 461 | +            "labels" : [  | 
 | 462 | +              "label1","label2"  | 
 | 463 | +            ],  | 
 | 464 | +          }  | 
 | 465 | +    }  | 
 | 466 | +]  | 
 | 467 | + | 
383 | 468 | alert_rule_config_multiple = [  | 
384 | 469 |     {  | 
385 | 470 |         "type": "WEBHOOK",  | 
 | 
404 | 489 |     }  | 
405 | 490 | ]  | 
406 | 491 | 
 
  | 
 | 492 | +alert_rule_labels = [  | 
 | 493 | +    {  | 
 | 494 | +        "labelName": "tagkey1",  | 
 | 495 | +        "labelValue": "tagval"  | 
 | 496 | +    },  | 
 | 497 | +    {  | 
 | 498 | +        "labelName": "tagkey2",  | 
 | 499 | +        "labelValue": "tagval"  | 
 | 500 | +    }  | 
 | 501 | +]  | 
 | 502 | + | 
 | 503 | +resource_group_id = "<GUID>"  | 
 | 504 | + | 
407 | 505 | # polling_interval can be DISABLED, THIRTY_MINUTES, ONE_HOUR, FOUR_HOURS, EIGHT_HOURS, TWELVE_HOURS, ONE_DAY, or ONE_WEEK  | 
408 | 506 | # tag_op can be OVERWRITE or APPEND  | 
409 | 507 | # severity can be INFO, LOW, MEDIUM, HIGH, or CRITICAL  | 
 | 
0 commit comments