from typing import Dict
from typing import Any


def get_user_choice(response: Dict[Any, Any]) -> str:
    """
    Simple utility function to display a list op options,
    and let the user pick one by using the index (displayed in front of it)
    :param response: Dict with the response recieved from the IXON api
    :return: str PublicID of chosen index
    """
    options = list()

    # Add them to a list
    for option in response['data']:
        options.append(option)

    # Display list
    for i in range(len(options)):
        option = options[i]
        public_id = option['publicId']
        name = option['name']
        print(f'{i}: {public_id}, {name}')

    # Make user pick one
    index: int = int(input('enter an index: '))  # will throw ValueError if not int, not a problem
    if not 0 <= index < len(options):
        raise ValueError(f'{index} is not a valid choice')
    return options[index]['publicId']