def set_user_permission(rid, uid, action='full'):
    """ Sets users permission on a given resource.  The resource will be created
        if it doesn't exist.  Actions are: read, write, update, delete, full.

        :param uid: user id
        :type uid: str
        :param rid: resource ID
        :type rid: str
        :param action: read, write, update, delete or full
        :type action: str
    """
    rid = rid.replace('/', '%252F')
    # Create ACL if it does not yet exist.
    ensure_resource(rid)

    # Set the permission triplet.
    try:
        acl_url = urljoin(_acl_url(), 'acls/{}/users/{}/{}'.format(rid, uid, action))
        r = http.put(acl_url)
        assert r.status_code == 204
    except DCOSHTTPException as e:
        if e.response.status_code != 409:
            raise