import requests


def get_instances_from_event_id(access_token, calendar_id, event_id):
    """Simple function to get instances of a recurring event from Google Calendar API

    Args:
        access_token (string): User's access token to make the request
        calendar_id (string): ID of the specific calendar that the event exists on
        event_id (string): ID of the recurring event to get the instances of

    Returns:
        Dict: Returns the normal response to the '/instances' endpoint as outlined in Google Cal API reference
    """
    # Headers for the request
    headers = {"Authorization": "Bearer " +
               access_token, "Accept": "application/json"}

    # Make the request
    response = requests.get("https://www.googleapis.com/calendar/v3/calendars/" +
                            calendar_id + "/events/" + event_id + "/instances", headers=headers)

    try:
        # Attempt to get JSON
        return response.json()
    except Exception as e:
        # Otherwise return an error occured with info + response
        return {"error": True, "message": e, "response": response}