def delete(self, restApi, data={}, headers=None, maxRetries=5): """ Description A HTTP DELETE function to delete the session. For Linux and Windows Connection Mgr API server only. Paramters restApi: (str): The REST API URL. data: (dict): The data payload for the URL. headers: (str): The headers to use for the URL. maxRetries: : The maximum amount of GET retries before declaring as server connection failure. """ if headers != None: self.jsonHeader = headers retryInterval = 3 restExecutionFailures = 0 while True: self.logInfo('\n\tDELETE: {0}\n\tDATA: {1}'.format(restApi, data)) try: response = self._session.request('DELETE', restApi, data=json.dumps(data), headers=self.jsonHeader, allow_redirects=True, verify=self.verifySslCert) for redirectStatus in response.history: if '307' in str(response.history): self.logInfo('\t{0}: {1}'.format(redirectStatus, response.url), timestamp=False) self.logInfo('\tSTATUS CODE: %s' % response.status_code, timestamp=False) if not str(response.status_code).startswith('2'): self.showErrorMessage() errMsg = 'DELETE Exception error: {0}\n'.format(response.text) self.logError(errMsg) raise IxNetRestApiException(errMsg) return response except (requests.exceptions.RequestException, Exception) as errMsg: errMsg = 'DELETE Exception error {}/{} retries: {}\n'.format(restExecutionFailures, maxRetries, errMsg) if restExecutionFailures < maxRetries: self.logError(errMsg) restExecutionFailures += 1 time.sleep(retryInterval) continue if restExecutionFailures == maxRetries: raise IxNetRestApiException(errMsg)