From 7907ca7d7fa4229c4c5902a13fc6ce8a3535bf6b Mon Sep 17 00:00:00 2001 From: SLRover Date: Thu, 18 Oct 2018 18:32:13 +0300 Subject: [PATCH] Added: Organizations actions for Jira Service Desk module Updated: - Description for new functions was add to docs - README: Added link to documentation --- README.rst | 11 +++++++++-- atlassian/service_desk.py | 37 +++++++++++++++++++++++++++++++++++++ docs/service_desk.rst | 6 ++++++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index f87f6af44..3c7f44e5c 100644 --- a/README.rst +++ b/README.rst @@ -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 diff --git a/atlassian/service_desk.py b/atlassian/service_desk.py index 90dea26ec..44775e94f 100644 --- a/atlassian/service_desk.py +++ b/atlassian/service_desk.py @@ -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): """ diff --git a/docs/service_desk.rst b/docs/service_desk.rst index c02cc8745..c3f26007c 100644 --- a/docs/service_desk.rst +++ b/docs/service_desk.rst @@ -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 ------------------