Skip to content

Commit ceaf357

Browse files
committed
Confluence: Add space related methods
1 parent 9181fe1 commit ceaf357

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

atlassian/confluence.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,42 @@ def get_all_spaces(
13221322
params["status"] = space_status
13231323
return self.get(url, params=params)
13241324

1325+
def archive_space(self, space_key):
1326+
"""
1327+
Archive space
1328+
:param space_key:
1329+
:return:
1330+
"""
1331+
url = f"rest/api/space/{space_key}/archive"
1332+
return self.put(url)
1333+
1334+
def get_trashed_contents_by_space(self, space_key, cursor=None, expand=None, limit=100):
1335+
"""
1336+
Get trashed contents by space
1337+
:param space_key:
1338+
:param cursor:
1339+
:param expand:
1340+
:param limit:
1341+
:return:
1342+
"""
1343+
url = f"rest/api/space/{space_key}/content/trash"
1344+
params = {"limit": limit}
1345+
if cursor:
1346+
params["cursor"] = cursor
1347+
if expand:
1348+
params["expand"] = expand
1349+
return self.get(url, params=params)
1350+
1351+
def remove_trashed_contents_by_space(self, space_key):
1352+
"""
1353+
Remove all content from the trash in the given space,
1354+
deleting them permanently.Example request URI:
1355+
:param space_key:
1356+
:return:
1357+
"""
1358+
url = f"rest/api/space/{space_key}/content/trash"
1359+
return self.delete(url)
1360+
13251361
def add_comment(self, page_id, text):
13261362
"""
13271363
Add comment into page

docs/confluence.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,26 @@ Get spaces info
246246
# Get Space export download url
247247
confluence.get_space_export(space_key, export_type)
248248
249+
Space
250+
-----
251+
252+
.. code-block:: python
253+
254+
# Archive the given Space identified by spaceKey.
255+
# This method is idempotent i.e.,
256+
# if the Space is already archived then no action will be taken.
257+
confluence.archive_space(space_key)
258+
259+
# Get trash contents of space
260+
confluence.get_trashed_contents_by_space(space_key, cursor=None, expand=None, limit=100)
261+
262+
# Remove all trash contents of space
263+
confluence.remove_trashed_contents_by_space(space_key)
264+
265+
266+
267+
268+
249269
Get space permissions
250270
---------------------
251271

0 commit comments

Comments
 (0)