Git Product home page Git Product logo

python-rt's Introduction

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='[email protected]')
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

python-rt's People

Contributors

e3rd avatar sim0nx avatar sperrygrove avatar vnznznz avatar brettcs avatar rafiot avatar jrandall avatar iamleot avatar wlyeow avatar benfulton avatar danmichaelo avatar kimmoal avatar petterreinholdtsen avatar wari 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.