KSC Open API
13.1
Kaspersky Security Center API description
|
Check status of the async action. Preconditions:
Postconditions:
See also Python code with use of KlAkOAPI Python package below: server = KlAkOAPI.AdmServer.KlAkAdmServer.Create("https://ksc.example.com:13299", "username", "password", verify = False) # remove group is asynchronous action strActionGuid = KlAkOAPI.HostGroup.KlAkHostGroup(server).RemoveGroup(nGroupId, nFlags = 1).OutPar('strActionGuid') # check for result of asynchronous action asyncActionStateChecker = KlAkOAPI.AsyncActionStateChecker.KlAkAsyncActionStateChecker(server) while True: res = asyncActionStateChecker.CheckActionState(strActionGuid) if res.OutPar('bFinalized'): if res.OutPar('bSuccededFinalized'): # got asynchronous result: success print ('Async action is performed successfully') else: # got asynchronous result: some error occurred err_description = KlAkOAPI.Params.KlAkParams(res.OutPar('pStateData')) print('Cannot perform async action:', err_description['GNRL_EA_DESCRIPTION'], '(error code ' + str(err_description['KLBLAG_ERROR_INFO']['KLBLAG_ERROR_CODE']) + ')') break else: # asynchronous result is not ready yet - need to wait for lNextCheckDelay milliseconds time.sleep(MillisecondsToSeconds(res.OutPar('lNextCheckDelay'))) |