Skip to content

Commit

Permalink
[Confluence] added new endpoints for confluence whiteboards + docs + …
Browse files Browse the repository at this point in the history
…example (#1377)

* fixing minor issue in scrap_regex_from_issue method

* new Confluence method scrap_regex_from_page+ docs + examples

* added method get_attachments_ids_from_page to jira.py

* added method download_attachments_from_issue

* refactoring download_all_attachments_from_page method

* finished download_attachments_from_issue

* added two new methods: download_attachments.from_issue  and get_attachments_ids_from_issue

* added fix to the infinitive loop

* adding reursion depth condition

* fixed reursion depth condition

* added update4d jira.py with new method + docs +example

* added update4d jira.py with new method + docs +exampl

* fix flake8 issue

* hotfix get_issue_tree_recursive

* added expand to get_issue method, added new method

* get_issue_status_changelog method

* included param expand in get_issue method decription

* WIP PR changes - #1357

* improving index.rst docs #1365

* added whiteboard methods

* added confluence whiteboard endpoints

---------

Co-authored-by: gkowalc <>
Co-authored-by: Greg <gkowalc>
  • Loading branch information
gkowalc authored Apr 22, 2024
1 parent 27275fe commit 85458f1
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
41 changes: 41 additions & 0 deletions atlassian/confluence.py
Original file line number Diff line number Diff line change
Expand Up @@ -2877,6 +2877,47 @@ def audit(
params["searchString"] = search_string
return self.get(url, params=params)

"""
##############################################################################################
# Confluence whiteboards (cloud only!) #
##############################################################################################
"""

def create_whiteboard(self, spaceId, title=None, parentId=None):
url = "/api/v2/whiteboards"
data = {"spaceId": spaceId}
if title is not None:
data["title"] = title
if parentId is not None:
data["parentId"] = parentId
return self.post(url, data=data)

def get_whiteboard(self, whiteboard_id):
try:
url = f"/api/v2/whiteboards/{whiteboard_id}"
return self.get(url)
except HTTPError as e:
# Default 404 error handling is ambiguous
if e.response.status_code == 404:
raise ApiValueError(
"Whiteboard not found. Check confluence instance url and/or if whiteboard id exists", reason=e
)

raise

def delete_whiteboard(self, whiteboard_id):
try:
url = f"/api/v2/whiteboards/{whiteboard_id}"
return self.delete(url)
except HTTPError as e:
# # Default 404 error handling is ambiguous
if e.response.status_code == 404:
raise ApiValueError(
"Whiteboard not found. Check confluence instance url and/or if whiteboard id exists", reason=e
)

raise

"""
##############################################################################################
# Team Calendars REST API implements (https://jira.atlassian.com/browse/CONFSERVER-51003) #
Expand Down
15 changes: 15 additions & 0 deletions docs/confluence.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@ Page actions
# Get regex matches from Confluence page
confluence.scrap_regex_from_page(page_id, regex)
Confluence Whiteboards
----------------------

.. code-block:: python
# Create new whiteboard - cloud only
confluence.create_whiteboard(spaceId, title=None, parentId=None)
# Delete existing whiteboard - cloud only
confluence.delete_whiteboard(whiteboard_id)
# Get whiteboard by id - cloud only!
confluence.get_whiteboard(whiteboard_id)
Template actions
----------------

Expand Down
20 changes: 20 additions & 0 deletions examples/confluence/confluence_whiteboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from atlassian import Confluence

confluence = Confluence(
url="<instance_url>",
username="<atlassian_username>",
password="api_key",
)
"""
This is example on how to use confluence whiteboard endponds
Currently only available on confluence cloud
"""
# create whiteboard. First parameter is a spaceID (not spacekey!),
# second param is a name of whiteboard (optional), third one is a parent pageid (optional)
confluence.create_whiteboard("42342", "My whiteboard", "545463")

# To delete of get whiteboard, use whiteboard id
# https://<instance_name>/wiki/spaces/<space_key>/whiteboard/<whiteboard_id>
# Deleting a whiteboard moves the whiteboard to the trash, where it can be restored later
confluence.delete_whiteboard("42342")
confluence.get_whiteboard("42342")

0 comments on commit 85458f1

Please sign in to comment.