Update an existing user.

    userid
        Id of the user.

    login
        Optional - Login of the user.

    email
        Optional - Email of the user.

    name
        Optional - Full name of the user.

    orgid
        Optional - Default Organization of the user.

    profile
        Configuration profile used to connect to the Grafana instance.
        Default is 'grafana'.

    CLI Example:

    .. code-block:: bash

        salt '*' grafana4.update_user <user_id> login=<login> email=<email>

def update_user(userid, profile='grafana', orgid=None, **kwargs):
    '''
    Update an existing user.

    userid
        Id of the user.

    login
        Optional - Login of the user.

    email
        Optional - Email of the user.

    name
        Optional - Full name of the user.

    orgid
        Optional - Default Organization of the user.

    profile
        Configuration profile used to connect to the Grafana instance.
        Default is 'grafana'.

    CLI Example:

    .. code-block:: bash

        salt '*' grafana4.update_user <user_id> login=<login> email=<email>
    '''
    if isinstance(profile, string_types):
        profile = __salt__['config.option'](profile)
    response = requests.put(
        '{0}/api/users/{1}'.format(profile['grafana_url'], userid),
        json=kwargs,
        auth=_get_auth(profile),
        headers=_get_headers(profile),
        timeout=profile.get('grafana_timeout', 3),
    )
    if response.status_code >= 400:
        response.raise_for_status()
    if orgid:
        response2 = requests.post(
            '{0}/api/users/{1}/using/{2}'.format(profile['grafana_url'], userid, orgid),
            auth=_get_auth(profile),
            headers=_get_headers(profile),
            timeout=profile.get('grafana_timeout', 3),
        )
        if response2.status_code >= 400:
            response2.raise_for_status()
    return response.json()