-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_components.py
80 lines (57 loc) · 2.41 KB
/
create_components.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
def create_variables(client, variables):
"""
https://docs.aws.amazon.com/frauddetector/latest/ug/create-a-variable.html
"""
for variable in variables:
client.create_variable(name=variable["name"],
variableType=variable["type"],
dataSource=variable["source"],
dataType=variable["data_type"],
defaultValue=variable["default"])
print("Variables are created!")
def create_entity_type(client, entity_type_name, entity_type_description):
"""
https://docs.aws.amazon.com/frauddetector/latest/ug/create-an-entity-type.html
"""
client.put_entity_type(name=entity_type_name,
description=entity_type_description)
print("Entity type is created!")
def create_label(client, labels):
"""
https://docs.aws.amazon.com/frauddetector/latest/ug/create-a-label.html
"""
for label in labels:
client.put_label(name=label["name"],
description=label["description"])
print("Labels are created!")
def create_event_type(client, event_type_name, variables, labels, entity_type_name):
"""
https://docs.aws.amazon.com/frauddetector/latest/ug/create-event-type.html
"""
var_names = [variable["name"] for variable in variables]
label_names = [label["name"] for label in labels]
client.put_event_type(name=event_type_name,
eventVariables=var_names,
labels=label_names,
entityTypes=[entity_type_name])
print("Event type is created!")
def create_rules(client, rules, detector_id):
"""
https://docs.aws.amazon.com/frauddetector/latest/ug/create-a-rule.html
"""
for rule in rules:
client.create_rule(ruleId=rule["name"],
detectorId=detector_id,
expression=rule["expression"],
language='DETECTORPL',
outcomes=[rule["outcome"]])
print("Rules are created")
def create_outcomes(client, outcomes):
"""
https://docs.aws.amazon.com/frauddetector/latest/ug/create-an-outcome.html
"""
for outcome in outcomes:
client.put_outcome(name=outcome["name"],
description=outcome["description"])
print("Outcomes are created!")
# TODO: Add comments