rt_requests

Warning: This module is deprecated! This module is no longer supported. We recommend using the newer ‘rt’ module, which utilizes the latest REST API V2 to interact with the RT System. Please add any new functionality to the ‘rt’ module instead of this one.

class accre.rt_requests.Requestor[source]

Bases: object

RT wrapper class for requests

create_ticket(queue, requestor, subject, text, cc=None, admincc=None, owner=None, priority=0, custom_fields={})[source]

Create a new RT ticket

Parameters:
  • queue (str) – Name of the RT Queue for the ticket

  • requestor (str) – Email address of the requestor

  • subject (str) – Subject line for the new ticket

  • text (str) – Ticket initial entry text. Note that this method will modify multiline text to proper indentation spacing as required by RT.

  • cc (str) – Optional email(s) for cc

  • admincc (str) – Optional emails(s) for admincc

  • owner (str) – Optional rt username for ticket owner

  • priority (int) – Priority for the new ticket, defaults to zero.

Returns:

Ticket ID for the new ticket

Return type:

int

static key_value_mapper(line)[source]

Maps an RT ticket string into key value pairs.

This parsing is a direct result of the RT API returning plain text instead of JSON. The use of JSON is a goal for their project.

Parameters:

line (str or iterable(str)) – RT ticket text

Returns:

ticket metadata

Return type:

OrderedDict

The rt responds with a list of items as text separated by “n–n” This modules builds on top of the existing one.

parse_ticket_history_content(hist: str)[source]

Parses the content using multiline regex

Parameters:

hist (str) – history content payload

Returns:

parsed output or None

Return type:

OrderedDict or NoneType

search_multiple_tickets(query="Status = 'open'", filter_fun=<function Requestor.<lambda>>, extra_params={})[source]

Searches for a ticket based on query

The query string supports any search supported by the Query Builder.

Example:

..code-block:

requestor.search_tickets(
  rt_query,
  extra_params={"fields": "Status, Subject, Priority"}
)
Parameters:
  • query – valid query string (see RT wiki)

  • filter_fun – filter function to apply to results, accepts a tuple of (ticket_id, subject) and returns a boolean

  • extra_params – dict of extra parameters to pass to the query.

Returns:

List(OrderedDict) of (ticket_no, title) pairs

search_tickets(query="Status = 'open'", filter_fun=<function Requestor.<lambda>>)[source]

Searches for a ticket based on query and prints results to stdout.

The query string supports any search supported by the Query Builder.

Parameters:
  • query – valid query string (see RT wiki)

  • filter_fun – filter function to apply to results, accepts a tuple of (ticket_id, subject) and returns a boolean

Returns:

OrderedDict of (ticket_no, title) pairs

set_user_disabled(user_id, disabled)[source]

Set user to disabled or enabled

Parameters:
  • user_id (str) – RT id of the user

  • disabled (bool) – New status for the user, True to disable

show_user(user_id)[source]

Return raw user information from RT

Parameters:

user_id (str) – RT id of the user

ticket_account_bot_json(ticket_id)[source]

Get a json object encoded into the content of the first comment on the ticket designed for use by account robots for account creation, password resets, and other purposes.

Parameters:

ticket_id (str|int) – str or int specifying unique ticket id

Returns:

json object with user info

Return type:

dict

ticket_first_history_content(ticket_id)[source]

Gets the content of the chronologically first history item for a given ticket id.

Parameters:

ticket_id – str or int specifying unique ticket id

Returns:

OrderedDict containing content of first history

ticket_first_history_text(ticket_id)[source]

Gets the content of the chronologically first history item for a given ticket id as raw text

Parameters:

ticket_id (str|int) – unique ticket id

Returnis:

String containing content of first history

ticket_last_responder(ticket_id)[source]

Search for most recent “Correspondence added by foo”

Parameters:

ticket_id (int or str) – RT ticket identifier

Returns:

last response to ticket

Return type:

str

ticket_latest_update(ticket_id)[source]

Find the time since last change on ticket history

Parameters:

user

Returns:

Return type:

ticket_responders(ticket_number)[source]

Gets the canonically chronological list of ticket responders

Parameters:

ticket_number (int or str) – RT ticket identifier

Returns:

(corresponders, commenters)

Return type:

tuple(list(str), list(str))

user_props(username: str)[source]

Return RT user properties

Parameters:

username (str) – RT username

Returns:

associative array of user properties and values

Return type:

OrderedDict