atlassian-python-api 4.0.2__py3-none-any.whl → 4.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- atlassian/VERSION +1 -1
- atlassian/__init__.py +7 -1
- atlassian/assets.py +626 -0
- atlassian/bamboo.py +1 -0
- atlassian/bitbucket/__init__.py +0 -1
- atlassian/bitbucket/base.py +1 -1
- atlassian/bitbucket/cloud/__init__.py +5 -1
- atlassian/bitbucket/cloud/base.py +2 -2
- atlassian/bitbucket/cloud/repositories/deploymentEnvironments.py +1 -1
- atlassian/cloud_admin.py +85 -0
- atlassian/confluence.py +131 -28
- atlassian/jira.py +84 -37
- atlassian/request_utils.py +3 -28
- atlassian/rest_client.py +8 -2
- {atlassian_python_api-4.0.2.dist-info → atlassian_python_api-4.0.4.dist-info}/METADATA +1 -2
- {atlassian_python_api-4.0.2.dist-info → atlassian_python_api-4.0.4.dist-info}/RECORD +19 -18
- {atlassian_python_api-4.0.2.dist-info → atlassian_python_api-4.0.4.dist-info}/WHEEL +1 -1
- {atlassian_python_api-4.0.2.dist-info → atlassian_python_api-4.0.4.dist-info}/licenses/LICENSE +0 -0
- {atlassian_python_api-4.0.2.dist-info → atlassian_python_api-4.0.4.dist-info}/top_level.txt +0 -0
atlassian/cloud_admin.py
CHANGED
|
@@ -16,9 +16,94 @@ class CloudAdminOrgs(AtlassianRestAPI):
|
|
|
16
16
|
super(CloudAdminOrgs, self).__init__(url=ADMIN_URL, *args, **kwargs)
|
|
17
17
|
|
|
18
18
|
def get_organizations(self):
|
|
19
|
+
"""
|
|
20
|
+
Returns a list of your organizations (based on your API key).
|
|
21
|
+
:return:
|
|
22
|
+
"""
|
|
19
23
|
url = self.resource_url("orgs")
|
|
20
24
|
return self.get(url)
|
|
21
25
|
|
|
26
|
+
def get_organization(self, org_id):
|
|
27
|
+
"""
|
|
28
|
+
Returns information about a single organization by ID
|
|
29
|
+
:param org_id:
|
|
30
|
+
:return:
|
|
31
|
+
"""
|
|
32
|
+
url = self.resource_url(f"orgs/{org_id}")
|
|
33
|
+
return self.get(url)
|
|
34
|
+
|
|
35
|
+
def get_managed_accounts_in_organization(self, org_id, cursor=None):
|
|
36
|
+
"""
|
|
37
|
+
Returns a list of accounts managed by the organization
|
|
38
|
+
:param org_id:
|
|
39
|
+
:param cursor:
|
|
40
|
+
:return:
|
|
41
|
+
"""
|
|
42
|
+
url = self.resource_url(f"orgs/{org_id}/users")
|
|
43
|
+
params = {}
|
|
44
|
+
if cursor:
|
|
45
|
+
params["cursor"] = cursor
|
|
46
|
+
return self.get(url, params=params)
|
|
47
|
+
|
|
48
|
+
def search_users_in_organization(
|
|
49
|
+
self,
|
|
50
|
+
org_id,
|
|
51
|
+
account_ids=None,
|
|
52
|
+
account_types=None,
|
|
53
|
+
account_statuses=None,
|
|
54
|
+
name_or_nicknames=None,
|
|
55
|
+
email_usernames=None,
|
|
56
|
+
email_domains=None,
|
|
57
|
+
is_suspended=None,
|
|
58
|
+
cursor=None,
|
|
59
|
+
limit=10000,
|
|
60
|
+
expand=None,
|
|
61
|
+
):
|
|
62
|
+
"""
|
|
63
|
+
Returns a list of accounts in the organization that match the search criteria.
|
|
64
|
+
The API is available for customers using the new user management experience only.
|
|
65
|
+
How the new user management experience works
|
|
66
|
+
Returns a list of users within an organization,
|
|
67
|
+
offering search functionality through multiple parameters for more precise results.
|
|
68
|
+
:param org_id:
|
|
69
|
+
:param account_ids: Unique ID of the users account. The format is [a-zA-Z0-9_|-:]{1,128}
|
|
70
|
+
:param account_types: The type of account Valid values: atlassian, customer, app
|
|
71
|
+
:param account_statuses: The lifecycle status of the account
|
|
72
|
+
:param name_or_nicknames:
|
|
73
|
+
:param email_usernames:
|
|
74
|
+
:param email_domains:
|
|
75
|
+
:param is_suspended: Suspended users with no access. This is independent of the user account status
|
|
76
|
+
:param cursor: Starting point marker for page result retrieval
|
|
77
|
+
:param limit: The number of items to return. Default = max = 10000
|
|
78
|
+
:param expand: Valid values: NAME, EMAIL, EMAIL_VERIFIED, PRODUCT_LAST_ACCESS, GROUPS
|
|
79
|
+
:return:
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
url = self.resource_url(f"orgs/{org_id}/users/search")
|
|
83
|
+
params = {}
|
|
84
|
+
if cursor:
|
|
85
|
+
params["cursor"] = cursor
|
|
86
|
+
if limit:
|
|
87
|
+
params["limit"] = limit
|
|
88
|
+
if account_ids:
|
|
89
|
+
params["accountIds"] = account_ids
|
|
90
|
+
if account_types:
|
|
91
|
+
params["accountTypes"] = account_types
|
|
92
|
+
if account_statuses:
|
|
93
|
+
params["accountStatuses"] = account_statuses
|
|
94
|
+
if name_or_nicknames:
|
|
95
|
+
params["nameOrNicknames"] = name_or_nicknames
|
|
96
|
+
if email_usernames:
|
|
97
|
+
params["emailUsernames"] = email_usernames
|
|
98
|
+
if email_domains:
|
|
99
|
+
params["emailDomains"] = email_domains
|
|
100
|
+
if is_suspended:
|
|
101
|
+
params["isSuspended"] = is_suspended
|
|
102
|
+
if expand:
|
|
103
|
+
params["expand"] = expand
|
|
104
|
+
|
|
105
|
+
return self.get(url, params=params)
|
|
106
|
+
|
|
22
107
|
|
|
23
108
|
class CloudAdminUsers(AtlassianRestAPI):
|
|
24
109
|
def __init__(self, admin_api_key, *args, **kwargs):
|
atlassian/confluence.py
CHANGED
|
@@ -647,24 +647,80 @@ class Confluence(AtlassianRestAPI):
|
|
|
647
647
|
content_type="page",
|
|
648
648
|
):
|
|
649
649
|
"""
|
|
650
|
-
|
|
650
|
+
Retrieve all pages from a Confluence space.
|
|
651
651
|
|
|
652
|
-
:param space:
|
|
653
|
-
:param start: OPTIONAL: The
|
|
654
|
-
:param limit: OPTIONAL: The
|
|
655
|
-
|
|
656
|
-
:param
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
652
|
+
:param space: The space key to fetch pages from.
|
|
653
|
+
:param start: OPTIONAL: The starting point of the collection. Default: 0.
|
|
654
|
+
:param limit: OPTIONAL: The maximum number of pages per request. Default: 50.
|
|
655
|
+
:param status: OPTIONAL: Filter pages by status ('current', 'trashed', 'any'). Default: None.
|
|
656
|
+
:param expand: OPTIONAL: Comma-separated list of properties to expand. Default: history,space,version.
|
|
657
|
+
:param content_type: OPTIONAL: The content type to return ('page', 'blogpost'). Default: page.
|
|
658
|
+
:return: List containing all pages from the specified space.
|
|
659
|
+
"""
|
|
660
|
+
all_pages = [] # Initialize an empty list to store all pages
|
|
661
|
+
while True:
|
|
662
|
+
# Fetch a single batch of pages
|
|
663
|
+
response = self.get_all_pages_from_space_raw(
|
|
664
|
+
space=space,
|
|
665
|
+
start=start,
|
|
666
|
+
limit=limit,
|
|
667
|
+
status=status,
|
|
668
|
+
expand=expand,
|
|
669
|
+
content_type=content_type,
|
|
670
|
+
)
|
|
671
|
+
|
|
672
|
+
# Extract results from the response
|
|
673
|
+
results = response.get("results", [])
|
|
674
|
+
all_pages.extend(results) # Add the current batch of pages to the list
|
|
675
|
+
|
|
676
|
+
# Break the loop if no more pages are available
|
|
677
|
+
if len(results) < limit:
|
|
678
|
+
break
|
|
679
|
+
|
|
680
|
+
# Increment the start index for the next batch
|
|
681
|
+
start += limit
|
|
682
|
+
return all_pages
|
|
683
|
+
|
|
684
|
+
def get_all_pages_from_space_as_generator(
|
|
685
|
+
self,
|
|
686
|
+
space,
|
|
687
|
+
start=0,
|
|
688
|
+
limit=50,
|
|
689
|
+
status=None,
|
|
690
|
+
expand="history,space,version",
|
|
691
|
+
content_type="page",
|
|
692
|
+
):
|
|
693
|
+
"""
|
|
694
|
+
Retrieve all pages from a Confluence space using pagination.
|
|
695
|
+
|
|
696
|
+
:param space: The space key to fetch pages from.
|
|
697
|
+
:param start: OPTIONAL: The starting point of the collection. Default: 0.
|
|
698
|
+
:param limit: OPTIONAL: The maximum number of pages per request. Default: 50.
|
|
699
|
+
:param status: OPTIONAL: Filter pages by status ('current', 'trashed', 'any'). Default: None.
|
|
700
|
+
:param expand: OPTIONAL: Comma-separated list of properties to expand. Default: history,space,version.
|
|
701
|
+
:param content_type: OPTIONAL: The content type to return ('page', 'blogpost'). Default: page.
|
|
702
|
+
:return: Generator yielding pages one by one.
|
|
664
703
|
"""
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
704
|
+
while True:
|
|
705
|
+
# Fetch a single batch of pages
|
|
706
|
+
response = self.get_all_pages_from_space_raw(
|
|
707
|
+
space=space,
|
|
708
|
+
start=start,
|
|
709
|
+
limit=limit,
|
|
710
|
+
status=status,
|
|
711
|
+
expand=expand,
|
|
712
|
+
content_type=content_type,
|
|
713
|
+
)
|
|
714
|
+
|
|
715
|
+
# Extract results from the response
|
|
716
|
+
results = response.get("results", [])
|
|
717
|
+
yield from results # Yield each page individually
|
|
718
|
+
|
|
719
|
+
# Break the loop if no more pages are available
|
|
720
|
+
if len(results) < limit:
|
|
721
|
+
break
|
|
722
|
+
start += limit
|
|
723
|
+
pass
|
|
668
724
|
|
|
669
725
|
def get_all_pages_from_space_trash(self, space, start=0, limit=500, status="trashed", content_type="page"):
|
|
670
726
|
"""
|
|
@@ -1238,7 +1294,7 @@ class Confluence(AtlassianRestAPI):
|
|
|
1238
1294
|
def get_all_spaces(
|
|
1239
1295
|
self,
|
|
1240
1296
|
start=0,
|
|
1241
|
-
limit=
|
|
1297
|
+
limit=50,
|
|
1242
1298
|
expand=None,
|
|
1243
1299
|
space_type=None,
|
|
1244
1300
|
space_status=None,
|
|
@@ -1266,6 +1322,42 @@ class Confluence(AtlassianRestAPI):
|
|
|
1266
1322
|
params["status"] = space_status
|
|
1267
1323
|
return self.get(url, params=params)
|
|
1268
1324
|
|
|
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
|
+
|
|
1269
1361
|
def add_comment(self, page_id, text):
|
|
1270
1362
|
"""
|
|
1271
1363
|
Add comment into page
|
|
@@ -1410,16 +1502,15 @@ class Confluence(AtlassianRestAPI):
|
|
|
1410
1502
|
content_type = self.content_types.get(extension, "application/binary")
|
|
1411
1503
|
|
|
1412
1504
|
with open(filename, "rb") as infile:
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
)
|
|
1505
|
+
return self.attach_content(
|
|
1506
|
+
infile,
|
|
1507
|
+
name,
|
|
1508
|
+
content_type,
|
|
1509
|
+
page_id=page_id,
|
|
1510
|
+
title=title,
|
|
1511
|
+
space=space,
|
|
1512
|
+
comment=comment,
|
|
1513
|
+
)
|
|
1423
1514
|
|
|
1424
1515
|
def download_attachments_from_page(self, page_id, path=None, start=0, limit=50, filename=None, to_memory=False):
|
|
1425
1516
|
"""
|
|
@@ -3312,9 +3403,21 @@ class Confluence(AtlassianRestAPI):
|
|
|
3312
3403
|
:param group_name: str - name of group to add user to
|
|
3313
3404
|
:return: Current state of the group
|
|
3314
3405
|
"""
|
|
3315
|
-
url = "rest/api/user
|
|
3406
|
+
url = f"rest/api/user/{username}/group/{group_name}"
|
|
3316
3407
|
return self.put(url)
|
|
3317
3408
|
|
|
3409
|
+
def remove_user_from_group(self, username, group_name):
|
|
3410
|
+
"""
|
|
3411
|
+
Remove the given {@link User} identified by username from the given {@link Group} identified by groupName.
|
|
3412
|
+
This method is idempotent i.e. if the membership is not present then no action will be taken.
|
|
3413
|
+
|
|
3414
|
+
:param username: str - username of user to add to group
|
|
3415
|
+
:param group_name: str - name of group to add user to
|
|
3416
|
+
:return: Current state of the group
|
|
3417
|
+
"""
|
|
3418
|
+
url = f"rest/api/user/{username}/group/{group_name}"
|
|
3419
|
+
return self.delete(url)
|
|
3420
|
+
|
|
3318
3421
|
# Space Permissions
|
|
3319
3422
|
def get_all_space_permissions(self, space_key):
|
|
3320
3423
|
"""
|