Skip to main content

Request Tracker Querying Library

Project description

https://travis-ci.org/tarvitz/rtquery.svg?branch=master https://coveralls.io/repos/github/tarvitz/rtquery/badge.svg?branch=master https://badge.fury.io/py/rtquery.svg

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": [
        "user@example.org.fake"
    ],
    "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())
# ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rtquery-0.10.1.tar.gz (16.1 kB view hashes)

Uploaded source

Built Distribution

rtquery-0.10.1-py3-none-any.whl (21.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page