in customizations/AccountFactory/EnrollAccount/enroll_account.py [0:0]
def list_all_accounts():
'''Return list of all accounts in the organization'''
output = list()
retry_count = 0
throttle_retry = True
while throttle_retry and retry_count < 5:
try:
org_paginator = ORG.get_paginator('list_accounts')
org_page_iterator = org_paginator.paginate()
throttle_retry = False
except ClientError as exe:
error_msg = str(exe.response['Error']['Code'])
if error_msg == 'ThrottlingException':
retry_count += 1
else:
error_and_exit('Failed to list accounts {}'.format(str(exe)))
for page in org_page_iterator:
output += page['Accounts']
return output