def container_absent(api, container):
    """
    Ensure a container is absent.

    Container is an :class:`~lxdapi.api.APIResult` for the container, to be
    able to compare the configuration with.

    It is expected that the user manages the HTTP transactions, here's an
    example usage::

        container_absent(api, container_get('yourcontainer'))
    """
    if not container:
        return False
    if container.metadata['status'] == 'Running':
        api.put('containers/%s/state' % container.metadata['name'], json=
            dict(action='stop', timeout=api.default_timeout)).wait()
    api.delete('containers/%s' % container.metadata['name']).wait()
    return True
