Skip to content

Commit 4add0ae

Browse files
Caramba77Gagnon, Sylvaingonchik
authored
[Confluence] Obtaining license information, max users and count (atlassian-api#932)
* [Confluence] Add functions to get license informations * [Confluence] Functions for license information - comments corrections * Renamed function get_license_usercount to get_license_user_count Co-authored-by: Gagnon, Sylvain <gagnon.sylvain@hydroquebec.com> Co-authored-by: Gonchik Tsymzhitov <gonchik.tsymzhitov@gmail.com>
1 parent c104fa6 commit 4add0ae

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

atlassian/confluence.py

+44
Original file line numberDiff line numberDiff line change
@@ -2669,3 +2669,47 @@ def clean_jira_metadata_cache(self, global_id):
26692669
url = "rest/jira-metadata/1.0/metadata/cache"
26702670
params = {"globalId": global_id}
26712671
return self.delete(url, params=params)
2672+
2673+
def get_license_details(self):
2674+
"""
2675+
Returns the license detailed information
2676+
"""
2677+
url = "rest/license/1.0/license/details"
2678+
return self.get(url)
2679+
2680+
def get_license_user_count(self):
2681+
"""
2682+
Returns the total used seats in the license
2683+
"""
2684+
url = "rest/license/1.0/license/userCount"
2685+
return self.get(url)
2686+
2687+
def get_license_remaining(self):
2688+
"""
2689+
Returns the available license seats remaining
2690+
"""
2691+
url = "rest/license/1.0/license/remainingSeats"
2692+
return self.get(url)
2693+
2694+
def get_license_max_users(self):
2695+
"""
2696+
Returns the license max users
2697+
"""
2698+
url = "rest/license/1.0/license/maxUsers"
2699+
return self.get(url)
2700+
2701+
def raise_for_status(self, response):
2702+
"""
2703+
Checks the response for an error status and raises an exception with the error message provided by the server
2704+
:param response:
2705+
:return:
2706+
"""
2707+
if 400 <= response.status_code < 600:
2708+
try:
2709+
j = response.json()
2710+
error_msg = j["message"]
2711+
except Exception:
2712+
response.raise_for_status()
2713+
else:
2714+
raise HTTPError(error_msg, response=response)
2715+

0 commit comments

Comments
 (0)