@@ -63,7 +63,7 @@ def get_friendly_name(arn: str) -> str:
63
63
"""
64
64
last_colon_index = arn .rfind (":" )
65
65
66
- return arn [last_colon_index + 1 :].strip ().replace ("/" , "" ).replace ("-" , "" )
66
+ return arn [last_colon_index + 1 :].strip ().replace ("/" , "" ).replace ("-" , "" ) # noqa ECE001
67
67
68
68
69
69
def build_resources_by_account (account_session : boto3 .Session , params : dict , account_id : str ) -> None :
@@ -103,7 +103,7 @@ def get_resources_to_protect_in_account(account: str, resource_arns: list) -> li
103
103
104
104
105
105
def get_route_53_hosted_zones (account_session : boto3 .Session ) -> list :
106
- """Gets route53 hosted zones.
106
+ """Get route53 hosted zones.
107
107
108
108
Args:
109
109
account_session: session for the AWS account
@@ -207,7 +207,7 @@ def update_emergency_contacts(shield_client: ShieldClient, params: dict, is_dele
207
207
208
208
209
209
def check_if_key_in_object (key : str , obj : dict , var_type : str ) -> None :
210
- """Checks if key in object.
210
+ """Check if key in object.
211
211
212
212
Args:
213
213
key: key
@@ -335,7 +335,7 @@ def check_if_role_exists(iam_client: IAMClient, role_name: str) -> str:
335
335
role_name: Role name
336
336
337
337
Returns:
338
- bool: True if role exists, False otherwise
338
+ role arn or empty string
339
339
"""
340
340
try :
341
341
response = iam_client .get_role (RoleName = role_name )
@@ -345,7 +345,7 @@ def check_if_role_exists(iam_client: IAMClient, role_name: str) -> str:
345
345
346
346
347
347
def create_drt_role (account : str , role_name : str , account_session : boto3 .Session ) -> str :
348
- """Creates the IAM role used by the DRT.
348
+ """Create IAM role used by the DRT.
349
349
350
350
Args:
351
351
account: account id
@@ -422,7 +422,7 @@ def get_protection_id(shield_client: ShieldClient, arn: str) -> str:
422
422
423
423
424
424
def delete_protection (shield_client : ShieldClient , resource_arn : str ) -> None :
425
- """Deletes a protection.
425
+ """Delete a protection.
426
426
427
427
Args:
428
428
shield_client: Shield client
@@ -440,7 +440,7 @@ def delete_protection(shield_client: ShieldClient, resource_arn: str) -> None:
440
440
441
441
442
442
def associate_drt_log_bucket (shield_client : ShieldClient , log_bucket : str ) -> None :
443
- """Allows bucket access for DRT.
443
+ """Allow bucket access for DRT.
444
444
445
445
Args:
446
446
shield_client: shield client
@@ -519,7 +519,7 @@ def check_proactive_engagement_enabled(shield_client: ShieldClient, params: dict
519
519
520
520
521
521
def check_if_protection_group_exists (shield_client : ShieldClient , protection_group_id : str ) -> bool :
522
- """Checks if a protection group exist.
522
+ """Check if a protection group exist.
523
523
524
524
Args:
525
525
shield_client: shield client
@@ -570,7 +570,7 @@ def update_protection_group(
570
570
],
571
571
pg_members : str ,
572
572
) -> None :
573
- """Updates an existing protection group.
573
+ """Update an existing protection group.
574
574
575
575
Args:
576
576
shield_client: Shield client
@@ -595,7 +595,7 @@ def update_protection_group(
595
595
596
596
597
597
def create_protection_group (shield_client : ShieldClient , params : dict , account_id : str ) -> None :
598
- """Creates a protection group.
598
+ """Create a protection group.
599
599
600
600
Args:
601
601
shield_client: shield client
@@ -655,14 +655,14 @@ def check_emergency_contacts(shield_client: ShieldClient) -> bool:
655
655
LOGGER .info (api_call_details )
656
656
if "EmergencyContactList" in emergency_contacts_response and len (emergency_contacts_response ["EmergencyContactList" ]) > 0 :
657
657
return True
658
- else :
659
- return False
658
+
659
+ return False
660
660
except shield_client .exceptions .ResourceNotFoundException :
661
661
return False
662
662
663
663
664
664
def enable_proactive_engagement (shield_client : ShieldClient , params : dict ) -> None :
665
- """Enables the DRT team to reach out to the contacts
665
+ """Enable the DRT team to reach out to the contact.
666
666
667
667
Args:
668
668
shield_client: shield client
@@ -703,10 +703,13 @@ def associate_proactive_engagement_details(shield_client: ShieldClient, params:
703
703
704
704
705
705
def disable_proactive_engagement (shield_client : ShieldClient ) -> None :
706
- """disallow the DRT to use the contact details
706
+ """Disable the DRT to use the contact details.
707
707
708
708
Args:
709
- shield_client: shield client
709
+ shield_client: Shield client
710
+
711
+ Raises:
712
+ e: Client error
710
713
"""
711
714
try :
712
715
disable_proactive_engagement_response = shield_client .disable_proactive_engagement ()
@@ -716,4 +719,4 @@ def disable_proactive_engagement(shield_client: ShieldClient) -> None:
716
719
if e .response ["Error" ]["Code" ] == "InvalidOperationException" :
717
720
LOGGER .exception (e )
718
721
else :
719
- raise e
722
+ raise
0 commit comments