RT¶
This module leverages RT’s REST API to create new interfaces for LNL’s ticketing system.
API Methods¶
-
rt.api.
api_request
(method, endpoint, data=None, token=None)[source]¶ Send an API request to the RT server
Parameters: - method – GET, POST, PUT, or DELETE
- endpoint – RT endpoint
- data – JSON data (if applicable)
- token – RT Auth Token (uses the General account token if None)
Returns: Response
-
rt.api.
create_ticket
(queue, reporter, subject, content, html=False, cc=None, attachments=None)[source]¶ Create a new ticket in RT
Parameters: - queue – The ticket queue to send the ticket to
- reporter – Email address of the user submitting the ticket
- subject – Brief subject line for quick reference
- content – The contents of the ticket
- html – If true, will set ContentType to text/html instead of text/plain
- cc – List of additional email addresses to include in the ticket [Optional]
- attachments – A list of attachments to include [Optional]
Returns: API response
-
rt.api.
fetch_ticket
(ticket_id)[source]¶ Retrieve a ticket from RT
Parameters: ticket_id – The ticket’s ID # Returns: Dictionary of ticket information
-
rt.api.
get_user
(username, token)[source]¶ Obtain user profile from RT
Parameters: - username – Username to use in search
- token – Valid auth token with the proper permissions
Returns: User profile (JSON) or None if not found
-
rt.api.
permission_error
(response)[source]¶ Check if a request to RT was rejected due to a lack of permissions
Parameters: response – The response from RT Returns: True if the request was rejected
-
rt.api.
search_tickets
(query)[source]¶ Obtain a list of RT tickets matching the specified query (works with pagination)
Parameters: query – The TicketSQL query to use for the search Returns: A list of ticket ids
-
rt.api.
simple_ticket_search
(requestor=None, owner=None, queue=None, status=None)[source]¶ Search for tickets in RT. You must provide a value for at least one of the following: requestor, owner, queue
Parameters: - requestor – Email address of the user that submitted the tickets
- owner – Email address of the user the tickets have been assigned to
- queue – Name of the RT queue (i.e. Database, Repairs, etc.)
- status – Filter by ticket status (i.e. New, Open, __Active__, etc.) [Optional]
Returns: A list of ticket ids
-
rt.api.
ticket_comment
(ticket_id, comments, notify=False, token=None)[source]¶ Comment on a ticket in RT
Parameters: - ticket_id – The ticket’s ID #
- comments – Comments to add to the ticket
- notify – If True, comments will also be sent to watchers via email
- token – Provide token if available (Comment will be posted anonymously otherwise)
Returns: API response
-
rt.api.
ticket_history
(ticket_id, simple=True, token=None)[source]¶ Retrieve ticket history information from RT
Parameters: - ticket_id – The ticket’s ID #
- simple – If False, the response will contain more detailed information
- token – RT Auth Token (uses the General account token if not provided)
Returns: Dictionary - Contains a list of dictionaries with ticket history information
-
rt.api.
update_ticket
(ticket_id, token, status=None, owner=None)[source]¶ Update a ticket’s metadata in RT
Parameters: - ticket_id – The ticket’s ID #
- token – Auth token to authenticate the request with
- status – The new status to assign to the ticket (if applicable). Must match the available options in RT.
- owner – The email address of the user to assign the ticket to (if applicable)
Returns: API response
Views¶
Forms¶
-
class
rt.forms.
AuthTokenForm
(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]¶ -
class
Meta
[source]¶ -
layout
= [('Text', "To continue, you'll need to create an Auth Token in RT. For instructions on how to do this, <a href='https://lnldb.readthedocs.io/en/latest/help/accounts/linking-rt.html'>click here</a>.<br><br>"), ('Field', 'token')]¶
-
-
base_fields
= {'token': <django.forms.fields.CharField object>}¶
-
declared_fields
= {'token': <django.forms.fields.CharField object>}¶
-
media
¶
-
class
-
class
rt.forms.
TicketSubmissionForm
(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]¶ -
class
Meta
[source]¶ -
layout
= [('Text', "<span style='color: grey'><em>Your name and contact information will automatically be shared with our support team when you submit this form.</em></span><br><br>"), ('Field', 'subject'), ('Field', 'description'), ('Field', 'attachments')]¶
-
-
base_fields
= {'attachments': <multiupload.fields.MultiFileField object>, 'description': <django.forms.fields.CharField object>, 'subject': <django.forms.fields.CharField object>}¶
-
declared_fields
= {'attachments': <multiupload.fields.MultiFileField object>, 'description': <django.forms.fields.CharField object>, 'subject': <django.forms.fields.CharField object>}¶
-
media
¶
-
class