Skip to main content

Python interface to Request Tracker API

Project description

codebeat badge tests Documentation Status https://badge.fury.io/py/rt.svg

Rt - Python interface to Request Tracker API

Python implementation of REST API described here:
Python version compatibility:

Python

rt

2.7

< 2.0.0

>= 3.5, <3.7

>= 2.0.0, < 3.0.0

>= 3.7

>= 3.0.0

ℹ️ Note:

Please note that starting with the major release of v3.0.0, this library requires Python version >= 3.7. See the Python version compatibility table above for more detailed information.

⚠️ Warning:

Though version 3.x still supports RT REST API version 1, it contains minor breaking changes. Please see the changelog in the documentation for details.

Requirements

This module uses following Python modules:

Documentation

https://python-rt.readthedocs.io/en/latest/

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 registry 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.rest2
>>> import requests.auth
>>> tracker = rt.rest2.Rt('http://localhost/rt/REST/2.0/', http_auth=requests.auth.HTTPBasicAuth('root', 'password'))
>>> map(lambda x: x['id'], tracker.search(Queue='helpdesk', Status='open'))
['1', '2', '10', '15']
>>> tracker.create_ticket(queue='helpdesk', \
... subject='Coffee (important)', content='Help I Ran Out of Coffee!')
19
>>> tracker.edit_ticket(19, Requestor='addicted@example.com')
True
>>> tracker.reply(19, content='Do you know Starbucks?')
True

Get the last important updates from a specific queue that have been updated recently:

>>> import datetime
>>> import base64
>>> import rt.rest2
>>> import requests.auth
>>> tracker = rt.rest2.Rt('http://localhost/rt/REST/2.0/', http_auth=requests.auth.HTTPBasicAuth('root', 'password'))
>>> 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']
>>>     history = tracker.get_ticket_history(id)
>>>     last_update = list(reversed([h for h in history if h['Type'] in ('Correspond', 'Comment')]))
>>>     hid = tracker.get_transaction(last_update[0]['id'] if last_update else history[0]['id'])
>>>
>>>     attachment_id = None
>>>     for k in hid['_hyperlinks']:
>>>         if k['ref'] == 'attachment':
>>>             attachment_id = k['_url'].rsplit('/', 1)[1]
>>>             break
>>>
>>>         if attachment_id is not None:
>>>             attachment = c.get_attachment(attachment_id)
>>>             if attachment['Content'] is not None:
>>>                 content = base64.b64decode(attachment['Content']).decode()
>>>                 print(content)

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, issue tracking and git repository:

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

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-3.0.6.tar.gz (67.3 kB view details)

Uploaded Source

Built Distribution

rt-3.0.6-py3-none-any.whl (43.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rt-3.0.6.tar.gz
  • Upload date:
  • Size: 67.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for rt-3.0.6.tar.gz
Algorithm Hash digest
SHA256 b0154298af0e3c14c95ad6b31f2abd20a85f450d9b21ab758577685b33961885
MD5 1c408714861ce17387638f192d73eb23
BLAKE2b-256 23a058d94b6ec4ae1daf4d45a39a953a3ecb007e42174bcc51b23ce46c17c365

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rt-3.0.6-py3-none-any.whl
  • Upload date:
  • Size: 43.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for rt-3.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 09bb3a11acf61a182bb0fb5b794b5d49ec786ba4a6496c8575404ed78330fa1c
MD5 03e46cb3ebde350b89dda5c1f97dba01
BLAKE2b-256 cf760e1a10b906d9a4a183ffd338133653debe635bc366104c1584ca1f760d5c

See more details on using hashes here.

Supported by

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