code: def _query_api(self, method, url, fields=None, extra_headers=None, req_body=None):
          
          with self.auth.authenticate() as token:
              logging.debug('PA Authentication returned token %s', token)
              headers = {
                  'Authorization': 'Bearer %s' % (token,),
                  'Realm': self.auth_realm
              }
              if extra_headers is not None:
                  headers.update(extra_headers)
  
              logging.info('[%s] %s', method, url)
              if req_body is not None:
                  response = self.http.request(method, url, fields, headers, body=req_body)
              else:
                  response = self.http.request(method, url, fields, headers)                
              if response.status != 200:
                  print(response.data)
                  logging.warning('Got non-200 HTTP status from API: %d', response.status)
                  raise ApiQueryError("Failed to get API data", response.status)
              return json.loads(response.data.decode())
docs: Abstracts http queries to the API