TDX Ticket Integration

This class contains all the methods that work with the TDX Ticket API endpoints.

This class inherits the base TDX integration class.

Class & Methods

class tdxlib.tdx_ticket_integration.TDXTicketIntegration(filename: str = None, config=None)
add_asset_to_ticket(ticket_id: int, asset_id: int) → dict

Attaches an asset to a ticket.

Parameters:
  • ticket_id – The Ticket ID to update
  • asset_id – The ID of the Asset to associate with the Ticket
Returns:

dict of update info

Return type:

dict

build_ticket_custom_attribute_value(custom_attribute: Union[str, dict], value: Union[str, int]) → dict

Builds a custom attribute for a ticket from the name of the attribute and value.

Parameters:
  • custom_attribute – name of custom attribute (or dict of info from )
  • value – name of value to set, or value to set to
Returns:

list of updated assets in dict format (for use in change_custom_attribute_value())

change_ticket_custom_attribute_value(ticket: Union[dict, str, int, list], custom_attributes: list) → Union[tdxlib.tdx_ticket.TDXTicket, list]

Takes a correctly formatted list of CA’s (from build_ticket_custom_attribute_value, for instance) and updates one or more assets with the new values.

Parameters:
  • ticket – ticket/Ticket ID to update (doesn’t have to be full record), or list of same
  • custom_attributes – List of ID/Value dicts (from build_ticket_custom_attribute_value())
Returns:

list of updated ticket in dict format

clean_cache()

Clears the tdx_ticket_integration cache.

Returns:None
create_custom_ticket_status(name: str, order: float, status_class: str, description: str = None, active: bool = True) → dict

Creates a custom ticket status.

Parameters:
  • name – A string containing the name of the new status. (Required)
  • order – A float containing the order number for sorting purposes.
  • status_class – A name of a status class. These values are hard-coded into the TDWebApi, and stored in this class as a class variable.
  • description – A string containing the description of the new status. (Default: Empty String)
  • active – A bool indicating whether this new status should be active. (Default: True)
Returns:

The new ticket status as a dict

Return type:

dict

create_ticket(ticket: tdxlib.tdx_ticket.TDXTicket, silent: bool = True) → tdxlib.tdx_ticket.TDXTicket

Creates a ticket in TeamDynamix using a TdxTicket object

Parameters:
  • ticket – TDXTicket Object
  • silent – Boolean – if False, notifications are sent to requestor and responsible, default: True
Returns:

Created ticket, if successful

Return type:

tdxlib.tdx_ticket.TDXTicket

create_ticket_task(ticket_id: Union[str, int], task: dict) → dict

Adds a ticket task to a ticket.

Parameters:
  • ticket_id – The ticket ID on which to create the ticket task.
  • task – dict of task to create, possibly generated from generate_ticket_task
Returns:

dict of created ticket task information

Return type:

dict

delete_ticket_task(ticket_id: str, task_id: str) → None

Deletes a ticket task by ID

Parameters:
  • ticket_id – The ticket ID on which the ticket task exists.
  • task_id – The task ID of the task you want to delete.
Returns:

none

edit_custom_ticket_status(name: str, changed_attributes: dict) → dict

Edits a custom ticket status

Parameters:
  • name – The name of the status (for finding the object to edit)
  • changed_attributes – A dict containing values to substitute for the status’s current values.
Returns:

The edited status information

Return type:

dict

edit_ticket(ticket: Union[tdxlib.tdx_ticket.TDXTicket, str, int], changed_attributes: dict, notify: bool = False) → tdxlib.tdx_ticket.TDXTicket

Edits one ticket, based on a dict of parameters to change.

Parameters:
  • ticket – a TDXTicket object or a Ticket ID
  • changed_attributes – Attributes to alter in the ticket
  • notify – If true, will notify newly-responsible resource if changed because of edit (default: false)
Returns:

edited ticket as TDXTicket

Return type:

tdxlib.tdx_ticket.TDXTicket

edit_ticket_task(ticket_id: int, task: Union[str, int, dict], changed_attributes: dict) → dict

Edits a ticket task with a set of new values.

Parameters:
  • ticket_id – The ticket ID on which the ticket task exists.
  • task – a single ticket task in dict (maybe from get_ticket_task_by_id), or a task ID
  • changed_attributes – The new values ot set on the ticket task.
Returns:

The modified ticket task as a dict, if the operation was successful

Return type:

dict

edit_tickets(ticket_list: list, changed_attributes: dict, notify: bool = False, visual: bool = False) → list

Edits one or more tickets, based on a dict of parameters to change

