dkutils.jira_api.jira_client module

class dkutils.jira_api.jira_client.JiraClient(server, username, api_key)[source]

Bases: object

Client object for invoking JIRA Python API “https://pypi.org/project/jira/

Parameters
  • server (str) – The server address and context path to use. Defaults to http://localhost:2990/jira

  • username (str) – Username to establish a session via HTTP BASIC authentication.

  • api_key (str) – API Key to establish a session via HTTP BASIC authentication.

__init__(server, username, api_key)[source]

Client object for invoking JIRA Python API “https://pypi.org/project/jira/

Parameters
  • server (str) – The server address and context path to use. Defaults to http://localhost:2990/jira

  • username (str) – Username to establish a session via HTTP BASIC authentication.

  • api_key (str) – API Key to establish a session via HTTP BASIC authentication.

add_comment(issue_key, comment)[source]

Add a comment from the current authenticated user on the specified issue and return a Resource for it.

Parameters
  • issue_key (str) – ID or key of the issue to add the comment to (e.g. IM-1)

  • comment (str) – Text of the comment to add

Raises

JiraError – If the issue does not exist or you do not have permission to see it.

Return type

Resource object of <class ‘jira.resources.Comment’> with Comment ID.

get_issue_field(issue, field)[source]

Helper function that returns the value of the requested value for an issue. This function is used in the get_issues() funtion to extract the fields of an issue.

Parameters
  • issue (<class 'jira.resources.Issue'>) – Issue Object of class <class ‘jira.resources.Issue’>.

  • field (str) – Name of the expected field. (e.g status). Note: for a custom field, use the custom field id. (e.g. customfield_10028)

Raises

AttributeError – If the Field does not exist for the issue.

Returns

For a text field : returns a string with the value of the requested field. (e.g. ‘Error’) For a field with multiple options : returns a string of comma separated values from all the options available in the field. (for e.g ‘User1,User2’)

Return type

str

get_issues(project, fields=['created', 'creator', 'assignee', 'status', 'issuetype', 'priority', 'summary', 'description', 'resolution', 'resolutiondate'])[source]

Returns a Pandas DataFrame of all JIRA Issues for the requested project with values for all requested fields.

Parameters
  • project (str) – Project name or key to pull issues from.

  • fields (list, optional) –

    A list of fields to be extracted for each issue in the project. (default is [‘created’, ‘creator’, ‘assignee’, ‘status’, ‘issuetype’, ‘priority’, ‘summary’, ‘description’, ‘resolution’, ‘resolutiondate’])

    Note: for a custom field, use the custom field id. (e.g. customfield_10028)

Raises

AttributeError – If the Field does not exist for the issue.

Returns

A pandas DataFrame of all issues for the requested project with values for all the requested fields.

The column header of the resulting DataFrame is of the form:

If “fields” is defined: [‘project’, ‘key’, field1, field2 , field3….] (default) If “fields” is not defined: [‘project’, ‘key’ ,’created’, ‘creator’, ‘assignee’,’status’, ‘issuetype’, ‘priority’, ‘summary’, ‘description’, ‘resolution’, ‘resolutiondate’]

Return type

pandas DataFrame

transition_issue(issue_key, status)[source]

Perform a transition on an issue.

Parameters
  • issue_key (str) – ID or key of the issue to add the comment to (e.g. IM-1)

  • status (str) – Name of the transition to perform

Raises
  • JiraError – If the issue does not exist or you do not have permission to see it.

  • KeyError – If transition does not exist for the issue.

Return type

None