Ensure that given continuous query is present.

    name
        Name of the continuous query to create.

    database
        Database to create continuous query on.

    query
        The query content

    resample_time : None
        Duration between continuous query resampling.

    coverage_period : None
        Duration specifying time period per sample.

def present(name, database, query, resample_time=None, coverage_period=None, **client_args):
    '''
    Ensure that given continuous query is present.

    name
        Name of the continuous query to create.

    database
        Database to create continuous query on.

    query
        The query content

    resample_time : None
        Duration between continuous query resampling.

    coverage_period : None
        Duration specifying time period per sample.
    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': 'continuous query {0} is already present'.format(name)}

    if not __salt__['influxdb.continuous_query_exists'](name=name,
                                                        database=database,
                                                        **client_args):
        if __opts__['test']:
            ret['result'] = None
            ret['comment'] = ' {0} is absent and will be created'\
                .format(name)
            return ret
        if __salt__['influxdb.create_continuous_query'](
            database, name, query, resample_time, coverage_period
        ):
            ret['comment'] = 'continuous query {0} has been created'\
                .format(name)
            ret['changes'][name] = 'Present'
            return ret
        else:
            ret['comment'] = 'Failed to create continuous query {0}'\
                .format(name)
            ret['result'] = False
            return ret

    return ret