Parameters:
  • ticket_list – list of TDXTicket objects, maybe from search_tickets
  • changed_attributes – Attributes to alter in selected tickets
  • notify – If true, will notify newly-responsible resource(s) if changed because of edit
  • visual – If true, print a . for each successful ticket that is edited
Returns:

list of edited TDXTicket objects, with complete data in json format

Return type:

list

generate_ticket(title_template: str, ticket_type: str, account: str, responsible: str, template_values: dict = None, body_template: str = None, attrib_prefix: str = None, due_date: Union[datetime.datetime, str] = None, location: str = None, room: str = None, active_days: int = 5, priority: str = 'Low', status: str = 'New', requestor: str = None, classification: str = 'Incident', form: str = None, responsible_is_group: str = False, custom_attributes: dict = None) → tdxlib.tdx_ticket.TDXTicket

Makes a TdxTicket object based on templates.

Parameters:
  • title_template – a string with {placeholders} that correspond to keys in template_values dict (REQUIRED)
  • ticket_type – name of ticket Type (REQUIRED)
  • account – name of requesting Account for Ticket (REQUIRED)
  • responsible – group or email address to set as responsible for ticket (REQUIRED)
  • template_values – a dictionary with substitutions for title/body, using the {placeholders} as keys
  • body_template – a string with {placeholders} that correspond to keys in template_values parameter
  • attrib_prefix – [DEPRECATED] the string that prefixes all the custom attribute column names in the template_values dict
  • due_date – due date for ticket, default None
  • location – Building name of location (optional)
  • room – Room name of location (optional) Will not set room if location not included.
  • active_days – number of days before due date to assign start date, default is 5
  • priority – name of priority of ticket, default “Low”
  • status – name of status for new ticket, default “New”
  • requestor – name or email for requester of the ticket, defaults to username of integration (optional)
  • classification – name of classification name for new ticket, default “Incident” (optional)
  • form – name or ID of a form to use for the new ticket
  • responsible_is_group – Boolean indicating whether ‘responsible’ refers to a group. (Default: False)
  • custom_attributes – dict of attribute names and values
Returns:

TdxTicket object ready to be created via create_ticket()

Return type:

tdxlib.tdx_ticket.TDXTicket

generate_ticket_task(title: str, est_minutes: int = 30, description: str = None, start: datetime.datetime = None, end: datetime.datetime = None, completion_minutes: int = None, responsible: str = None, group: bool = False, predecessor: int = None) → dict

Generates a dict with the information in the proper format for creating at ticket task.

Parameters:
  • title – A string indicating the title of the ticket (Required)
  • est_minutes – Estimation of minutes required to complete this task (Default: 30) This is used for comparison to actual hours when using time tracking
  • description – A string containing a description of the task (Default: Empty String)
  • start – Datetime object indicating the start date of the ticket task (Default: date of creation)
  • end – Datetime object indicating the end date of the ticket task. Sets the due date/time. (Default: one hour after start)
  • completion_minutes – This parameter is used for tasks with predecessors. (Default: 0) They set the due date/time based on the activation date and time.
  • responsible – String containing the name or partial name of a group or individual to assign the task to. (Default: None)
  • group – Boolean indicating whether the responsible parameter references a group (Default:false)
  • predecessor – Task ID of another task in the destination ticket to set as the predecessor. (Default: None)
Returns:

Dict of task information fit for creating a task on a ticket using create_task()

get_all_tasks_by_ticket_id(ticket_id: Union[str, int], is_eligible_predecessor: bool = None) → list

Gets a list of tasks currently on an open ticket. If the ticket is closed, no tasks will be returned.

Parameters:
  • ticket_id – The ticket ID to retrieve ticket tasks for.
  • is_eligible_predecessor – (optional) If true, will only retrieve tasks that can be assigned as a predecessor for other tasks.
Returns:

list of ticket tasks as dicts

Return type:

list

get_all_ticket_assets(ticket_id: int) → list

Gets all asset attached to a ticket.

Parameters:ticket_id – The Ticket ID to update
Returns:list of asset info
Return type:list
get_all_ticket_forms() → list

Gets a list of all ticket forms from TDX.

Returns:list of ticket forms as python dicts
Return type:list
get_all_ticket_impacts() → list

Gets a list of all ticket impacts from TDX.

Returns:list of impacts in as python dicts
Return type:dict
get_all_ticket_priorities() → list

Gets a list of all ticket priorities from TDX.

Returns:list of priorities in python dict
Return type:list
get_all_ticket_sources() → list

Gets a list of all ticket sources from TDX

Returns:list of sources in python dict
Return type:list
get_all_ticket_statuses() → list

