55 load_username_description ,
66 get_user_id ,
77 update_user ,
8- handle_bad_request_during_add ,
8+ try_handle_user_already_added_error ,
9+ try_add_risk_tags ,
10+ try_remove_risk_tags ,
911)
10- from code42cli .cmds .detectionlists .enums import DetectionLists
11- from code42cli .cmds .detectionlists .enums import DetectionListUserKeys
12+ from code42cli .cmds .detectionlists .enums import DetectionLists , DetectionListUserKeys , RiskTags
1213from code42cli .commands import Command
1314
1415from py42 .exceptions import Py42BadRequestError
1516
1617
1718def load_subcommands ():
18-
1919 handlers = _create_handlers ()
2020 detection_list = DetectionList .create_high_risk_employee_list (handlers )
2121 cmd_list = detection_list .load_subcommands ()
@@ -47,13 +47,13 @@ def _create_handlers():
4747def add_risk_tags (sdk , profile , username , risk_tag ):
4848 risk_tag = _handle_list_args (risk_tag )
4949 user_id = get_user_id (sdk , username )
50- sdk . detectionlists . add_user_risk_tags ( user_id , risk_tag )
50+ try_add_risk_tags ( sdk , user_id , risk_tag )
5151
5252
5353def remove_risk_tags (sdk , profile , username , risk_tag ):
5454 risk_tag = _handle_list_args (risk_tag )
5555 user_id = get_user_id (sdk , username )
56- sdk . detectionlists . remove_user_risk_tags ( user_id , risk_tag )
56+ try_remove_risk_tags ( sdk , user_id , risk_tag )
5757
5858
5959def add_high_risk_employee (sdk , profile , username , cloud_alias = None , risk_tag = None , notes = None ):
@@ -74,8 +74,9 @@ def add_high_risk_employee(sdk, profile, username, cloud_alias=None, risk_tag=No
7474 sdk .detectionlists .high_risk_employee .add (user_id )
7575 update_user (sdk , user_id , cloud_alias , risk_tag , notes )
7676 except Py42BadRequestError as err :
77- if not handle_bad_request_during_add (err , username , DetectionLists .HIGH_RISK_EMPLOYEE ):
78- raise
77+ list_name = DetectionLists .HIGH_RISK_EMPLOYEE
78+ try_handle_user_already_added_error (err , username , list_name )
79+ raise
7980
8081
8182def remove_high_risk_employee (sdk , profile , username ):
@@ -93,16 +94,9 @@ def remove_high_risk_employee(sdk, profile, username):
9394def _load_risk_tag_description (argument_collection ):
9495 risk_tag = argument_collection .arg_configs [DetectionListUserKeys .RISK_TAG ]
9596 risk_tag .as_multi_val_param ()
97+ tags = u", " .join (list (RiskTags ()))
9698 risk_tag .set_help (
97- u"Risk tags associated with the employee. "
98- u"Options include "
99- u"[HIGH_IMPACT_EMPLOYEE, "
100- u"ELEVATED_ACCESS_PRIVILEGES, "
101- u"PERFORMANCE_CONCERNS, "
102- u"FLIGHT_RISK, "
103- u"SUSPICIOUS_SYSTEM_ACTIVITY, "
104- u"POOR_SECURITY_PRACTICES, "
105- u"CONTRACT_EMPLOYEE]"
99+ u"Risk tags associated with the employee. Options include: [{}]." .format (tags )
106100 )
107101
108102
0 commit comments