Package: atlassian-modules
The best way to interact with Atlassian Jira/Confluence API.Prerequisitesfromatlassian_modulesimportJiraHelper# for Jirafromatlassian_modulesimportWikiHelper# for WikiGetting StartedConnectivity to Atlassian JiraTo initialize a connection to Jira, instantiate theJiraHelperclass with your Jira URL, email, and API token:jira_helper=JiraHelper(JIRA_URL,EMAIL,API_TOKEN)wiki_helper=WikiHelper(JIRA_URL,EMAIL,API_TOKEN)Atlassian Jira1. Create a Jira TicketYou can create a new Jira ticket using thecreate_ticketmethod:test=jira_helper.create_ticket("XX","Test Issue","This is a test issue created from main.py","Task")print(test)Parameters:project_key: The key of the project in which the ticket should be created.summary: A brief summary of the issue.description: A detailed description of the issue.issue_type: The type of the issue (e.g., "Task", "Bug", etc.).Output:Preparing issue data...Sending request to create a ticket in project ID...Ticket created successfully!Ticket URL:https://your-url.atlassian.net/browse/XX-1234Or error! with details!Return:test =https://your-url.atlassian.net/browse/XX-12342. Delete a Jira TicketTo delete a ticket, use thedelete_ticketmethod:test=jira_helper.delete_ticket("XX-1234")print(test)Parameter:ticket_key: The unique key of the ticket you want to delete.Output:Checking existence of ticket:XX-1234...TicketXX-1234exists!Or error! with details!Return:True/False3. Transition a Jira TicketTo transition a ticket to a different status, use thetransition_ticketmethod:test=jira_helper.transition_ticket("XX-1234","In Progress")print(test)# ortest=jira_helper.transition_ticket("XX-1234",31)print(test)Parameters:ticket_key: The unique key of the ticket you want to transition.transition_name: The name of the transition you want to apply. This is not a case-sensitive when you apply the transition name.Output:Attempting to transition ticket:XX-1234...Using provided transition ID.Successfully transitioned ticket:XX-1234Or error! with details!Return:True/False4. If exist a Jira TicketTo check if a ticket exist, use theif_ticket_existmethod:test=jira_helper.if_ticket_exist("XX-1234")print(test)Parameters:ticket_key: The unique key of the ticket you want to check that exist.Output:Checking existence of ticket:XX-1234...TicketXX-1234exists!Return:True/False5. Comment on a Jira ticketTo comment on the ticket, use thecomment_ticketmethod:test=jira_helper.comment_ticket("XX-1234","test")print(test)Parameters:ticket_key: The unique key of the ticket you want to comment.comment_text: The text comment you want to post to the Jira ticket.Output:Checking existence of ticket:XX-1234...TicketXX-1234exists!Adding comment to ticket:XX-1234...Successfully added comment to ticketXX-1234. Comment URL:https://your-url.atlassian.net/browse/XX-1234?focusedCommentId=5820515#comment-5820515Return:https://your-url.atlassian.net/browse/XX-1234?focusedCommentId=5820515#comment-5820515/False6. Pass the JQL and get the ticket arrayTo query tickets using JQL, use thejql_ticketmethod:test=jira_helper.jql_ticket('project = "PRJ" and status = Triage and type != Epic')print(test)# It returns all ticketstest=jira_helper.jql_ticket('project = "PRJ" and status = Triage and type != Epic',5)print(test)# It returns 5 ticketsParameters:jql_query: Working JQL Query.max_results: Optional. If you passed the number it will return that number of array ticket.Output:Executing JQL query:project = "PRJ" and status = Triage and type != Epic...Fetched50tickets in this batch.FetchedXtickets in this batch.Total tickets found:XReturn:['XX-1234', 'XX-1235', ...]Atlassian Wiki1. Creating a wiki pageTo create wiki page, use thecreate_wiki_pagemethod:test=wiki_helper.create_wiki_page("SPACE","module test","test data",<parent_page_id>)print(test)Parameters:space_key: Key of the Confluence space where the new page will reside.title: Title of the new page.content: Content of the new page.parent_page_id: Optional parent page ID if the new page is to be a child.
Output:Creating Confluence page with titlemodule testin spaceSPACE, please wait...Pagemodule testcreated successfully! You can view it here:https://your-url.atlassian.net/wiki/spaces/SPACE/pages/<new_id>/module+test1Or error! with details!Return:https://your-url.atlassian.net/wiki/spaces/SPACE/pages/<new_id>/module+test1/False2. Duplicate a wiki pageTo duplicate wiki page, use theduplicate_wiki_pagemethod:test=wiki_helper.duplicate_wiki_page(<source_page_id>,"SPACE","module test1",<target_parent_page_id>)print(test)Parameters:source_page_id: ID of the source Confluence page to be duplicated.target_space_key: Key of the Confluence space where the duplicated page will reside.target_title: Title of the duplicated page.target_parent_page_id: Optional parent page ID if the duplicated page is to be a child.
Output:Initiating duplication of page with IDsource_page_idto spaceSPACEwith title 'module test1'...Successfully retrieved content from source page with IDsource_page_id.Creating Confluence page with titlemodule test1in spaceSPACE, please wait...Pagemodule test1created successfully! You can view it here:https://your-url.atlassian.net/wiki/spaces/SPACE/pages/<new_id>/module+test2Or error! with details!Return:https://your-url.atlassian.net/wiki/spaces/SPACE/pages/<new_id>/module+test1/False3. Create a wiki page from templateTo create a wiki page from template use thecreate_page_from_templatemethod:test=wiki_helper.create_page_from_template(<template_id>,"SPACE","from the template1",<parent_page_id>)print(test)Parameters:template_id: ID of the Confluence template to use.space_key: Key of the Confluence space where the new page will reside.title: Title of the new page.parent_page_id: Optional parent page ID if the new page is to be a child.
Output:Initiating creation of pagefrom the template1in spaceSPACEusing template IDtemplate_id...Successfully retrieved content from template with IDtemplate_id.Creating the new pagefrom the template1using the retrieved template content...Pagefrom the template1successfully created in spaceSPACE.Or error! with details!Return:https://your-url.atlassian.net/wiki/spaces/SPACE/pages/<new_id>/from+the+template1/False4. Move wiki page from one location to anotherTo move wiki page from one location to another location without changing title usemove_wiki_pagemethod:test=wiki_helper.move_wiki_page(<page_id>,"SPACE",'append',<target_parent_page_id>)print(test)Parameters:page_id: ID of the Confluence page to be moved.target_space_key: Key of the Confluence space where the moved page will reside.target_position: Position to place the moved page relative to the parent page (e.g.,append,above,below). Default isappend.target_parent_page_id: Optional ID of the parent page in which the page will be moved under.
Output:Initiating move of page with IDpage_id...Preparing to move pageduplicate module testto spaceSPACE.Executing move operation for pageduplicate module test...Successfully moved pageduplicate module testto spaceSPACE.Or error! with details!Return:https://your-url.atlassian.net/wiki/spaces/SPACE/pages/<same-id>/from+the+template1/False5. Check if wiki page existTo move wiki page from one location to another location without changing title usemove_wiki_pagemethod:test=wiki_helper.wiki_page_exists("pages name","SPACE")print(test)Parameters:title: Title of the Confluence wiki page.space_key: Key of the Confluence space.
Output:Checking if wiki pagepages nameexists in spaceSPACE...Wiki pagepages nameexists in spaceSPACE.Or error! with details!Return:True/False6. Retrieve all child pagesRecursively retrieve all descendant pages of a given parent page ID.test=wiki_helper.get_child_pages_recursive(<parent_id>)print(test)Parameters:parent_id: ID of the parent Confluence wiki page.
Output:The duration may vary depending on the number of child pages you have. Please wait...Or error! with details!Return:[{'id': '<child_page1>', 'title': 'Daniel Cave - Offboarding', 'parentid': '<parent_id>'},...]/False7. Get wiki page IDRetrieve the ID of a Confluence wiki page by its title.test=wiki_helper.get_page_id("page - name","SPACE")print(test)Parameters:title: Title of the Confluence wiki page.space_key: Key of the Confluence space to search in.
Output:Searching for page with title:page - namein space:SPACE...Page found! ID:123456Or error! with details!Return:123456\False8. Replace word in wikiReplace all occurrences of a string in a Confluence wiki page.test=wiki_helper.replace_in_page(123456,"this","that")print(test)Parameters:page_id: ID of the Confluence wiki page.from_string: String to be replaced.to_string: String to replace with.
Output:Fetching content of page ID:123456...Performing replacements...Page ID: 123456 updated successfully! / No occurrences ofthisfound in page ID:123456Or error! with details!Return:True\False9. Fetch tables from wikiFetch all tables from a Confluence wiki page.test=wiki_helper.get_tables_from_page(123456)print(test)Parameterpage_id: ID of the Confluence wiki page.Output:Fetching content of page ID: 123456...Performing replacements...Or error! with details!Return:{"table1": [{"FNAME": "Pavan", "MNAME": "H", "LNAME": "Bhatt"}, {"FNAME": "Pavan1", "MNAME": "H1", "LNAME": "Bhatt1"}], "table2": [{"FNAME": "Palak", "MNAME": "H", "LNAME": "Bhatt"}]}10. Replace the whole wiki pageReplace the entire Confluence wiki page with the new contenttest=wiki_helper.update_wiki_page(123456,'new content')print(test)Parameterpage_id: ID of the Confluence wiki page to be updated.new_content: New content to replace the existing content of the page.`Output:Fetching current data of page ID: 123456...Updating page with new content...Page ID: 123456 content replaced successfully!Or error! with details!Return:True\False11. Get parent page IDRetrieve the parent ID of a Confluence wiki page by passed page ID.test=wiki_helper.get_parent_page_id("123456")print(test)Parameterpage_id: ID of the Confluence wiki page.Output:Fetching parent page ID for page ID: 123456...Found parent page. ID: 654321Or error! with details!Return:654321\False12. Add Table of Content (TOC) in wiki pageAdd a Table of Contents (TOC) to a Confluence wiki page if it doesn't already have one.test=wiki_helper.add_toc_to_page("123456")print(test)Parameterpage_id: ID of the Confluence wiki page.Output:Checking and updating page ID: 226646659591 for TOC...Or error! with details!Return:TOC added successfully.\Failed to add TOC: with status_code\TOC already exists.Data Privacy Note🔒We respect your privacy: This module doesnotstore any of your data anywhere. It simply interacts with the Atlassian Jira API to perform the requested operations. Ensure you manage your connection details securely.Release NotesRelease 0.2.7 (08 Jan 2024)Introducedadd_toc_to_pageThis add table of content to the wiki page if not existUpdated theREADME.md- How to useadd_toc_to_pageRelease 0.2.6 (05 Jan 2024)Introducedget_parent_page_idThis gives the parent ID of the passed wiki page idUpdated theREADME.md- How to useget_parent_page_idRelease 0.2.5.4 (04 Jan 2024)Introducedupdate_wiki_pageThis replaces the entire wiki page with the new contentUpdated theREADME.md- How to useupdate_wiki_pageRelease 0.2.5.3 (04 Jan 2024)This is just for testing purpose. not to useRelease 0.2.5.2 (04 Jan 2024)Deleted due to potential bugRelease 0.2.5.1 (04 Jan 2024)Deleted due to potential bugRelease 0.2.5 (04 Jan 2024)Deleted due to potential bugRelease 0.2.4 (13 Oct 2023)Introducedget_tables_from_pageThis will help to fetch all the tables in JSON formatEasy to extract table! Happy days!Updated theREADME.md- How to useget_tables_from_pageRelease 0.2.3.1 (21 Sep 2023)Updated theREADME.md- How to useget_page_idandreplace_in_pageRelease 0.2.3 (21 Sep 2023)Confluence functionality addedGet wiki page IDget_page_idRelease 0.2.2.1 (21 Sep 2023)Extra output suppressed from wiki classConfluence functionality addedReplace word in wiki pagereplace_in_pageRelease 0.2.2 (20 Sep 2023)Updated theREADME.mdfor better understandingConfluence functionality addedGet child pages recursivelyget_child_pages_recursiveRelease 0.2.1 (20 Sep 2023) -Major ReleaseUpdated theREADME.mdfor better understandingFine-tuned the output to monitor the progressBetter return formatConfluence functionality addedCreating a wiki pagecreate_wiki_pageDuplicate a wiki pageduplicate_wiki_pageCreate a wiki page from templatecreate_page_from_templateMove wiki page from one location to anothermove_wiki_pageCheck if wiki page existwiki_page_existsRelease 0.2 (20 Sep 2023)Deleted due to potential bugRelease 0.1.4.1 (18 Sep 2023)Updated theREADME.mdfor better understanding.Release 0.1.4 (18 Sep 2023)Suppressed extra output and focused on specific output of functions for smoother integrationUpdated theREADME.mdwith output detailsSearch a ticketif_exist_ticketComment on a ticketcomment_ticketPass the JQLjql_ticketRelease 0.1.3 (18 Sep 2023)Deleted due to potential bugRelease 0.1.2.1 (16 Sep 2023)Updated theREADME.mdformatRelease 0.1.2 (16 Sep 2023)Check Jira ticket existif_exist_ticketaddedUpdated theREADME.mdformatRelease 0.1.1 (16 Sep 2023)Transition a Jira ticket (Can pass transition ID too)transition_ticketModifiedREADME.mdfor clarity use of this moduleRelease 0.1 (16 Sep 2023)Create a Jira ticketcreate_ticketDelete a Jira ticketdelete_ticketTransition a Jira ticket (Strict to Transition Name)transition_ticket