<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed Materials - Property of IBM* and/or HCL**
- UrbanCode Deploy
- UrbanCode Build
- UrbanCode Release
- AnthillPro
- (c) Copyright IBM Corporation 2011, 2017. All Rights Reserved.
- (c) Copyright HCL Technologies Ltd. 2018. All Rights Reserved.
-
- U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by
- GSA ADP Schedule Contract with IBM Corp.
-
- * Trademark of International Business Machines
- ** Trademark of HCL Technologies Limited
-->
<plugin xmlns="http://www.urbancode.com/PluginXMLSchema_v1"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:server="http://www.urbancode.com/PluginServerXMLSchema_v1">
  <header>
    <identifier id="com.urbancode.air.plugin.uDeployEnvironment" name="UrbanCode Deploy Environments" version="88"/>
    <description>
      Plugin for creating and managing UrbanCode Deploy environments.
    </description>
    <tag>UrbanCode Deploy/Environments</tag>
  </header>

  <step-type name="Create Environment">
    <description>Creates an environment for the specified application.</description>
    <properties>
      <property name="application" required="true">
        <property-ui type="textBox"
                     label="Application Name"
                     description="The name of the application the environment will be created for."/>
      </property>
      <property name="environment" required="true">
        <property-ui type="textBox"
                     label="Environment Name"
                     description="The name of the environment to be created."/>
      </property>
      <property name="suffix">
        <property-ui type="checkBox"
                     label="Append Unique Suffix"
                     description="Check this box if you want to guarantee your environment name is unique."/>
      </property>
      <property name="description">
        <property-ui type="textBox"
                     label="Description"
                     description="A description of of the environment to be created."/>
      </property>
      <property name="blueprint">
        <property-ui type="textBox"
                     label="Blueprint Name"
                     description="Specify a blueprint name if this environment should be created based on an application blueprint."/>
      </property>
      <property name="baseResource">
        <property-ui type="textBox"
                     label="Base Resource Path"
                     description="Specify the path to a base resource to put the new environment's resources in if using a blueprint. This field must be provided when using a blueprint. Example: /Provisioned Environments"/>
      </property>
      <property name="envProfileName">
        <property-ui type="textBox"
                     label="Environment Profile"
                     description="Specify the name of the environment profile to use to provision the new environment. This field is only valid for blueprints backed by resource templates imported from the cloud."/>
      </property>
      <property name="requireApprovals">
        <property-ui type="checkBox"
                     label="Require Approvals"
                     description="Check this box if the environment will require approval from an approval process to install versions or snapshots."/>
      </property>
      <property name="properties">
        <property-ui type="textAreaBox"
                     label="Properties"
                     description="Properties to be set on the new environment, using Java property file syntax."/>
      </property>
      <property name="nodeProperties">
        <property-ui type="textAreaBox"
                     label="Node Resource Properties"
                     description="Properties that configure cloud resource nodes. Syntax: [node or script package name]/propertyName=propertyValue
                     Examples: OS Node/HWAttributes.numvcpus=2
                     install_ucd_agent/UCD_Agent_Name=newAgentName"/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="createenv.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Create Environment from Template">
    <description>Creates an environment from a template for the specified application.</description>
    <properties>
      <property name="application" required="true">
        <property-ui type="textBox"
                     label="Application ID"
                     description="The Application ID where the environment will be created."/>
      </property>
      <property name="environment" required="true">
        <property-ui type="textBox"
                     label="Environment Name"
                     description="The name of the environment to be created."/>
      </property>
      <property name="description">
        <property-ui type="textBox"
                     label="Description"
                     description="A description of of the environment to be created."/>
      </property>
      <property name="templateName">
        <property-ui type="textBox"
                     label="Environment Template Name"
                     description="The name of the environment template. The Environment Template ID or Name is required."/>
      </property>
      <property name="templateId">
        <property-ui type="textBox"
                     label="Environment Template ID"
                     description="The ID of the environment template. The Environment Template ID or Name is required."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="createEnvironmentFromTemplate.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Create Multiple Environments">
    <description>Creates multiple environments using JSON format. Outputs a comma delimited list of the environment UUIDs that were created ('environment.ids').</description>
    <properties>
      <property name="json" required="true">
        <property-ui type="textAreaBox"
                     label="JSON File/Text"
                     description="Specify a body of JSON text or a file to define Environments. Separate multiple
                        JSON objects by using commas within an array, e.g. [{},{},{}]."
                     default-value='[{ &#xD;&#xA;"application": "Application assigned to the environment.",
                        &#xD;&#xA;"name": "Environment name or ID.",
                        &#xD;&#xA;"description": "Description of the environment",
                        &#xD;&#xA;"requireApprovals": "True/false to specify whether environment requires approvals.",
                        &#xD;&#xA;"noSelfApprovals": "True/false to specify whether environment allows self approvals.",
                        &#xD;&#xA;"nodeProperties": {"Node property name": "Property value"},
                        &#xD;&#xA;"properties": {"Environment property name": "Property value"},
                        &#xD;&#xA;"templateName": "(Optional) Supply either the templateId or templateName to use a template.",
                        &#xD;&#xA;"templateId": "(Optional) Supply either the templateId or templateName to use a template.",
                        &#xD;&#xA;}]'
                     />
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="createMultipleEnvironments.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Create Environment Property">
    <description>Create a property for an application environment.</description>
    <properties>
      <property name="application">
        <property-ui type="textBox"
                     label="Application"
                     description="name/ID of the application that the environment belongs to. Not needed if you refer to environment by ID instead of name."/>
      </property>
      <property name="environment" required="true">
        <property-ui type="textBox"
                     label="Environment"
                     description="name/ID of the environment. If you specify ID you don't need to specify the application."/>
      </property>
      <property name="name" required="true">
        <property-ui type="textBox"
                     label="Property Name"
                     description="name of the property to set."/>
      </property>
      <property name="value">
        <property-ui type="textBox"
                     label="Property Value"
                     description="Value of the property to set if &quot;Secure&quot; is not checked."/>
      </property>
      <property name="secureValue">
        <property-ui type="secureBox"
                     label="Secure Property Value"
                     description="Value of the property to set if &quot;Secure&quot; is checked. If this is empty, &quot;Property Value&quot; will be used instead."/>
      </property>
      <property name="isSecure">
        <property-ui type="checkBox"
                     label="Secure"
                     description="Check if the property should be secure. When this is checked, &quot;Secure Property Value&quot; will be used if given. If &quot;Secure Property Value&quot; is missing, &quot;Property Value&quot; will be used instead."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="setenvprop.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Get Environment Properties">
    <description>Get the name-value pairs of all environment properties and sets them as output properties for this step. Secure property values cannot be resolved.</description>
    <properties>
      <property name="application">
        <property-ui type="textBox"
                     label="Application"
                     description="name/ID of the application that the environment belongs to. Not needed if you refer to environment by ID instead of name."/>
      </property>
      <property name="environment" required="true">
        <property-ui type="textBox"
                     label="Environment"
                     description="name/ID of the environment. If you specify ID you don't need to specify the application."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="getenvprops.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Get Component Environment Properties">
    <description>Get the name-value pairs of all component environment properties and sets them as output properties for this step. Secure property values cannot be resolved.</description>
    <properties>
      <property name="application">
        <property-ui type="textBox"
                     label="Application"
                     description="name/ID of the application that the environment belongs to. Not needed if you refer to environment by ID instead of name."/>
      </property>
      <property name="environment" required="true">
        <property-ui type="textBox"
                     label="Environment"
                     description="name/ID of the environment. If you specify ID you don't need to specify the application."/>
      </property>
      <property name="component" required="true">
        <property-ui type="textBox"
                     label="Component"
                     description="name/ID of the component."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="getcompenvprops.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Set Component Environment Property">
    <description>Sets an environment-specific property value for a component. The property must already exist.</description>
    <properties>
      <property name="component" required="true">
        <property-ui type="textBox"
                     label="Component"
                     description="name/ID of the component that the environment belongs to."/>
      </property>
      <property name="environment" required="true">
        <property-ui type="textBox"
                     label="Environment"
                     description="name/ID of the environment. If you specify ID you don't need to specify the application."/>
      </property>
      <property name="application">
        <property-ui type="textBox"
                     label="Application"
                     description="name/ID of the application that the environment belongs to. Not required if you specify environment by ID instead of name."/>
      </property>
      <property name="name" required="true">
        <property-ui type="textBox"
                     label="Property Name"
                     description="name of the property to set."/>
      </property>
      <property name="value">
        <property-ui type="textBox"
                     label="Property Value"
                     description="value of the property to set."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="setcompenvprop.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Verify Inventory Status">
    <description>Verifies that the environment has a component with a certain version in inventory.</description>
    <properties>
      <property name="environment" required="true">
        <property-ui type="textBox"
                     label="Environment"
                     description="name/ID of the environment. If you specify ID you don't need to specify the application."/>
      </property>
      <property name="application">
        <property-ui type="textBox"
                     label="Application"
                     description="name/ID of the application that the environment belongs to. Not needed if you refer to environment by ID instead of name."/>
      </property>
      <property name="component" required="true">
        <property-ui type="textBox"
                     label="Component"
                     description="name/ID of the component to verify."/>
      </property>
      <property name="version" required="true">
        <property-ui type="textBox"
                     label="Version"
                     description="name of the version to verify."/>
      </property>
      <property name="inventoryStatus" required="true">
        <property-ui type="textBox"
                     label="Status"
                     description="The inventory entry must match this status (case sensitive). Default possible statuses are Active or Staged, but custom statuses are also possible."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else if (properties.get("verified") == "false") {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="verifyInventoryStatus.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Check If Environment Exists">
    <description>This step will succeed if the environment exists and fail if it does not.</description>
    <properties>
      <property name="environment" required="true">
        <property-ui type="textBox"
                     label="Environment"
                     description="name/ID of the environment. If you specify ID you don't need to specify the application."/>
      </property>
      <property name="application">
        <property-ui type="textBox"
                     label="Application"
                     description="name/ID of the application that the environment belongs to. Not needed if you refer to environment by ID instead of name."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else if (properties.get("exists").equals("false")) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="exists.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Delete Environment">
    <description>Deletes an environment.</description>
    <properties>
      <property name="application">
        <property-ui type="textBox"
                     label="Application"
                     description="name/ID of the application that the environment belongs to. Not needed if you refer to environment by ID instead of name."/>
      </property>
      <property name="environment" required="true">
        <property-ui type="textBox"
                     label="Environment"
                     description="name/ID of the environment. If you specify ID you don't need to specify the application."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="deleteEnvironment.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Add Environment To Team">
    <description>Adds an environment or list of environments delimited by commas to a team for a
        given application and type classification.</description>
    <properties>
      <property name="application">
        <property-ui type="textBox"
                     label="Application"
                     description="Required unless you are specifying the environment by its ID."/>
      </property>
      <property name="environment" required="true">
        <property-ui type="textAreaBox"
                     label="Environment/Environments"
                     description="A comma delimited list of environment names/ids to add to the team."/>
      </property>
      <property name="team" required="true">
        <property-ui type="textBox"
                     label="Team"/>
      </property>
      <property name="type">
        <property-ui type="textBox"
                     label="Type"
                     description="The type classification to add. Leave blank to use the type Standard Environment."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="addEnvironmentToTeam.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

    <step-type name="Add Base Resource To Environment">
    <description>Adds a base resource to an environment as a deployment target.</description>
    <properties>
      <property name="application">
        <property-ui type="textBox"
                     label="Application"
                     description="Required unless you are specifying the environment by its ID."/>
      </property>
      <property name="environment" required="true">
        <property-ui type="textBox"
                     label="Environment"/>
      </property>
            <property name="resource" required="true">
        <property-ui type="textBox"
                     label="Resource Path"/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="addBaseResource.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Get Latest Version By Environment and Component">
    <description>Gets the latest Version of a Component in a given Environment</description>
    <properties>
      <property name="application">
        <property-ui type="textBox"
                     label="Application"
                     description="Required Application Name" />
      </property>
      <property name="environment">
        <property-ui type="textBox"
                     label="Environment"
                     description="Required Environment Name" />
      </property>
      <property name="component">
        <property-ui type="textBox"
                     label="Component"
                     description="Required Component Name" />
      </property>
    </properties>
    <post-processing>
    <![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]>
    </post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="getLatestVersionByEnvironmentAndComponent.groovy" />
      <arg file="${PLUGIN_INPUT_PROPS}" />
      <arg file="${PLUGIN_OUTPUT_PROPS}" />
    </command>
  </step-type>

  <step-type name="Get Environment Details">
    <description>Retrieve basic configuration information about a environment.</description>
    <properties>
      <property name="environment" required="true">
        <property-ui type="textBox"
                     label="Environment"
                     description="Environment name or ID"/>
      </property>
      <property name="application" required="true">
        <property-ui type="textBox"
                     label="Application"
                     description="Application name or ID. (Required when using a name for the environment instead of its ID)"/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp" />
      <arg path="classes:lib/uDeployRestClient.jar:lib/securedata.jar:lib/jettison.jar:lib/commons-codec.jar:lib/CommonsUtil.jar" />
      <arg file="getEnvironmentInfo.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

</plugin>
