docs: def InitFromApiFlow(self, f, cron_job_id=None):
      """Shortcut method for easy legacy cron jobs support."""
      if f.flow_id:
        self.run_id = f.flow_id
      elif f.urn:
        self.run_id = f.urn.Basename()
      self.started_at = f.started_at
      self.cron_job_id = cron_job_id
  
      flow_state_enum = api_plugins_flow.ApiFlow.State
      cron_enum = rdf_cronjobs.CronJobRun.CronJobRunStatus
      errors_map = {
          flow_state_enum.RUNNING: cron_enum.RUNNING,
          flow_state_enum.TERMINATED: cron_enum.FINISHED,
          flow_state_enum.ERROR: cron_enum.ERROR,
          flow_state_enum.CLIENT_CRASHED: cron_enum.ERROR
      }
      self.status = errors_map[f.state]
  
      if f.state != f.State.RUNNING:
        self.finished_at = f.last_active_at
  
      if f.context.kill_timestamp:
        self.status = self.Status.LIFETIME_EXCEEDED
  
      if f.context.HasField("status"):
        self.log_message = f.context.status
  
      if f.context.HasField("backtrace"):
        self.backtrace = f.context.backtrace
  
      return self