<!--
Copyright (C) 2013-2022 Greenbone AG

SPDX-License-Identifier: AGPL-3.0-or-later
-->

<!--
  This wizard deletes a task as well as the associated target and credentials.

  Required parameters:
  task_id : The ID of the task to delete.
  ultimate : Whether to delete ultimately.

  To run this wizard, use the GMP command RUN_WIZARD.
  Please see the GMP documentation for details.
 -->

<wizard>
  <step>
    <command>
      <xsl:stylesheet
          version="1.0"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output
          method="xml"
          encoding="UTF-8"/>
        <xsl:template match="/">
          <get_tasks task_id="{/wizard/params/param[name='task_id']/value}" details="1"></get_tasks>
        </xsl:template>
      </xsl:stylesheet>
    </command>
  </step>
  <step>
    <command>
      <xsl:stylesheet
          version="1.0"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output
          method="xml"
          encoding="UTF-8"/>
        <xsl:template match="/">
          <delete_task task_id="{/wizard/params/param[name='task_id']/value}" ultimate="{/wizard/params/param[name='ultimate']/value}" />
          <get_targets target_id="{/wizard/previous/response/get_tasks_response/task/target/@id}" />
        </xsl:template>
      </xsl:stylesheet>
    </command>
  </step>
  <step>
    <command>
      <xsl:stylesheet
          version="1.0"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output
          method="xml"
          encoding="UTF-8"/>
        <xsl:template match="/">
          <xsl:if test="/wizard/previous/response/get_targets_response/target/@id != ''">
            <delete_target target_id="{/wizard/previous/response/get_targets_response/target/@id}" ultimate="{/wizard/params/param[name='ultimate']/value}" />
          </xsl:if>
          <xsl:if test="/wizard/previous/response/get_targets_response/target/ssh_lsc_credential/@id != ''">
            <delete_credential credential_id="{/wizard/previous/response/get_targets_response/target/ssh_lsc_credential/@id}" ultimate="{/wizard/params/param[name='ultimate']/value}"/>
          </xsl:if>
        </xsl:template>
      </xsl:stylesheet>
    </command>
  </step>
</wizard>
