Skip to content

Commit 3f33de8

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master'
2 parents 00c18e0 + 85458f1 commit 3f33de8

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed

atlassian/confluence.py

Lines changed: 41 additions & 0 deletions
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) #

atlassian/rest_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,9 @@ def raise_for_status(self, response):
537537
else:
538538
error_msg_list = j.get("errorMessages", list())
539539
errors = j.get("errors", dict())
540-
if isinstance(errors, dict):
540+
if isinstance(errors, dict) and "message" not in errors:
541+
error_msg_list.extend(errors.values())
542+
elif isinstance(errors, dict) and "message" in errors:
541543
error_msg_list.append(errors.get("message", ""))
542544
elif isinstance(errors, list):
543545
error_msg_list.extend([v.get("message", "") if isinstance(v, dict) else v for v in errors])

docs/confluence.rst

Lines changed: 15 additions & 0 deletions
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

Lines changed: 20 additions & 0 deletions
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)