Skip to main content

Python interface to Request Tracker API

Project description

https://travis-ci.org/CZ-NIC/python-rt.svg?branch=master Documentation Status

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:

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:

https://github.com/CZ-NIC/python-rt

Git repository:

git://github.com/CZ-NIC/python-rt.git

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

rt-2.0.1.tar.gz (40.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rt-2.0.1-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

Details for the file rt-2.0.1.tar.gz.

File metadata

  • Download URL: rt-2.0.1.tar.gz
  • Upload date:
  • Size: 40.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rt-2.0.1.tar.gz
Algorithm Hash digest
SHA256 7c7d81d9112bd5718d57182ad39a70cdb8b7a5b9b06cde289f70d7e4d495ae8e
MD5 7725c766d6bcca6808432414f58a4b8a
BLAKE2b-256 09bb894f5cfac398e18ea592a16de18913f75be771f22b91e9d98c03784197a0

See more details on using hashes here.

File details

Details for the file rt-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: rt-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rt-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab367b9e0a6b17aecaa22cde38c7036aff97410fb096b8514eaad801a906f332
MD5 eeb7ab2bcf6ce9785d3b6ebf057bd3cc
BLAKE2b-256 f143d1f0550cd89c81082bb95d368974fea985fd9dcd50630d0b32ed4bec24ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page