Update user role in the organization.

    userid
        Id of the user.

    loginOrEmail
        Login or email of the user.

    role
        Role of the user for this organization. Should be one of:
            - Admin
            - Editor
            - Read Only Editor
            - Viewer

    orgname
        Name of the organization in which users are updated.

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

    CLI Example:

    .. code-block:: bash

        salt '*' grafana4.update_org_user <user_id> <orgname> loginOrEmail=<loginOrEmail> role=<role>

def update_org_user(userid, orgname=None, profile='grafana', **kwargs):
    '''
    Update user role in the organization.

    userid
        Id of the user.

    loginOrEmail
        Login or email of the user.

    role
        Role of the user for this organization. Should be one of:
            - Admin
            - Editor
            - Read Only Editor
            - Viewer

    orgname
        Name of the organization in which users are updated.

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

    CLI Example:

    .. code-block:: bash

        salt '*' grafana4.update_org_user <user_id> <orgname> loginOrEmail=<loginOrEmail> role=<role>
    '''
    if isinstance(profile, string_types):
        profile = __salt__['config.option'](profile)
    if orgname:
        switch_org(orgname, profile)
    response = requests.patch(
        '{0}/api/org/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()
    return response.json()