Skip to content

Commit 40a6b36

Browse files
Gonchik TsymzhitovGonchik Tsymzhitov
authored andcommitted
Conlfunece: Subtree method
1 parent fa9e320 commit 40a6b36

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

atlassian/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.14.2
1+
1.14.3

atlassian/confluence.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,3 +1321,18 @@ def add_user_to_group(self, username, group_name):
13211321
data = {'name': username}
13221322

13231323
return self.post(url, params=params, data=data)
1324+
1325+
def get_subtree_of_content_ids(self, page_id):
1326+
"""
1327+
Get sub tree of page ids
1328+
:param page_id:
1329+
:return: Set of page ID
1330+
"""
1331+
output = list()
1332+
output.append(page_id)
1333+
children_pages = self.get_page_child_by_type(page_id)
1334+
for page in children_pages:
1335+
child_subtree = self.get_subtree_of_content_ids(self, page.get('id'))
1336+
if child_subtree:
1337+
output.extend([p for p in child_subtree])
1338+
return set(output)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# coding=utf-8
2+
from atlassian import Confluence
3+
4+
"""
5+
This example shows how to clean page versions for subtree of pages
6+
"""
7+
8+
CONFLUENCE_URL = "confluence.example.com"
9+
CONFLUENCE_LOGIN = "gonchik.tsymzhitov"
10+
CONFLUENCE_PASSWORD = "passwordpassword"
11+
12+
if __name__ == '__main__':
13+
confluence = Confluence(
14+
url=CONFLUENCE_URL,
15+
username=CONFLUENCE_LOGIN,
16+
password=CONFLUENCE_PASSWORD,
17+
timeout=190
18+
)
19+
remained_count = 1
20+
21+
subtree = confluence.get_subtree_of_content_ids('123123')
22+
for page_id in subtree:
23+
confluence.remove_page_history_keep_version(page_id=page_id, keep_last_versions=remained_count)

0 commit comments

Comments
 (0)