示例#1
0
def job_cancel(request: Request, job_id: str) -> StatusSchema:
    """
    Cancels the job with a provided `job_id`.
    """
    userid = request.client.host
    db.cancel_job(userid, JobId(job_id))
    return StatusSchema(status="ok")
示例#2
0
def config_edit(data: RequestConfigEdit = Body(...)) -> StatusSchema:
    """
    Change a given configuration key to a specified value.

    This endpoint is not stable and may be subject to change in the future.
    """
    db.set_plugin_configuration_key(data.plugin, data.key, data.value)
    return StatusSchema(status="ok")
示例#3
0
def compact_files() -> StatusSchema:
    """
    Broadcasts compcat command to all ursadb instances. This uses `compact all;`
    subcommand (which is more intuitive because it ways compacts), except the
    recommended `compact smart;` which ignores useless merges. Because of this,
    and also because of lack of control, this it's not recommended for advanced
    users - see documentation and `compactall.py` script to learn more.

    This still won't merge datasets of different types or with different tags,
    and will silently do nothing in such case.

    This endpoint is not stable and may be subject to change in the future.
    """
    db.broadcast_command(f"compact all;")
    return StatusSchema(status="ok")
示例#4
0
def reindex_files() -> StatusSchema:
    """
    Reindex files in the configured default directory.

    There are no server-side checks to avoid indexing multiple times at the
    same time, care should be taken when using it from user scripts.
    This is also not very efficient for large datasets - take a look at
    the documentation for indexing and `index.py` script to learn more.

    This endpoint is not stable and may be subject to change in the future.
    """
    if config.INDEX_DIR is not None:
        types = "[gram3, text4, wide8, hash4]"
        db.broadcast_command(f'index "{config.INDEX_DIR}" with {types};')
    return StatusSchema(status="ok")
示例#5
0
def query_remove(job_id: str) -> StatusSchema:
    db.remove_query(JobId(job_id))
    return StatusSchema(status="ok")
示例#6
0
def job_cancel(job_id: str) -> StatusSchema:
    """
    Cancels the job with a provided `job_id`.
    """
    db.cancel_job(JobId(job_id))
    return StatusSchema(status="ok")
示例#7
0
def query_remove(job_id: str) -> StatusSchema:
    job = db.get_job(JobId(job_id))
    if job.userid != "unknown":
        db.remove_query(JobId(job_id))
    return StatusSchema(status="ok")
示例#8
0
文件: app.py 项目: raw-data/mquery
def user_login(auth: UserAuthSchema = Body(...)) -> StatusSchema:
    if auth.username.startswith("a"):
        return StatusSchema(status="ok")
    raise HTTPException(status_code=400, detail="Wrong password")
示例#9
0
文件: app.py 项目: raw-data/mquery
def user_register(auth: UserAuthSchema = Body(...)) -> StatusSchema:
    if auth.username.startswith("a"):
        return StatusSchema(status="ok")
    raise HTTPException(status_code=400, detail="This user already exists")
示例#10
0
文件: app.py 项目: raw-data/mquery
def config_edit(data: RequestConfigEdit = Body(...)) -> StatusSchema:
    db.set_plugin_configuration_key(data.plugin, data.key, data.value)
    return StatusSchema(status="ok")
示例#11
0
文件: app.py 项目: raw-data/mquery
def job_cancel(job_id: str) -> StatusSchema:
    db.cancel_job(JobId(job_id))
    return StatusSchema(status="ok")
示例#12
0
def compact_all() -> StatusSchema:
    redis.rpush("queue-commands", "compact all;")
    return StatusSchema(status="ok")
示例#13
0
def job_cancel(job_id: str) -> StatusSchema:
    redis.hmset("job:" + job_id, {"status": "cancelled"})
    return StatusSchema(status="ok")