Skip to content

Commit 2ef538f

Browse files
authored
Merge pull request #83 from SLRover/master
New features and fix
2 parents c729d5f + 412092b commit 2ef538f

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

atlassian/service_desk.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,25 @@ def get_info(self):
1010
""" Get info about Service Desk app """
1111
return self.get('rest/servicedeskapi/info')
1212

13+
def get_service_desks(self):
14+
"""
15+
Returns all service desks in the JIRA Service Desk application
16+
with the option to include archived service desks
17+
18+
:return: Service Desks
19+
"""
20+
service_desks_list = self.get('rest/servicedeskapi/servicedesk')
21+
return service_desks_list.get('values')
22+
23+
def get_service_desk_by_id(self, service_desk_id):
24+
"""
25+
Returns the service desk for a given service desk ID
26+
27+
:param service_desk_id: str
28+
:return: Service Desk
29+
"""
30+
return self.get('rest/servicedeskapi/servicedesk/{}'.format(service_desk_id))
31+
1332
def create_customer(self, full_name, email):
1433
"""
1534
Creating customer user
@@ -68,6 +87,19 @@ def get_customer_request_status(self, issue_id_or_key):
6887
status = request[0].get('status')
6988
return status
7089

90+
def get_customer_transitions(self, issue_id_or_key):
91+
"""
92+
Returns a list of transitions that customers can perform on the request
93+
94+
:param issue_id_or_key: str
95+
:return:
96+
"""
97+
headers = {'Content-Type': 'application/json',
98+
'Accept': 'application/json',
99+
'X-ExperimentalApi': 'opt-in'
100+
}
101+
return self.get('rest/servicedeskapi/request/{}/transition'.format(issue_id_or_key), headers=headers)
102+
71103
def perform_transition(self, issue_id_or_key, transition_id, comment=None):
72104
"""
73105
Perform a customer transition for a given request and transition ID.
@@ -121,17 +153,23 @@ def get_request_comment_by_id(self, issue_id_or_key, comment_id):
121153

122154
def get_organisations(self, start=0, limit=50):
123155
"""
124-
Returns a list of organizations in the JIRA instance. If the user is not an agent, the resource returns a list of organizations the user is a member of.
156+
Returns a list of organizations in the JIRA instance. If the user is not an agent,
157+
the resource returns a list of organizations the user is a member of.
158+
125159
:param start: OPTIONAL: int The starting index of the returned objects.
126160
Base index: 0. See the Pagination section for more details.
127161
:param limit: OPTIONAL: int The maximum number of users to return per page.
128162
Default: 50. See the Pagination section for more details.
129163
:return:
130164
"""
165+
headers = {'Content-Type': 'application/json',
166+
'Accept': 'application/json',
167+
'X-ExperimentalApi': 'opt-in'
168+
}
131169
params = {}
132170
if start is not None:
133171
params["start"] = int(start)
134172
if limit is not None:
135173
params["limit"] = int(limit)
136174

137-
return self.get('rest/servicedeskapi/organization', params=params)
175+
return self.get('rest/servicedeskapi/organization', headers=headers, params=params)

docs/service_desk.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ Get info about Service Desk
66

77
.. code-block:: python
88
9+
# Get info about Service Desk app
910
sd.get_info()
1011
12+
# Get all service desks in the JIRA Service Desk application with the option to include archived service desks
13+
sd.get_service_desks()
14+
15+
# Get the service desk for a given service desk ID
16+
sd.get_service_desk_by_id(service_desk_id)
17+
1118
Create customer
1219
---------------
1320

@@ -50,5 +57,17 @@ Transitions
5057

5158
.. code-block:: python
5259
60+
# Get customer transitions. A list of transitions that customers can perform on the request
61+
sd.get_customer_transitions(issue_id_or_key)
62+
5363
# Perform transition. Optional argument comment (string), default is None
5464
sd.perform_transition(issue_id_or_key, transition_id, comment=None)
65+
66+
Manage the Organizations
67+
------------------------
68+
69+
.. code-block:: python
70+
71+
# Get a list of organizations in the JIRA instance
72+
# If the user is not an agent, the resource returns a list of organizations the user is a member of
73+
sd.get_organisations(self, start=0, limit=50)

0 commit comments

Comments
 (0)