import warnings


def api_server_version_check(daq):
    """
    Issue a warning and return False if the release version of the API used in the session (daq) does not have the same
    release version as the Data Server (that the API is connected to). If the versions match return True.

    Args:

      daq (ziDAQServer): An instance of the ziPython.ziDAQServer class
        (representing an API session connected to a Data Server).

    Returns:

      Bool: Returns True if the versions of API and Data Server match, otherwise returns False.
    """
    api_version = daq.version()
    api_revision = daq.revision()
    server_version = daq.getString('/zi/about/version')
    server_revision = daq.getInt('/zi/about/revision')
    if api_version != server_version:
        message = ("There is a mismatch between the versions of the API and Data Server. The API reports version `{}' "
                   "(revision: {}) whilst the Data Server has version `{}' (revision {}). See the ``Compatibility'' "
                   "Section in the LabOne Programming Manual for more information.".format(
                       api_version, api_revision, server_version, server_revision))
        warnings.warn(message)
        return False
    return True