code: def clean(self, timeout=60):
          
          self.refresh()
  
          tds = self['maxTotalDataSizeMB']
          ftp = self['frozenTimePeriodInSecs']
          was_disabled_initially = self.disabled
          try:
              if (not was_disabled_initially and \
                  self.service.splunk_version < (5,)):
                  # Need to disable the index first on Splunk 4.x,
                  # but it doesn't work to disable it on 5.0.
                  self.disable()
              self.update(maxTotalDataSizeMB=1, frozenTimePeriodInSecs=1)
              self.roll_hot_buckets()
  
              # Wait until event count goes to 0.
              start = datetime.now()
              diff = timedelta(seconds=timeout)
              while self.content.totalEventCount != '0' and datetime.now() < start+diff:
                  sleep(1)
                  self.refresh()
  
              if self.content.totalEventCount != '0':
                  raise OperationError("Cleaning index %s took longer than %s seconds; timing out." % (self.name, timeout))
          finally:
              # Restore original values
              self.update(maxTotalDataSizeMB=tds, frozenTimePeriodInSecs=ftp)
              if (not was_disabled_initially and \
                  self.service.splunk_version < (5,)):
                  # Re-enable the index if it was originally enabled and we messed with it.
                  self.enable()
  
          return self
docs: Deletes the contents of the index.
  
          This method blocks until the index is empty, because it needs to restore
          values at the end of the operation.
  
          :param timeout: The time-out period for the operation, in seconds (the
              default is 60).
          :type timeout: ``integer``
  
          :return: The :class:`Index`.