Search code examples
pythoncheckmarx

How monitory live response and make decision with python?


I'm doing an integration with Checkmarx.

I sent the request to create a new report, it worked well. But, the proccess take a time, so, I need to wait to report be create and download it.

https://checkmarx.atlassian.net/wiki/spaces/KC/pages/222069127/Get+Report+Status+by+Id+-+GET+reports+sastScan+id+status+v8.6.0+to+v8.7.0

Sample Response: { "location": "/reports/sastScan/1", "contentType": "application/xml", "status": { "id": 2, "value": "In Process" } }

Sample Response: { "location": "/reports/sastScan/1", "contentType": "application/xml", "status": { "id": 2, "value": "Created" } }

I'd like to know how create a monitoring in python when the "value" is "Created" get it and continue my python script.

Thanks!


Solution

  • One simple option would be to have a while loop after your initial post that stays looping until the status turns to created. The psuedocode for this would be

    post_request()
    flag = false
    while(flag == false):
        if(status == complete):
            flag = true
    get_status()
    

    This will trap the program in the while loop until your request comes in.