Gets a list of all ticket statuses from TDX

Returns:list of status data in python dicts
Return type:list
get_all_ticket_types() → list

Gets a list of all ticket types from TDX.

Returns:list of type data in python dicts
Return type:list
get_all_ticket_urgencies() → list

Gets all ticket urgencies from the Tickets app.

Returns:list of priorities in python dict
Return type:dict
get_ticket_by_id(ticket_id: int) → tdxlib.tdx_ticket.TDXTicket

Gets a ticket, based on its ID

Parameters:ticket_id – ticket ID of required ticket
Returns:ticket info as python dict
Return type:dict
classmethod get_ticket_classification_id_by_name(name: str)

Gets ticket classification data by searching by the name of the classification.

Parameters:name – the name of the classification to search for
Returns:dict of ticket classification info
Return type:dict
get_ticket_custom_attribute_by_name(key: str) → dict

Gets a ticket custom attribute based on its name or ID. This includes hard-coded the component ID for tickets.

Parameters:key – A full or partial name of the CA to get.
Returns:a dict of custom attribute information
Return type:dict
get_ticket_custom_attribute_by_name_id(key: str) → dict

Gets a ticket custom attribute based on its name or ID. This includes hard-coded the component ID for tickets.

Parameters:key – A full or partial name of the CA to get.
Returns:a dict of custom attribute information
Return type:dict
get_ticket_feed(ticket_id: Union[str, int]) → list

Gets the feed entries from a ticket.

Parameters:ticket_id – The ticket ID on which the ticket task exists.
Returns:list of feed entries from the task as python dicts, if any exist
Return type:list
get_ticket_form_by_name_id(key: Union[str, int]) → dict

Gets ticket form based on ID or Name.

Parameters:key – Name or ID of form to search for
Returns:form data in python dict
Return type:dict
get_ticket_impact_by_name_id(key: Union[str, int]) → dict

Gets ticket impact based on ID or Name

Parameters:key – Name or ID of impact to search for
Returns:impact data in python dict
Return type:dict
get_ticket_priority_by_name_id(key: Union[str, int]) → dict

Gets ticket priority based on ID or Name.

Parameters:key – ID or Name of priority to search for
Returns:priority data in python dict
Return type:dict
get_ticket_source_by_name_id(key: Union[str, int]) → dict

Gets ticket source based on ID or Name

Parameters:key – Name or ID of source to search for.

Supports search for exact name (‘1. Phone’), or part of name (‘Phone’).

Returns:source data in python dict
Return type:dict
get_ticket_status_by_id(key: Union[str, int]) → dict

Gets ticket status based on ID or Name.

Parameters:key – ID of ticket status to search for
Returns:status data in python dict
Return type:dict
get_ticket_task_by_id(ticket_id: Union[str, int], task_id: Union[str, int]) → dict

Gets ticket task by ID.

Parameters:
  • ticket_id – The ticket ID on which the ticket task exists.
  • task_id – The ticket task ID.
Returns:

Task data in dict

Return type:

dict

get_ticket_task_feed(ticket_id: Union[str, int], task_id: Union[str, int]) → list

Gets all the feed entries from a ticket task.

Parameters:
  • ticket_id – The ticket ID on which the ticket task exists.
  • task_id – The ticket task ID.
Returns:

list of feed entries from the task, if any exist

Return type:

list

get_ticket_type_by_name_id(key: Union[str, int]) → dict

Gets ticket type based on ID or Name.

Parameters:key – Name or ID of attribute to search for
Returns:type data in python dict
Return type:dict
get_ticket_urgency_by_name_id(key: Union[str, int]) → dict

Gets ticket urgency based on ID or Name.

Parameters:key – ID or Name of urgency to search for
Returns:urgency data in python dict
Return type:dict
make_call(url: str, action: str, post_body: dict = None)

Makes an HTTP call using the Tickets API information.

Parameters:
  • url – The URL (everything after tickets/) to call
  • action – The HTTP action (get, put, post, delete, patch) to perform.
  • post_body – A dict of the information to post, put, or patch. Not used for get/delete.
Returns:

the API response as a python dict or list

reassign_ticket(ticket_id: Union[str, int], responsible: str, group: bool = False) → tdxlib.tdx_ticket.TDXTicket

Reassigns a ticket to a person or group

Parameters:
  • ticket_id – The ticket of the ticket you want to edit.
  • responsible – a username, email, Full Name, or ID number to use to search for a person
  • group – If this parameter is True, assign to group instead of individual
Returns:

Edited TDXTicket object, if the operation was successful

Return type:

tdxlib.tdx_ticket.TDXTicket

