def get(self, restApi, data={}, stream=False, silentMode=False, ignoreError=False, maxRetries=5): """ Description A HTTP GET function to send REST APIs. Parameters restApi: (str): The REST API URL. data: (dict): The data payload for the 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 failure. Syntax /api/v1/sessions/1/ixnetwork/operations """ retryInterval = 3 restExecutionFailures = 0 while True: if silentMode is False: self.logInfo('\n\tGET: {0}'.format(restApi)) try: # For binary file if stream: response = self._session.request('GET', restApi, stream=True, headers=self.jsonHeader, allow_redirects=True, verify=self.verifySslCert) if stream == False: response = self._session.request('GET', 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 = 'GET Exception error: {0}'.format(response.text) raise IxNetRestApiException(errMsg) return response except (requests.exceptions.RequestException, Exception) as errMsg: errMsg = 'GET 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)