def options(self, restApi, data={}, silentMode=False, ignoreError=False, maxRetries=5): """ Description A HTTP OPTIONS function to send REST APIs. Parameters restApi: (str): The REST API URL. silentMode: (bool): To display on stdout: URL, data and header info. ignoreError: (bool): True: Don't raise an exception. False: The response will be returned. maxRetries: : The maximum amount of GET retries before declaring as server connection failu """ retryInterval = 3 restExecutionFailures = 0 while True: if silentMode is False: self.logInfo('\n\tOPTIONS: {0}'.format(restApi)) try: # For binary file response = self._session.request('OPTIONS', restApi, headers=self.jsonHeader, allow_redirects=True, verify=self.verifySslCert) if silentMode is False: 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: {0}'.format(response.status_code), timestamp=False) if not str(response.status_code).startswith('2'): if ignoreError == False: if 'message' in response.json() and response.json()['messsage'] != None: self.logWarning('\n%s' % response.json()['message']) errMsg = 'OPTIONS Exception error: {0}'.format(response.text) raise IxNetRestApiException(errMsg) return response except (requests.exceptions.RequestException, Exception) as errMsg: errMsg = 'OPTIONS Exception error {}/{} retries: {}'.format(restExecutionFailures, maxRetries, errMsg) if restExecutionFailures < maxRetries: self.logError(errMsg) restExecutionFailures += 1 time.sleep(retryInterval) continue if restExecutionFailures == maxRetries: raise IxNetRestApiException(errMsg)