Skip to content

Commit 89f9858

Browse files
Gonchik TsymzhitovGonchik Tsymzhitov
authored andcommitted
1.15.2 version and add audit records methods
1 parent 4f4831c commit 89f9858

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

atlassian/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1.15.1
1+
1.15.2
22

atlassian/jira.py

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ def get_all_application_roles(self):
324324
:return:
325325
"""
326326
url = 'rest/api/2/applicationrole'
327-
328-
return self.get(url)
327+
return self.get(url) or {}
329328

330329
def get_application_role(self, role_key):
331330
"""
@@ -334,8 +333,7 @@ def get_application_role(self, role_key):
334333
:return:
335334
"""
336335
url = 'rest/api/2/applicationrole/{}'.format(role_key)
337-
338-
return self.get(url)
336+
return self.get(url) or {}
339337

340338
def projects(self, included_archived=None):
341339
"""Returns all projects which are visible for the currently logged in user.
@@ -2498,4 +2496,45 @@ def health_check(self):
24982496
if not response:
24992497
# check as support tools
25002498
response = self.get('rest/supportHealthCheck/1.0/check/')
2501-
return response
2499+
return response
2500+
2501+
# Audit Records
2502+
def get_audit_records(self, offset=None, limit=None, filter=None, from_date=None, to_date=None):
2503+
"""
2504+
Returns auditing records filtered using provided parameters
2505+
:param offset: the number of record from which search starts
2506+
:param limit: maximum number of returned results (if is limit is <= 0 or > 1000,
2507+
it will be set do default value: 1000)
2508+
:param filter: string = text query; each record that will be returned
2509+
must contain the provided text in one of its fields
2510+
:param from: string - timestamp in past; 'from' must be less or equal 'to',
2511+
otherwise the result set will be empty only records that
2512+
where created in the same moment or after the 'from' timestamp will be provided in response
2513+
:param to: string - timestamp in past; 'from' must be less or equal 'to',
2514+
otherwise the result set will be empty only records that
2515+
where created in the same moment or earlier than the 'to'
2516+
timestamp will be provided in response
2517+
:return:
2518+
"""
2519+
params = {}
2520+
if offset:
2521+
params["offset"] = offset
2522+
if limit:
2523+
params["limit"] = limit
2524+
if filter:
2525+
params["filter"] = filter
2526+
if from_date:
2527+
params["from"] = from_date
2528+
if to_date:
2529+
params["to"] = to_date
2530+
url = "rest/api/2/auditing/record"
2531+
return self.get(url, params=params) or {}
2532+
2533+
def post_audit_record(self, audit_record):
2534+
"""
2535+
Store a record in Audit Log
2536+
:param audit_record: json with compat https://docs.atlassian.com/jira/REST/schema/audit-record#
2537+
:return:
2538+
"""
2539+
url = "rest/api/2/auditing/record"
2540+
return self.post(url, data=audit_record)

0 commit comments

Comments
 (0)