KSC Open API
Kaspersky Security Center API description
HostGroup::RemoveGroup ( int  nGroup,
int  nFlags,
[out] wstring  strActionGuid 
)

Deletes an administration group.

Parameters:
nGroup(int) ID of the existing administration group to delete.
nFlags(int) flags. May have the following values:
  • 1 - Group is deleted only if it does not contain subgroups, hosts, policies, tasks, secondary servers. The value is used by default.
  • 2 - Delete an administration group with subgroups, policies and tasks.
  • 3 - Delete an administration group with subgroups, hosts, policies and tasks.
[out]strActionGuid(wstring) ID of an asynchronous operation. To get a status, use AsyncActionStateChecker.CheckActionState. lStateCode "1" means OK and "0" means failure.

See also how to use the KlAkOAPI Python package:

            server = KlAkOAPI.AdmServer.KlAkAdmServer.Create("https://ksc.example.com:13299", "username", "password", verify = False)
            oHostGroup = KlAkOAPI.HostGroup.KlAkHostGroup(server)
            # show the group name to delete
            oGroupInfo = oHostGroup.GetGroupInfoEx(nGroupId, ['grp_full_name']).RetVal()
            print('Group to remove is: ' + oGroupInfo['grp_full_name'])
            # remove the group asynchronously
            strActionGuid = oHostGroup.RemoveGroup(nGroupId, nFlags = 1).OutPar('strActionGuid')
            # check for result of the asynchronous operation
            oAsyncActionStateChecker = KlAkOAPI.AsyncActionStateChecker.KlAkAsyncActionStateChecker (server)
            while True:
                res = oAsyncActionStateChecker.CheckActionState(strActionGuid)
                if res.OutPar('bFinalized'):
                    if res.OutPar('bSuccededFinalized'):
                        # got the asynchronous operation result: success 
                        print ('Group deleted successfully')
                    else:
                        # got the asynchronous operation result: some error occurred
                        err_description = KlAkOAPI.Params.KlAkParams(res.OutPar('pStateData'))
                        print('Cannot delete group:', err_description['GNRL_EA_DESCRIPTION'], '(error code ' + str(err_description['KLBLAG_ERROR_INFO']['KLBLAG_ERROR_CODE']) + ')')
                    break
                else:
                    # the asynchronous operation result is not ready yet, you need to wait for lNextCheckDelay milliseconds
                    time.sleep(MillisecondsToSeconds(res.OutPar('lNextCheckDelay')))