reassign_ticket_task(ticket_id: int, task: Union[str, dict, int], responsible: str, group=False) → dict

Reassigns a ticket task to a person or group

Parameters:
  • ticket_id – The ticket ID on which the ticket task exists.
  • task – a single ticket task in dict (maybe from get_ticket_task_by_id), or a task ID
  • responsible – a username, email, Full Name, or ID number to use to search for a person, or a group name.
  • group – If this parameter is True, assign to group instead of individual
Returns:

The modified ticket task as a dict, if the operation was successful

Return type:

dict

reschedule_ticket(ticket_id: Union[str, int], start_date: datetime.datetime = False, end_date: datetime.datetime = False) → tdxlib.tdx_ticket.TDXTicket

Reschedules the start and end dates of a ticket. This is impossible if the ticket has a task.

Parameters:
  • ticket_id – The ticket of the ticket you want to edit.
  • start_date – datetime.datetime object for the start date of the ticket (defaults to now)
  • end_date – datetime.datetime object for the end date of the ticket (defaults to now + 1 day)
Returns:

Edited TDXTicket object, if the operation was successful

Return type:

tdxlib.tdx_ticket.TDXTicket

reschedule_ticket_task(ticket_id, task, start_date: datetime.datetime = None, end_date: datetime.datetime = None) → dict

Sets the start date and end date for a ticket task. This will affect the start & end dates of the parent ticket.

Parameters:
  • ticket_id – The ticket ID on which the ticket task exists.
  • task – a single ticket task in dict (maybe from get_ticket_task_by_id), or a task ID
  • start_date – datetime.datetime object to use as the starting date for a task, defaults to now.
  • end_date – datetime.datetime object to use as the starting date for a task, defaults to now + 1 day.
Returns:

The modified ticket task as a dict, if the operation was successful

Return type:

dict

search_ticket_status(key: str) → dict

Gets ticket status based on name.

Parameters:key – Name of ticket status to search for
Returns:status data in python dict
Return type:dict
search_tickets(criteria: dict, max_results: int = 25, closed: bool = False, cancelled: bool = False, other_status: bool = False) → list

Gets a ticket, based on a variety of criteria:

{'TicketClassification': [List of Int],
'SearchText': [String],
'Status IDs': [List of Int],
'ResponsibilityUids': [List of String (GUID)],
'ResponsibilityGroupIDs': [List of String (ID)],
'RequestorEmailSearch': [String],
'LocationIDs': [List of Int],
'LocationRoomIds': [List of Int],
'CreatedDateFrom': [DateTime],
'CreatedDateTo': [DateTime],
'SlaViolationStatus': [Boolean -- true = SLA Violated]}

(https://api.teamdynamix.com/TDWebApi/Home/type/TeamDynamix.Api.Tickets.TicketSearch)

Parameters:
  • max_results – maximum number of results to return
  • criteria – a string, list or dict to search for tickets with
  • cancelled – include cancelled tickets in search if true
  • closed – include closed tickets in search if true
  • other_status – Status ID of a custom status
Returns:

list of TDXTicket objects

Return type:

list

update_ticket(ticket_id: Union[str, int], comments: str, new_status: str = None, notify: list = None, private: bool = True) → dict

Sends an update to a ticket feed.

Parameters:
  • ticket_id – the ticket ID whose task to update
  • comments – a string to provide as a comment to the update.
  • new_status – The name of the new status to set for the ticket (Default: The status whose ID is 0)
  • notify – a list of strings containing email addresses to notify regarding this ticket. Default: None
  • private – boolean indicating whether the update to the task should be private. Default: True
Returns:

python dict containing created ticket update information

Return type:

dict

update_ticket_task(ticket_id: int, task_id: int, percent: int, comments: str = '', notify: list = None, private: bool = True) → dict

Sends an update to a ticket task.

Parameters:
  • ticket_id – the ticket ID whose task to update
  • task_id – the ID of the task to update
  • percent – the percent complete to set the task to after update
  • comments – a string to provide as a comment to the update. Defaults to empty string.
  • notify – a list of strings containing email addresses to notify regarding this ticket. Default: None
  • private – boolean indicating whether the update to the task should be private. Default: True
Returns:

dict of update info

Return type:

dict

upload_attachment(ticket_id: Union[str, int], file: BinaryIO, filename: str = None)

Uploads an attachment to a ticket.

Parameters:
  • ticket_id – the ticket ID to upload the attachment
  • file – Python file object opened in binary read mode to upload as attachment
  • filename – (optional), explicitly specify filename header. If None, requests will determine from

passed-in file object.

Returns:python dict containing created attachment information
Return type:dict