Skip to content

Commit b3f6d77

Browse files
committed
Cloud admin rest api methods
1 parent 41e7b64 commit b3f6d77

File tree

3 files changed

+98
-1
lines changed

3 files changed

+98
-1
lines changed

atlassian/cloud_admin.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,94 @@ def __init__(self, admin_api_key, *args, **kwargs):
1616
super(CloudAdminOrgs, self).__init__(url=ADMIN_URL, *args, **kwargs)
1717

1818
def get_organizations(self):
19+
"""
20+
Returns a list of your organizations (based on your API key).
21+
:return:
22+
"""
1923
url = self.resource_url("orgs")
2024
return self.get(url)
2125

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+
22107

23108
class CloudAdminUsers(AtlassianRestAPI):
24109
def __init__(self, admin_api_key, *args, **kwargs):

docs/cloud_admin.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ CloudAdminOrgs
99
# Returns a list of your organizations
1010
cloud_admin_orgs.get_organizations()
1111
12+
# Returns information about a single organization by ID
13+
cloud_admin_orgs.get_organization(org_id)
14+
15+
# Returns a list of accounts managed by the organization
16+
cloud_admin_orgs.get_managed_accounts_in_organization(org_id, cursor=None)
17+
18+
# Returns a list of accounts in the organization that match the search criteria.
19+
cloud_admin_orgs.search_users_in_organization(org_id, account_ids=None, account_types=None,account_statuses=None,
20+
name_or_nicknames=None, email_usernames=None, email_domains=None, is_suspended=None,
21+
cursor=None, limit=10000, expand=None)
22+
23+
#
1224
1325
CloudAdminUsers
1426
---------------

docs/crowd.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ Healthcheck
8282
crowd.check_plugin_manager_status()
8383
8484
# Update plugin license
85-
crowd.update_plugin_license(plugin_key, license_key)
85+
crowd.update_plugin_license(plugin_key, license_key)

0 commit comments

Comments
 (0)