Skip to content

Commit 85458f1

Browse files
authored
[Confluence] added new endpoints for confluence whiteboards + docs + 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>
1 parent 27275fe commit 85458f1

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

atlassian/confluence.py

+41
Original file line numberDiff line numberDiff line change
@@ -2877,6 +2877,47 @@ def audit(
28772877
params["searchString"] = search_string
28782878
return self.get(url, params=params)
28792879

2880+
"""
2881+
##############################################################################################
2882+
# Confluence whiteboards (cloud only!) #
2883+
##############################################################################################
2884+
"""
2885+
2886+
def create_whiteboard(self, spaceId, title=None, parentId=None):
2887+
url = "/api/v2/whiteboards"
2888+
data = {"spaceId": spaceId}
2889+
if title is not None:
2890+
data["title"] = title
2891+
if parentId is not None:
2892+
data["parentId"] = parentId
2893+
return self.post(url, data=data)
2894+
2895+
def get_whiteboard(self, whiteboard_id):
2896+
try:
2897+
url = f"/api/v2/whiteboards/{whiteboard_id}"
2898+
return self.get(url)
2899+
except HTTPError as e:
2900+
# Default 404 error handling is ambiguous
2901+
if e.response.status_code == 404:
2902+
raise ApiValueError(
2903+
"Whiteboard not found. Check confluence instance url and/or if whiteboard id exists", reason=e
2904+
)
2905+
2906+
raise
2907+
2908+
def delete_whiteboard(self, whiteboard_id):
2909+
try:
2910+
url = f"/api/v2/whiteboards/{whiteboard_id}"
2911+
return self.delete(url)
2912+
except HTTPError as e:
2913+
# # Default 404 error handling is ambiguous
2914+
if e.response.status_code == 404:
2915+
raise ApiValueError(
2916+
"Whiteboard not found. Check confluence instance url and/or if whiteboard id exists", reason=e
2917+
)
2918+
2919+
raise
2920+
28802921
"""
28812922
##############################################################################################
28822923
# Team Calendars REST API implements (https://jira.atlassian.com/browse/CONFSERVER-51003) #

docs/confluence.rst

+15
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ Page actions
161161
# Get regex matches from Confluence page
162162
confluence.scrap_regex_from_page(page_id, regex)
163163
164+
Confluence Whiteboards
165+
----------------------
166+
167+
.. code-block:: python
168+
169+
# Create new whiteboard - cloud only
170+
confluence.create_whiteboard(spaceId, title=None, parentId=None)
171+
172+
# Delete existing whiteboard - cloud only
173+
confluence.delete_whiteboard(whiteboard_id)
174+
175+
# Get whiteboard by id - cloud only!
176+
confluence.get_whiteboard(whiteboard_id)
177+
178+
164179
Template actions
165180
----------------
166181

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from atlassian import Confluence
2+
3+
confluence = Confluence(
4+
url="<instance_url>",
5+
username="<atlassian_username>",
6+
password="api_key",
7+
)
8+
"""
9+
This is example on how to use confluence whiteboard endponds
10+
Currently only available on confluence cloud
11+
"""
12+
# create whiteboard. First parameter is a spaceID (not spacekey!),
13+
# second param is a name of whiteboard (optional), third one is a parent pageid (optional)
14+
confluence.create_whiteboard("42342", "My whiteboard", "545463")
15+
16+
# To delete of get whiteboard, use whiteboard id
17+
# https://<instance_name>/wiki/spaces/<space_key>/whiteboard/<whiteboard_id>
18+
# Deleting a whiteboard moves the whiteboard to the trash, where it can be restored later
19+
confluence.delete_whiteboard("42342")
20+
confluence.get_whiteboard("42342")

0 commit comments

Comments
 (0)