code: def _retrieve_items(self, num_items, params, item_type="events", page=0):
          
          try:
              page = page
              retries = 0
              item_list = []
              remaining = num_items
              list_name = "eventResourceList" if item_type == "events" else "alarms"
              if not params:
                  params = {}
              # Loop if num_items > MAX_EVENTS as that is the max number of items in one page
              while remaining and page < (num_items//MAX_EVENTS+1) and retries < MAX_RETRIES:
                  params["page"] = page
                  params["size"] = min(remaining, MAX_EVENTS)
                  #response = self.client.get(self.url+item_type, params=params, verify=False)
                  response = self.client.get(self.url+item_type, params=params)
                  if response.status_code == 200:
                      self.log.warning("Got 200. Page info: {}.".format(response.json()['page']))
                      page += 1
                      retries = 0
                      items = response.json()['_embedded'][list_name]
                      item_list.extend(items)
                      remaining = min(remaining, response.json()['page']['totalElements'])
                      remaining -= len(items)
                  else:
                      retries += 1
                      self.log.error("Got response {response.status_code} for page {params['page']} " + \
                                     "and size {params['size']}. Attempt {retries}.")
                      time.sleep(1)
              return item_list
  
          except TokenExpiredError as e:
              self.log.error("ERROR: {e}. Token Expired.")
              self.client = self._connect()
              return self._retrieve_items(remaining, params, item_type, page)
  
          except KeyError as e:
              self.log.error("ERROR: {e}. {response.json()['_links']}")
              return []
docs: Retrieve num_items from item_type
          :param int num_items: Max items to retrieve
          :param dict params: Additional params dictionary
          :param string item_type: 'events' or 'alarms'
          :returns list: list of items