Skip to content

Commit

Permalink
1.15.2 version and add audit records methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonchik Tsymzhitov authored and Gonchik Tsymzhitov committed Feb 5, 2020
1 parent 4f4831c commit 89f9858
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
2 changes: 1 addition & 1 deletion atlassian/VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1.15.1
1.15.2

49 changes: 44 additions & 5 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,7 @@ def get_all_application_roles(self):
:return:
"""
url = 'rest/api/2/applicationrole'

return self.get(url)
return self.get(url) or {}

def get_application_role(self, role_key):
"""
Expand All @@ -334,8 +333,7 @@ def get_application_role(self, role_key):
:return:
"""
url = 'rest/api/2/applicationrole/{}'.format(role_key)

return self.get(url)
return self.get(url) or {}

def projects(self, included_archived=None):
"""Returns all projects which are visible for the currently logged in user.
Expand Down Expand Up @@ -2498,4 +2496,45 @@ def health_check(self):
if not response:
# check as support tools
response = self.get('rest/supportHealthCheck/1.0/check/')
return response
return response

# Audit Records
def get_audit_records(self, offset=None, limit=None, filter=None, from_date=None, to_date=None):
"""
Returns auditing records filtered using provided parameters
:param offset: the number of record from which search starts
:param limit: maximum number of returned results (if is limit is <= 0 or > 1000,
it will be set do default value: 1000)
:param filter: string = text query; each record that will be returned
must contain the provided text in one of its fields
:param from: string - timestamp in past; 'from' must be less or equal 'to',
otherwise the result set will be empty only records that
where created in the same moment or after the 'from' timestamp will be provided in response
:param to: string - timestamp in past; 'from' must be less or equal 'to',
otherwise the result set will be empty only records that
where created in the same moment or earlier than the 'to'
timestamp will be provided in response
:return:
"""
params = {}
if offset:
params["offset"] = offset
if limit:
params["limit"] = limit
if filter:
params["filter"] = filter
if from_date:
params["from"] = from_date
if to_date:
params["to"] = to_date
url = "rest/api/2/auditing/record"
return self.get(url, params=params) or {}

def post_audit_record(self, audit_record):
"""
Store a record in Audit Log
:param audit_record: json with compat https://docs.atlassian.com/jira/REST/schema/audit-record#
:return:
"""
url = "rest/api/2/auditing/record"
return self.post(url, data=audit_record)

0 comments on commit 89f9858

Please sign in to comment.