import requests


def post_to_hec(
    hec_uri: str, hec_token: str, index: str, data: dict
) -> requests.Response:
    """
    Upload data to selected index via HEC

    Args:
        hec_uri (str): HEC URI
        hec_token (str): HEC token
        index (str): Index to upload to
        data (dict): Data to upload

    Returns:
        requests.Response: HTTP response for uploading to Splunk via HEC
    """
    headers = {"Authorization": f"Splunk {hec_token}"}
    hec_json = {"sourcetype": "_json", "index": index, "event": data}

    return requests.post(hec_uri, json=hec_json, headers=headers, verify=False)