Skip to main content

A light weight library to interact with the Jira API

Project description

Jirasession

A light weight library to interact with the Jira API

Documentation

jirasession

Documentation for the JiraSession and JiraUser objects

jirasession.session

jirasession.session.JiraSession(self, username: str, token: str, server: str, session: requests.sessions.Session = None, max_retries: int = 3, pool_connections: int = 16, pool_maxsize: int = 16, resolve_status_codes: list = [200, 201, 204])

JiraSession object can be imported from jirasession.session or from jirasession

JiraSession.__init__(self, username: str, token: str, server: str, session: requests.sessions.Session = None, max_retries: int = 3, pool_connections: int = 16, pool_maxsize: int = 16, resolve_status_codes: list = [200, 201, 204])

Initialization of JiraSession

JiraSession._resolver(self, request: functools.partial) -> requests.models.Response

attempt to resolve a bad requests don't call this method alone

JiraSession.account_info(self) -> requests.models.Response

    get jira accountid from current auth creds

    return {int} -- accountid or None

JiraSession.add_attachment(self, issue_key: str, filepath: str) -> requests.models.Response

    add an attachment to an issue

    issue_key {str} -- id or key of issue to add attachment
    filepath {str} -- path to file to use as attachment

    return {requests.Response} -- response from attachment route

JiraSession.add_comment(self, issue_key: str, comment: str) -> requests.models.Response

    add a new comment to a issue

    issue_key {str} -- issue key to pull available transitions from
    comment {str} -- string to add as comment

    return {requests.Response} -- response from post to comment route

JiraSession.assign_issue(self, issue_key: str, accountid: str) -> requests.models.Response

    assign a issue to the current user accountid

    issue_key {str} -- newly created issue key

JiraSession.assign_to_me(self, issue_key: str) -> requests.models.Response

    assign to yourself based on jirauser.userid
    issue {str} -- issue key to assign to yourself

JiraSession.create_issue(self, content: dict) -> requests.models.Response

    create a new issue

    content {dict} -- dictionary of issue content

    return {requests.Response} -- response from post

JiraSession.delete_issue(self, issue_key: str, delete_subtasks: bool = False) -> requests.models.Response

    delete and issue by id

    issue_key {str} -- key of issue to delete

    return {requests.Response} -- response from delete

JiraSession.get_all_comments(self, issue_key: str, orderby: str = 'created', expand: bool = False) -> list

get all comments from an issue

    issue_key {str} -- issue key to get comments for
    orderby {str} -- order comments by created date, other options [-created, +created]
    expand {bool} -- if true, renderBody will be sent to get comments rendered in html

    return {list} -- return list of comments from issue

JiraSession.get_comments(self, issue_key: str, start: int = 0, maxresults: int = 50, orderby: str = 'created', expand: bool = False) -> requests.models.Response

get comments from an issue

    issue_key {str} -- issue key to get comments for
    start {int} -- start index for retrieval
    maxresults {int} -- max number of comments to retrieve [default: 50]
    orderby {str} -- order comments by created date, other options [-created, +created]
    expand {bool} -- if true, renderBody will be sent to get comments rendered in html

    return {requests.Response} -- response from comments route

JiraSession.get_issue(self, issue_key: str, fields: list = ['*all'], expand: dict = {}) -> requests.models.Response

    get jira issue by id

    issue_key {str} -- key of issue to get
    fields {list} -- fields to retrieve, add a '-' to a field to remove it. Default: *all
    expand {dict} -- custom expand for search, use jira api docs to further expand

    return {requests.Response} -- response from issue route (GET)

JiraSession.get_issues_from_project(self, project_key: str, maxresults: int = None) -> list

    retrieve all issues from a given project id
    project_key {str} -- project key, example: DEV
    maxresults {int} -- max number of results

    return {list} -- issues

JiraSession.get_jira_user(self, username: Union[str, list]) -> requests.models.Response

    get user information for jira users by usernames

    username {Union[str, list]} -- a username or list of usernames

    return {requests.Response} -- the response from the user bulk route

JiraSession.get_project_issuetypes(self, project_key: str) -> list

    get the available issue types for a project

    project_key {str} -- key for project

    return {list} -- issuetypes found for the given project

