in createCustomStandard.py [0:0]
def list_controls(controlType: str = None, region_name=None) -> dict:
auditmanager_client = boto3.client('auditmanager', region_name=region_name)
existing_controls = auditmanager_client.list_controls(controlType="Custom")
nextToken = existing_controls.get('nextToken', None)
while nextToken is not None:
next_existing_controls = auditmanager_client.list_controls(
controlType="Custom",
nextToken=nextToken
)
# Adding each control in the new list of controls to the existing list
for item in next_existing_controls["controlMetadataList"]:
existing_controls["controlMetadataList"].append(item)
# Checking if there is a token in the new list of controls
if "nextToken" in next_existing_controls:
nextToken = next_existing_controls["nextToken"]
else:
nextToken = None
logging.debug(existing_controls)
return existing_controls