Skip to content

Commit

Permalink
added confluence whiteboard endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
gkowalc committed Apr 21, 2024
1 parent 8233f84 commit fd3c1b6
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 12 deletions.
24 changes: 12 additions & 12 deletions atlassian/confluence.py
Original file line number Diff line number Diff line change
Expand Up @@ -2878,14 +2878,13 @@ def audit(
return self.get(url, params=params)

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

def create_whiteboard(self, spaceId, title=None, parentId=None):
# Use spaceId, not space key.
url = '/api/v2/whiteboards'
url = "/api/v2/whiteboards"
data = {"spaceId": spaceId}
if title is not None:
data["title"] = title
Expand All @@ -2895,26 +2894,27 @@ def create_whiteboard(self, spaceId, title=None, parentId=None):

def get_whiteboard(self, whiteboard_id):
try:
url = f'/api/v2/whiteboards/{whiteboard_id}'
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 ApiValueError(
"Whiteboard not found. Check confluence instance url and/or if whiteboard id exists", reason=e
)

raise


def delete_whiteboard(self, whiteboard_id):
# Deleting a whiteboard moves the whiteboard to the trash, where it can be restored later
try:
url = f'/api/v2/whiteboards/{whiteboard_id}'
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)
"Whiteboard not found. Check confluence instance url and/or if whiteboard id exists", reason=e
)

raise

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 fd3c1b6

Please sign in to comment.