def list_all_accounts()

in customizations/AccountFactory/BatchUpdate/update_pp.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 Exception as exe:
            error_msg = exe.response['Error']['Code']
            if error_msg == 'ThrottlingException':
                retry_count += 1
            else:
                error_and_exit('Failed to get list of accounts {}'.format(str(exe)))

    for page in org_page_iterator:
        output += page['Accounts']

    return output