@@ -63,7 +63,7 @@ def get_friendly_name(arn: str) -> str:
6363 """
6464 last_colon_index = arn .rfind (":" )
6565
66- return arn [last_colon_index + 1 :].strip ().replace ("/" , "" ).replace ("-" , "" )
66+ return arn [last_colon_index + 1 :].strip ().replace ("/" , "" ).replace ("-" , "" ) # noqa ECE001
6767
6868
6969def 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
103103
104104
105105def get_route_53_hosted_zones (account_session : boto3 .Session ) -> list :
106- """Gets route53 hosted zones.
106+ """Get route53 hosted zones.
107107
108108 Args:
109109 account_session: session for the AWS account
@@ -207,7 +207,7 @@ def update_emergency_contacts(shield_client: ShieldClient, params: dict, is_dele
207207
208208
209209def 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.
211211
212212 Args:
213213 key: key
@@ -335,7 +335,7 @@ def check_if_role_exists(iam_client: IAMClient, role_name: str) -> str:
335335 role_name: Role name
336336
337337 Returns:
338- bool: True if role exists, False otherwise
338+ role arn or empty string
339339 """
340340 try :
341341 response = iam_client .get_role (RoleName = role_name )
@@ -345,7 +345,7 @@ def check_if_role_exists(iam_client: IAMClient, role_name: str) -> str:
345345
346346
347347def 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.
349349
350350 Args:
351351 account: account id
@@ -422,7 +422,7 @@ def get_protection_id(shield_client: ShieldClient, arn: str) -> str:
422422
423423
424424def delete_protection (shield_client : ShieldClient , resource_arn : str ) -> None :
425- """Deletes a protection.
425+ """Delete a protection.
426426
427427 Args:
428428 shield_client: Shield client
@@ -440,7 +440,7 @@ def delete_protection(shield_client: ShieldClient, resource_arn: str) -> None:
440440
441441
442442def associate_drt_log_bucket (shield_client : ShieldClient , log_bucket : str ) -> None :
443- """Allows bucket access for DRT.
443+ """Allow bucket access for DRT.
444444
445445 Args:
446446 shield_client: shield client
@@ -519,7 +519,7 @@ def check_proactive_engagement_enabled(shield_client: ShieldClient, params: dict
519519
520520
521521def 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.
523523
524524 Args:
525525 shield_client: shield client
@@ -570,7 +570,7 @@ def update_protection_group(
570570 ],
571571 pg_members : str ,
572572) -> None :
573- """Updates an existing protection group.
573+ """Update an existing protection group.
574574
575575 Args:
576576 shield_client: Shield client
@@ -595,7 +595,7 @@ def update_protection_group(
595595
596596
597597def create_protection_group (shield_client : ShieldClient , params : dict , account_id : str ) -> None :
598- """Creates a protection group.
598+ """Create a protection group.
599599
600600 Args:
601601 shield_client: shield client
@@ -655,14 +655,14 @@ def check_emergency_contacts(shield_client: ShieldClient) -> bool:
655655 LOGGER .info (api_call_details )
656656 if "EmergencyContactList" in emergency_contacts_response and len (emergency_contacts_response ["EmergencyContactList" ]) > 0 :
657657 return True
658- else :
659- return False
658+
659+ return False
660660 except shield_client .exceptions .ResourceNotFoundException :
661661 return False
662662
663663
664664def 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.
666666
667667 Args:
668668 shield_client: shield client
@@ -703,10 +703,13 @@ def associate_proactive_engagement_details(shield_client: ShieldClient, params:
703703
704704
705705def 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.
707707
708708 Args:
709- shield_client: shield client
709+ shield_client: Shield client
710+
711+ Raises:
712+ e: Client error
710713 """
711714 try :
712715 disable_proactive_engagement_response = shield_client .disable_proactive_engagement ()
@@ -716,4 +719,4 @@ def disable_proactive_engagement(shield_client: ShieldClient) -> None:
716719 if e .response ["Error" ]["Code" ] == "InvalidOperationException" :
717720 LOGGER .exception (e )
718721 else :
719- raise e
722+ raise
0 commit comments