def getorgid()

in radlab-launcher/radlab.py [0:0]


def getorgid():
    x = input("\nSet Org ID ?\n[1] Enter Manually\n[2] Select from the List\n[3] Skip setting Org ID\n" + Fore.YELLOW + Style.BRIGHT + "Choose a number for your choice" + Style.RESET_ALL + ': ').strip()

    if (x == '1'):
        orgid = input(Fore.YELLOW + Style.BRIGHT + "Enter the Org ID ( Example format - 1234567890 )" + Style.RESET_ALL + ': ').strip()
        return orgid

    elif (x == '2'):
        credentials = GoogleCredentials.get_application_default()
        service = discovery.build('cloudresourcemanager', 'v1beta1', credentials=credentials)

        request = service.organizations().list()
        response = request.execute()

        # pprint(response)

        print("\nList of Org ID you have access to: \n")
        org_ids = []
        # Print out Org IDs accounts
        for x in range(len(response['organizations'])):
            print("[" + str(x + 1) + "] " + response['organizations'][x]['organizationId'] + "    " + response['organizations'][x]['displayName'] + "    " + response['organizations'][x]['lifecycleState'])
            org_ids.append(response['organizations'][x]['organizationId'])

        # Take user input and get the corresponding item from the list
        inp = int(input(Fore.YELLOW + Style.BRIGHT + "Choose a number for Organization ID" + Style.RESET_ALL + ': '))
        if inp in range(1, len(org_ids) + 1):
            orgid = org_ids[inp - 1]
            # print(orgid)
            return orgid
        else:
            sys.exit(Fore.RED + "\nError Occured - INVALID ORG ID SELECTED\n" + Style.RESET_ALL)

    elif (x == '3'):
        print("Skipped setting Org ID...")
        return ''

    else:
        sys.exit(Fore.RED + "\nError Occured - INVALID CHOICE\n" + Style.RESET_ALL)