Skip to content

Commit

Permalink
Added: Organizations actions for Jira Service Desk module
Browse files Browse the repository at this point in the history
Updated:
 - Description for new functions was add to docs
 - README: Added link to documentation
  • Loading branch information
SLRover committed Oct 18, 2018
1 parent de9fbf7 commit 7907ca7
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
11 changes: 9 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ Atlassian Python API wrapper
============================
|Build Status| |PyPI version| |License| |Codacy Badge|

For users
---------
Documentation
-------------

`Documentation (beta)`_

.. _Documentation (beta): https://atlassian-python-api.readthedocs.io/en/latest/index.html

Examples
--------

For everyday normal use, just install package using pip

Expand Down
37 changes: 37 additions & 0 deletions atlassian/service_desk.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,43 @@ def get_organisations(self, start=0, limit=50):

return self.get('rest/servicedeskapi/organization', headers=headers, params=params)

def get_organization(self, organization_id):
"""
Get an organization for a given organization ID
:param organization_id: str
:return: Organization
"""
url = 'rest/servicedeskapi/organization/{}'.format(organization_id)
headers = {'Content-Type': 'application/json',
'Accept': 'application/json',
'X-ExperimentalApi': 'opt-in'
}

return self.get(url, headers=headers)

def get_users_in_organization(self, organization_id, start=0, limit=50):
"""
Get all the users of a specified organization
:param organization_id: str
:param start: OPTIONAL: int
:param limit: OPTIONAL: int
:return: Users list in organization
"""
url = 'rest/servicedeskapi/organization/{}/user'.format(organization_id)
headers = {'Content-Type': 'application/json',
'Accept': 'application/json',
'X-ExperimentalApi': 'opt-in'
}
params = {}
if start is not None:
params["start"] = int(start)
if limit is not None:
params["limit"] = int(limit)

return self.get(url, headers=headers, params=params)

# Attachments actions
def create_attachment(self, service_desk_id, issue_id_or_key, filename, public=True, comment=None):
"""
Expand Down
6 changes: 6 additions & 0 deletions docs/service_desk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ Manage the Organizations
# If the user is not an agent, the resource returns a list of organizations the user is a member of
sd.get_organisations(self, start=0, limit=50)
# Get an organization for a given organization ID
sd.get_organization(organization_id)
# Get all the users of a specified organization
sd.get_users_in_organization(organization_id, start=0, limit=50)
Attachment actions
------------------

Expand Down

0 comments on commit 7907ca7

Please sign in to comment.