Overview
|BuildStatus|
Welcome line
Features
- OTRS REST API for python
Import
import pyotrs
or from pyotrs import Article, Attachment, Client, DynamicField, Ticket
Example
- instantiate a
Client
object called client - create a session ("login") on client
- get the
Ticket
with ID 1
>>> from pyotrs import Article, Client, Ticket >>> client = Client("http://otrs.example.com", "GenericTicketConnectorREST", "root@localhost", "password") >>> client.session_create() True
>>> client.ticket_get_by_id(1) True >>> client.result_list_ticket_get [<Ticket: 1>] >>> my_ticket = client.result_list_ticket_get[0]
>>> my_ticket.TicketNumber u'2010080210123456' >>> my_ticket.Title u'Welcome to OTRS!' >>> my_ticket.to_dct() # Show complete ticket
- add an
Article
toTicket
with ID 1
>>> my_article = Article({"Subject": "Subj", "Body": "New Body"}) >>> client.ticket_update(1, article=my_article) True
- get Articles and Attachments
>>> client.ticket_get_by_id(1, articles=1, attachments=1) # include Articles and Attachments >>> my_ticket = client.result_list_ticket_get[0]
>>> my_ticket.list_articles [<ArticleID: 3>, <ArticleID: 3>
>>> my_ticket.list_dynamic_field [<DynamicField: ProcessManagementActivityID: None>, <DynamicField: ProcessManagementProcessID: None>]
Installation
Get
Project is not yet hosted on Pypi - so for now get it here:
wget https://sys.denm.de/PyOTRS/dist/PyOTRS-0.3.0.tar.gz
Dependencies
Dependencies are installed automatically
- python-requests
- click (for CLI App)
- colorama (for colors in CLI App)
Install
consider using a virtual env:
virtualenv venv
source venv/bin/activate
pip install -U pip
install:
pip install PyOTRS-0.3.0.tar.gz
Getting Started
Get Started:
from pyotrs import Client
client = Client("https://otrs.example.com", "GenericTicketConnectorREST", "root@localhost", "x")
client.session_restore_or_set_up_new()
client.ticket_get_by_id(1)
Useful result data
- client.result_list_ticket_get (list) - list of ticket_get results
- client.result_list_ticket_search (list) - list of ticket_search results
- client.result_json (dict) - full result set as dict
Tips
ipython:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
Full Docs
The Docs are hosted here: https://sys.denm.de/PyOTRS/docs/
Dist
Source distribution files: https://sys.denm.de/PyOTRS/dist/
Coverage
Coverage details: https://sys.denm.de/PyOTRS/htmlcov/
PyOTRS CLI
Bash Completion
http://click.pocoo.org/5/bashcomplete/
For instance, to enable Bash completion put this into your .bashrc: eval "$(_FOO_BAR_COMPLETE=source foo-bar)"
Or Built .sh script
Activation Script The above activation example will always invoke your application on startup. This might be slowing down the shell activation time significantly if you have many applications. Alternatively, you could also ship a file with the contents of that, which is what Git and other systems are doing.
This can be easily accomplished:
_PYOTRS_COMPLETE=source PyOTRS > /path/to/PyOTRS-complete.sh And then you would put this into your bashrc instead:
source /path/to/PyOTRS-complete.sh
Zsh Completion
There is no native support for zsh completion, but zsh can use the bash completion script. Put this into your .zshrc
autoload bashcompinit bashcompinit source /path/to/PyOTRS-complete.sh
License
MIT