Skip to content

Commit 82bb442

Browse files
committed
Add post_item_workflow_transitions method
1 parent d03cb91 commit 82bb442

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ compatibility)
7676
- `POST` an item to a project
7777
- `POST` item attachment
7878
- `POST` item sync
79+
- `POST` Executes a workflow transition for the item with the specified item ID
7980
- `POST` a tag to an item
8081
- `PUT` an item
8182
- `PUT` item lock

py_jama_rest_client/client.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,31 @@ def post_item_sync(self, source_item: int, pool_item: int):
11931193
JamaClient.__handle_response_status(response)
11941194
return response.json()['meta']['id']
11951195

1196+
def post_item_workflow_transitions(self, item_id, transition_id, comment=''):
1197+
"""
1198+
Executes a workflow transition for the item with the specified ID
1199+
1200+
Args:
1201+
item_id: the api id of the item
1202+
transition_id: the api id of the tranistion status
1203+
comment: short description about the item transition
1204+
1205+
Returns: 201 if successful
1206+
"""
1207+
resource_path = 'items/'+ str(item_id) + '/workflowtransitions'
1208+
body = {
1209+
'transitionId': transition_id,
1210+
'comment': comment
1211+
}
1212+
headers = {'content-type': 'application/json'}
1213+
try:
1214+
response = self.__core.post(resource_path, data=json.dumps(body), headers=headers)
1215+
except CoreException as err:
1216+
py_jama_rest_client_logger.error(err)
1217+
raise APIException(str(err))
1218+
JamaClient.__handle_response_status(response)
1219+
return response.status_code
1220+
11961221
def post_relationship(self, from_item: int, to_item: int, relationship_type=None):
11971222
"""
11981223

test/test_jamaClient.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ def test_post_item_sync(self):
188188
sync = self.jama_client.post_item_sync(source_item, pool_item)
189189
self.assertIsNotNone(sync)
190190

191+
@unittest.skip('Entity Already Exists')
192+
def test_post_item_workflow_transitions(self):
193+
item_id = 10410
194+
transition_id = "566_700"
195+
comment = "Draft to Ready for Review"
196+
res_status = self.jama_client.post_item_workflow_transitions(item_id,transition_id,comment)
197+
self.assertEqual(res_status, 201)
198+
191199
@unittest.skip('Entity Already Exists')
192200
def test_post_relationship(self):
193201
from_item = 104755

0 commit comments

Comments
 (0)