cisco-en-programmability/dnacentersdk

api.task.get_task_by_id(taskid) return object does not include "endTime"

Closed this issue · 3 comments

Prerequisites

  • Have you tested the operation in the API directly?
  • Do you have the latest SDK version?

Describe the bug
api.task.get_task_by_id(taskid) return object must include "endTime" when the task has completed.
presence of the "endTime" key in the response data signifies the completion of the task and hence is very useful for executing conditional loops to check task status.
Below is the response for obtained for a completed task using the SDK (api.task.get_task_by_id(taskid))
{
'version': 1667597378807,
'startTime': 1667597377102,
'progress': '{"fileId":"f4b356e7-d132-4eab-811a-bbad2001d08f"}',
'username': 'admin',
'serviceType': 'Command Runner Service',
'lastUpdate': 1667597378807,
'isError': False,
'instanceTenantId': '6334ab5f519bd86f3b93a4ee',
'id': '2eee4e7c-93b7-41c0-9c8f-de71e171d546'
}

Output from POSTMAN for the same task

"response": {
    "endTime": 1667597382798,       <---- Important endTime key/value pair 
    "version": 1667597382798,
    "startTime": 1667597377102,
    "progress": "{\"fileId\":\"f4b356e7-d132-4eab-811a-bbad2001d08f\"}",
    "username": "admin",
    "serviceType": "Command Runner Service",
    "lastUpdate": 1667597378807,
    "isError": false,
    "instanceTenantId": "6334ab5f519bd86f3b93a4ee",
    "id": "2eee4e7c-93b7-41c0-9c8f-de71e171d546"
},
"version": "1.0"

}
Expected behavior
Expected return object:
{
'version': 1667597378807,
'startTime': 1667597377102,
"endTime": 1667597382798,
'progress': '{"fileId":"f4b356e7-d132-4eab-811a-bbad2001d08f"}',
'username': 'admin',
'serviceType': 'Command Runner Service',
'lastUpdate': 1667597378807,
'isError': False,
'instanceTenantId': '6334ab5f519bd86f3b93a4ee',
'id': '2eee4e7c-93b7-41c0-9c8f-de71e171d546'
}

Screenshots
Please provide an screenshot of the successful API call with cuRL, Postman, etc.

Environment (please complete the following information):

  • Cisco DNA Center Version and patch: 2.2.2.5
  • Python version: 3.9.13
  • SDK version: 2.5.4
  • OS Version: Windows10 / ubuntu 20.4

Additional context
Add any other context about the problem here.

Hi @ragadegithub
dnacentersdk already supports it, what I think happened is that when you performed get_task_by_id it was not finished yet, that's why it didn't come endTime.

That's API performance, since endTime only comes when it is really done

That's why later when you checked in postman it was already there because it had time to finish.

This issue can be closed.
endTime key is available in the response.
{'version': 1674498909320, 'endTime': 1674498909320, 'startTime': 1674498905844, 'progress': '{"fileId":"60dc7a4c-6ed2-4d63-a01b-f9dc5a319026"}', 'serviceType': 'Command Runner Service', 'username': 'admin', 'lastUpdate': 1674498909320, 'isError': False, 'instanceTenantId': '6334ab5f519bd86f3b93a4ee', 'id': '9deb655d-2a81-4beb-bf9e-14282ed68a94'}

endTime is On a scale setup the reponse.progress will have the 'fileId' field well before the endTime is published. Increase the "Wait time to fix the issue in script than sdk.