Python interface to Request Tracker API
Project description
Rt - Python interface to Request Tracker API
Python implementation of REST API described here: https://rt-wiki.bestpractical.com/wiki/REST
Note: Please note that starting with the major release of v2.0.0, this library requires a Python version >= 3.5. In case you still require a Python 2 version or one compatible with Python < 3.5, please use a version < 2.0.0 of this library.
REQUIREMENTS
This module uses following Python modules:
requests (http://docs.python-requests.org/)
Unit-tests are implemented using: - nose (http://nose.readthedocs.org)
INSTALLATION
Install the python-rt package using:
pip install rt
LICENCE
This module is distributed under the terms of GNU General Public Licence v3 and was developed by CZ.NIC Labs - research and development department of CZ.NIC association - top level domain registy for .CZ. Copy of the GNU General Public License is distributed along with this module.
USAGE
An example is worth a thousand words:
>>> import rt >>> tracker = rt.Rt('http://localhost/rt/REST/1.0/', 'user_login', 'user_pass') >>> tracker.login() True >>> map(lambda x: x['id'], tracker.search(Queue='helpdesk', Status='open')) ['ticket/1', 'ticket/2', 'ticket/10', 'ticket/15'] >>> tracker.create_ticket(Queue='helpdesk', \ ... Subject='Coffee (important)', Text='Help I Ran Out of Coffee!') 19 >>> tracker.edit_ticket(19, Requestors='addicted@example.com') True >>> tracker.reply(19, text='Do you know Starbucks?') True >>> tracker.logout() True
Get the last important updates from a specific queue that have been updated recently:
>>> import rt >>> tracker = rt.Rt('http://localhost/rt/REST/1.0/', http_auth=HTTPBasicAuth(os.environ['rtuser'], os.environ['rtpasswd'])) >>> tracker.default_queue = "my-queue" >>> fifteen_minutes_ago = str(datetime.datetime.now() - datetime.timedelta(minutes=15)) >>> tickets = tracker.last_updated(since=fifteen_minutes_ago) >>> for ticket in tickets: >>> id = ticket['id'][7:] >>> history = tracker.get_short_history(id) >>> last_update = list(reversed([h for h in history if h[1].startswith('Correspondence added') or h[1].startswith('Comments added')])) >>> hid = tracker.get_history(id, last_update[0][0] if last_update else history[0][0])[0] >>> print("http://localhost/rt/Ticket/Display.html?id=%s" % id) >>> print(hid['Content']) >>> print("\n")
Please use docstrings to see how to use different functions. They are written in ReStructuredText. You can also generate HTML documentation by running make html in doc directory (Sphinx required).
OFFICIAL SITE
- Project site and issue tracking:
- Git repository:
git://github.com/CZ-NIC/python-rt.git
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file rt-2.2.0.tar.gz
.
File metadata
- Download URL: rt-2.2.0.tar.gz
- Upload date:
- Size: 40.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc5a84aa4f4bf0cc8991f197ceba169d2f8dcc2682a913401417961b4b7ab047 |
|
MD5 | 7984e5e27924519ec6223c36380a7202 |
|
BLAKE2b-256 | e77d84e335ec41913a8ff569c78ce649392453e33ebff771584b23dc6e30ef51 |
File details
Details for the file rt-2.2.0-py3-none-any.whl
.
File metadata
- Download URL: rt-2.2.0-py3-none-any.whl
- Upload date:
- Size: 30.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab2293a0b3a90a1cfe66ae82302c97b69d039c47cd5e6d2127772df3e5497d3f |
|
MD5 | b7513f9787ca7f2b6c45ffa9a26fe81a |
|
BLAKE2b-256 | 6cf967e36f3330793d68019765d456c047c07fd5ff57b571b03effbb6c78beae |