JiraSession.get_transitions_from_issue(self, issue_key: str) -> requests.models.Response

    get the available transitions for a issue

    issue_key {str} -- issue key to pull available transitions from

    return {requests.Response} -- response from get to transitions route

JiraSession.jira_priorities_list(self) -> list

    get the available priorities for a project

    project_key {str} -- key for project

    return {list} -- priorities found for the given project

JiraSession.link_issues(self, in_issue_key: str, out_issue_key: str, link_type: str = 'relates to', comment: dict = None) -> requests.models.Response

link two issues together, in and out will relate to jira api route but has no effect on functionality

    in_issue_key {str} -- the issue to link from
    out_issue_key {str} -- the issue to link to
    link_type {str] -- type of link, default: Relates To
    comment {dict} [optional] -- comment for linking of issues
    
    return {requests.Response} -- response from issuelink route

JiraSession.link_types(self) -> requests.models.Response

    retrieve the link types for jira issues

    return {requests.Response} -- response from issueLinkType route

JiraSession.search(self, jql: str, start: int = 0, maxresults: int = 50, fields: list = ['*all'], validate: bool = True, validate_level: str = 'strict', expand: dict = {}) -> requests.models.Response

    search jira using a jql statement
    jql {str} -- jql string to search and validate if chosen
    start {int} -- start index
    maxresults {int} -- max number of results per page
    fields {list} -- fields to retrieve, add a '-' to a field to remove it. Default: *all
    validate {bool} -- to validate jql string upon search
    validate_level {str} -- validation level: strict, warn, none. Default: strict
    expand {dict} -- custom expand for search, use jira api docs to further expand

    return {requests.Response} -- response from search route (POST)

JiraSession.track_issue_time(self, issue_key: str, time_spent: str) -> requests.models.Response

    add time for time tracking application for a issue

    issue_key {str} -- issue key to pull available transitions from
    time_spent {str} -- jira format time. ex: 1d 2h 3m

    return {requests.Response} -- response from post to worklog route

JiraSession.transition_issue(self, issue_key: str, transition_state_id: str) -> requests.models.Response

    transition a issue to a new state by id

    issue_key {str} -- issue key to pull available transitions from
    transition_state_id {str} -- new transition state id

    return {requests.Response} -- response from post to transitions route

JiraSession.update_issue(self, issue_key: str, content: dict) -> requests.models.Response

    update an issue by id

    issue_key {str} -- key of issue to update
    content {dict} -- dictionary of issue content

    return {requests.Response} -- response from put

jirasession.user

jirasession.user.JiraUser(self, username: str = None, token: str = None, server: str = None)

An authenticated Jira user

JiraUser.__init__(self, username: str = None, token: str = None, server: str = None)

a JiraUser object that contains information for the authenticated user

    username {str} -- username for jira account
    token {str} -- api token for jira account
    server {str} -- server to build rest url from

JiraUser.account_information(self) -> requests.models.Response

get account information for jira account from username and token

    return {requests.Response} response from myself route

Basic example

from jirasession import JiraSession

session = JiraSession('email', 'token', 'https://server.atlassian.net/')

new_isssue = {
    'project': {'key': 'DEV'},
    'summary': 'test',
    'description': 'test',
    'issuetype': {'name':'Ticket'}
}

resp = session.create_issue(new_isssue)
if resp.status_code == 200:
    print('issue created') # handle requests.Response to get issue information
else:
    print('error creating issue') # debug requests.Response here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jirasession-0.2.4.tar.gz (9.6 kB view details)

Uploaded Source

File details

Details for the file jirasession-0.2.4.tar.gz.

File metadata

  • Download URL: jirasession-0.2.4.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.4

File hashes

Hashes for jirasession-0.2.4.tar.gz
Algorithm Hash digest
SHA256 f96da087ea81f53bf13b27a422e8ea0d170636a7f403a69e8689f5080ea73de9
MD5 c72b3bf59258cd17bbd71b89b876a62a
BLAKE2b-256 edf9ab924f22d746dadd548cbd674faded351fc7b8e34dc719db67b382256c51

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page