Given an email address, creates a notification-channels
    if one is not found and also returns the corresponding
    notification channel id.

    notify_channel
        Email escalation policy
    profile
        A dict of telemetry config information.

    CLI Example:

        salt myminion telemetry.get_notification_channel_id userx@company.com profile=telemetry

def get_notification_channel_id(notify_channel, profile="telemetry"):
    '''
    Given an email address, creates a notification-channels
    if one is not found and also returns the corresponding
    notification channel id.

    notify_channel
        Email escalation policy
    profile
        A dict of telemetry config information.

    CLI Example:

        salt myminion telemetry.get_notification_channel_id userx@company.com profile=telemetry
    '''

    # This helper is used to procure the channel ids
    # used to notify when the alarm threshold is violated
    auth = _auth(profile=profile)

    notification_channel_id = _retrieve_channel_id(notify_channel)

    if not notification_channel_id:
        log.info("%s channel does not exist, creating.", notify_channel)

        # create the notification channel and cache the id
        post_url = _get_telemetry_base(profile) + "/notification-channels"
        data = {
            "_type": "EmailNotificationChannel",
            "name":  notify_channel[:notify_channel.find('@')] + 'EscalationPolicy',
            "email": notify_channel
        }
        response = requests.post(post_url, data=salt.utils.json.dumps(data), headers=auth)
        if response.status_code == 200:
            log.info("Successfully created EscalationPolicy %s with EmailNotificationChannel %s",
                     data.get('name'), notify_channel)
            notification_channel_id = response.json().get('_id')
            __context__["telemetry.channels"][notify_channel] = notification_channel_id
        else:
            raise Exception("Failed to created notification channel {0}".format(notify_channel))

    return notification_channel_id