Giter VIP home page Giter VIP logo

rtquery's Introduction

RT Query

image

image

image

Abstract

Simplifies query interface for Request Tracker_'s rest-api lib RT Library_. Main query interface has been take from Django Framework_ project

Requirements

  • Python 3.4+
  • RT Library_ (it's not dependency itself, but it uses in examples)

Usage

import rt

client = rt.Rt('http://localhost/rt/REST/1.0/',
               basic_auth=('user', 'password'))
assert client.login()
#: rt filtering does not support `in` operation, so interface looks similar
#: to django querying, but it sticks to its limits.
query = Q(Subject__contains='[improvements]') | Q(Subject__contains='[enhancements]')
query &= Q(Queue='development', Status='sprint', Owner='User',
           Priority__gt=80)
result = client.search(Queue=rt.ALL_QUEUES, raw_query=query.resolve())
print(result)
[{
    "id": "ticket/471147",
    "Queue": "development",
    "Owner": "User",
    "Creator": "User",
    "Subject": "[improvements] Implement Requests Tracker simple querying",
    "Status": "sprint",
    "Priority": "99",
    "InitialPriority": "40",
    "FinalPriority": "40",
    "Requestors": [
        "[email protected]"
    ],
    "Created": "Thu Nov 02 19:26:40 2017",
    "Starts": "Not set",
    "Started": "Thu Nov 02 19:27:12 2017",
    "Due": "Not set",
    "Resolved": "Not set",
    "Told": "Not set",
    "LastUpdated": "Thu Nov 09 17:20:33 2017",
    "TimeEstimated": "180 minutes",
    "TimeWorked": "0",
    "TimeLeft": "0",
    "CF.{Tags}": "extra",
    "CF.{Code Review}": "",
    "CF.{Difficulty}": ""
}]

Extra functionality

In addition to existent rtquery.Q you can also try to use utils.query builder which is simple dsl to make Q objects from user input (argument parser for example)

from rtquery.utils import query
qset = query("Queue = development & Status = sprint & Owner ~ user")
result = client.search(Queue=rt.ALL_QUEUES, raw_query=query.resolve())
# ...

rtquery's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.