def create_uri(user, target, port):
    """
    Create a valid URI from the provided parameters.
    """
    if user and port:
        return user + '@' + target + ':' + port
    elif user:
        return user + '@' + target
    elif port:
        return target + ':' + port
    else:
        return target
