<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed Materials - Property of IBM Corp.
- IBM UrbanCode Build
- IBM UrbanCode Deploy
- IBM UrbanCode Release
- IBM AnthillPro
- (c) Copyright IBM Corporation 2002, 2013. All Rights Reserved.
-
- U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by
- GSA ADP Schedule Contract with IBM Corp.
-->
<plugin xmlns="http://www.urbancode.com/PluginXMLSchema_v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <header>
    <identifier version="9" id="com.urbancode.air.plugin.ServiceNow" name="ServiceNow"/>
    <description>The Service Now plugin allows uDeploy to check approvals and set the status of change requests.</description>
    <tag>ITSM Process/ServiceNow</tag>
  </header>
  <!-- ==================================== -->
  <!--  Check Approval                         -->
  <!-- ==================================== -->
  <step-type name="Check Approval Status">
    <description>Check Approval Status of a change request in ServiceNow</description>
    <properties>
      <property name="serverUrl" required="true">
        <property-ui type="textBox" default-value="${property:resource/serviceNow/serverUrl}" label="Server Url" description="The Server Url to use to contact ServiceNow."/>
      </property>
      <property name="status" required="true">
        <property-ui type="textBox" label="Status" description="The status you want to ensure the change request has."/>
      </property>
      <property name="changeRequestId" required="true">
        <property-ui type="textBox" label="Change Request Number" description="The change request number to look at the status for."/>
      </property>
      <property name="username" required="false">
        <property-ui type="textBox" default-value="${property:resource/servicenow/username}" label="User Name" description="The user name to be used to connect to the ServiceNow server."/>
      </property>
      <property name="password" required="false">
        <property-ui type="secureBox" default-value="${property:resource/servicenow/password}" label="Password" description="The password to be used to connect to the ServiceNow server."/>
      </property>
      <property name="proxyHost">
        <property-ui type="textBox"
                     label="HTTP Proxy Host"
                     description="Provide the hostname of the HTTP proxy to use to connect to ServiceNow. Eg proxy.domain.com"/>
      </property>
      <property name="proxyPort">
        <property-ui type="textBox"
                     label="HTTP Proxy Port"
                     description="Provide the port number of the HTTP proxy to use to connect to ServiceNow."/>
      </property>
      <property name="proxyUser">
        <property-ui type="textBox"
                     label="HTTP Proxy User name"
                     description="Provide the user name to authenticate with HTTP proxy."/>
      </property>
      <property name="proxyPass">
        <property-ui type="secureBox"
                     label="HTTP Proxy Password"
                     description="Provide the password to authenticate with HTTP proxy."/>
      </property>
      <property name="newAPI">
        <property-ui type="checkBox"
                     label="Use New ServiceNow API"
                     description="Check this box if you are using ServiceNow version Eureka or later."/>
      </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/log4j.jar;lib/CommonsUtil.jar;lib/httpclient.jar:lib/httpcore.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/commons-lang3.jar:lib/commons-beanutils.jar:lib/commons-collections.jar:lib/commons-codec.jar:lib/commons-lang.jar:lib/HttpComponents-Util.jar"/>
      <arg file="check_approval.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <!-- check ticket status -->
  <step-type name="Check Change Request Status">
    <description>Check Status of a change request in ServiceNow</description>
    <properties>
      <property name="serverUrl" required="true">
        <property-ui type="textBox" default-value="${property:resource/serviceNow/serverUrl}" label="Server Url" description="The Server Url to use to contact ServiceNow."/>
      </property>
      <property name="status" required="true">
        <property-ui type="textBox" label="Status" description="The status you want to ensure the change request has. This is an integer corresponding to the state integer ServiceNow uses."/>
      </property>
      <property name="changeRequestId" required="true">
        <property-ui type="textBox" label="Change Request Number" description="The change request number to look at the status for."/>
      </property>
      <property name="username" required="false">
        <property-ui type="textBox" default-value="${property:resource/servicenow/username}" label="User Name" description="The user name to be used to connect to the ServiceNow server."/>
      </property>
      <property name="password" required="false">
        <property-ui type="secureBox" default-value="${property:resource/servicenow/password}" label="Password" description="The password to be used to connect to the ServiceNow server."/>
      </property>
      <property name="proxyHost">
        <property-ui type="textBox"
                     label="HTTP Proxy Host"
                     description="Provide the hostname of the HTTP proxy to use to connect to ServiceNow. Eg proxy.domain.com"/>
      </property>
      <property name="proxyPort">
        <property-ui type="textBox"
                     label="HTTP Proxy Port"
                     description="Provide the port number of the HTTP proxy to use to connect to ServiceNow."/>
      </property>
      <property name="proxyUser">
        <property-ui type="textBox"
                     label="HTTP Proxy User name"
                     description="Provide the user name to authenticate with HTTP proxy."/>
      </property>
      <property name="proxyPass">
        <property-ui type="secureBox"
                     label="HTTP Proxy Password"
                     description="Provide the password to authenticate with HTTP proxy."/>
      </property>
      <property name="newAPI">
        <property-ui type="checkBox"
                     label="Use New ServiceNow API"
                     description="Check this box if you are using ServiceNow version Eureka or later."/>
      </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/log4j.jar;lib/CommonsUtil.jar;lib/httpclient.jar:lib/httpcore.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/commons-lang3.jar:lib/commons-lang.jar:lib/commons-beanutils.jar:lib/commons-collections.jar:lib/commons-codec.jar:lib/HttpComponents-Util.jar"/>
      <arg file="check_status.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <!-- check ticket status -->
  <step-type name="Set Change Request Status">
    <description>Set the Status of a change request in ServiceNow</description>
    <properties>
      <property name="serverUrl" required="true">
        <property-ui type="textBox" default-value="${property:resource/serviceNow/serverUrl}" label="Server Url" description="The Server Url to use to contact ServiceNow."/>
      </property>
      <property name="status" required="true">
        <property-ui type="textBox" label="Status" description="The status you want to set on the change request This is an integer corresponding to the state integer ServiceNow uses."/>
      </property>
      <property name="changeRequestId" required="true">
        <property-ui type="textBox" label="Change Request Number" description="The change request number to look at the status for."/>
      </property>
      <property name="username" required="false">
        <property-ui type="textBox" default-value="${property:resource/servicenow/username}" label="User Name" description="The user name to be used to connect to the ServiceNow server."/>
      </property>
      <property name="password" required="false">
        <property-ui type="secureBox" default-value="${property:resource/servicenow/password}" label="Password" description="The password to be used to connect to the ServiceNow server."/>
      </property>
      <property name="proxyHost">
        <property-ui type="textBox"
                     label="HTTP Proxy Host"
                     description="Provide the hostname of the HTTP proxy to use to connect to ServiceNow. Eg proxy.domain.com"/>
      </property>
      <property name="proxyPort">
        <property-ui type="textBox"
                     label="HTTP Proxy Port"
                     description="Provide the port number of the HTTP proxy to use to connect to ServiceNow."/>
      </property>
      <property name="proxyUser">
        <property-ui type="textBox"
                     label="HTTP Proxy User name"
                     description="Provide the user name to authenticate with HTTP proxy."/>
      </property>
      <property name="proxyPass">
        <property-ui type="secureBox"
                     label="HTTP Proxy Password"
                     description="Provide the password to authenticate with HTTP proxy."/>
      </property>
      <property name="newAPI">
        <property-ui type="checkBox"
                     label="Use New ServiceNow API"
                     description="Check this box if you are using ServiceNow version Eureka or later."/>
      </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/log4j.jar;lib/CommonsUtil.jar;lib/httpclient.jar:lib/httpcore.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/commons-lang3.jar:lib/commons-lang.jar:lib/commons-beanutils.jar:lib/commons-collections.jar:lib/commons-codec.jar:lib/HttpComponents-Util.jar"/>
      <arg file="update_status.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <!-- check ticket status -->
  <step-type name="Check Change Request's Child Tasks Statuses">
    <description>Check Status of all child tasks of a change request in ServiceNow</description>
    <properties>
      <property name="serverUrl" required="true">
        <property-ui type="textBox" default-value="${property:resource/serviceNow/serverUrl}" label="Server Url" description="The Server Url to use to contact ServiceNow."/>
      </property>
      <property name="status" required="true">
        <property-ui type="textBox" label="Status" description="The status you want to ensure the change request has. This is an integer corresponding to the state integer ServiceNow uses."/>
      </property>
      <property name="changeRequestId" required="true">
        <property-ui type="textBox" label="Change Request Number" description="The change request number to look at the status for."/>
      </property>
      <property name="username" required="false">
        <property-ui type="textBox" default-value="${property:resource/servicenow/username}" label="User Name" description="The user name to be used to connect to the ServiceNow server."/>
      </property>
      <property name="password" required="false">
        <property-ui type="secureBox" default-value="${property:resource/servicenow/password}" label="Password" description="The password to be used to connect to the ServiceNow server."/>
      </property>
      <property name="proxyHost">
        <property-ui type="textBox"
                     label="HTTP Proxy Host"
                     description="Provide the hostname of the HTTP proxy to use to connect to ServiceNow. Eg proxy.domain.com"/>
      </property>
      <property name="proxyPort">
        <property-ui type="textBox"
                     label="HTTP Proxy Port"
                     description="Provide the port number of the HTTP proxy to use to connect to ServiceNow."/>
      </property>
      <property name="proxyUser">
        <property-ui type="textBox"
                     label="HTTP Proxy User name"
                     description="Provide the user name to authenticate with HTTP proxy."/>
      </property>
      <property name="proxyPass">
        <property-ui type="secureBox"
                     label="HTTP Proxy Password"
                     description="Provide the password to authenticate with HTTP proxy."/>
      </property>
      <property name="newAPI">
        <property-ui type="checkBox"
                     label="Use New ServiceNow API"
                     description="Check this box if you are using ServiceNow version Eureka or later."/>
      </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/log4j.jar;lib/CommonsUtil.jar;lib/httpclient.jar:lib/httpcore.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/commons-lang3.jar:lib/commons-lang.jar:lib/commons-beanutils.jar:lib/commons-collections.jar:lib/commons-codec.jar:lib/HttpComponents-Util.jar"/>
      <arg file="check_tasks_status.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <!-- check ticket status -->
  <step-type name="Update Tasks Statuses">
    <description>Update Status of all tasks in task ID list in ServiceNow</description>
    <properties>
      <property name="serverUrl" required="true">
        <property-ui type="textBox" default-value="${property:resource/serviceNow/serverUrl}" label="Server Url" description="The Server Url to use to contact ServiceNow."/>
      </property>
      <property name="status" required="true">
        <property-ui type="textBox" label="Status" description="The status you want to ensure the change request has. This is an integer corresponding to the state integer ServiceNow uses."/>
      </property>
      <property name="tasksId" required="true">
        <property-ui type="textBox" label="Task ID List" description="A comma-separated list of task ID to be updated."/>
      </property>
      <property name="username" required="false">
        <property-ui type="textBox" default-value="${property:resource/servicenow/username}" label="User Name" description="The user name to be used to connect to the ServiceNow server."/>
      </property>
      <property name="password" required="false">
        <property-ui type="secureBox" default-value="${property:resource/servicenow/password}" label="Password" description="The password to be used to connect to the ServiceNow server."/>
      </property>
      <property name="proxyHost">
        <property-ui type="textBox"
                     label="HTTP Proxy Host"
                     description="Provide the hostname of the HTTP proxy to use to connect to ServiceNow. Eg proxy.domain.com"/>
      </property>
      <property name="proxyPort">
        <property-ui type="textBox"
                     label="HTTP Proxy Port"
                     description="Provide the port number of the HTTP proxy to use to connect to ServiceNow."/>
      </property>
      <property name="proxyUser">
        <property-ui type="textBox"
                     label="HTTP Proxy User name"
                     description="Provide the user name to authenticate with HTTP proxy."/>
      </property>
      <property name="proxyPass">
        <property-ui type="secureBox"
                     label="HTTP Proxy Password"
                     description="Provide the password to authenticate with HTTP proxy."/>
      </property>
      <property name="newAPI">
        <property-ui type="checkBox"
                     label="Use New ServiceNow API"
                     description="Check this box if you are using ServiceNow version Eureka or later."/>
      </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/log4j.jar;lib/CommonsUtil.jar;lib/httpclient.jar:lib/httpcore.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/commons-lang3.jar:lib/commons-lang.jar:lib/commons-beanutils.jar:lib/commons-collections.jar:lib/commons-codec.jar:lib/HttpComponents-Util.jar"/>
      <arg file="update_tasks_status.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
  
  <step-type name="Insert Row Into CMDB Table">
    <description>Inserts a row in to the specified table in the ServiceNow CMDB.</description>
    <properties>
      <property name="serverUrl" required="true">
        <property-ui type="textBox"
                     label="Server URL"
                     description="The URL of your ServiceNow portal. Example: https://myaccount.service-now.com"/>
      </property>
      <property name="username" required="true">
        <property-ui type="textBox"
                     label="ServiceNow User name"
                     description="Provide the user name to authenticate with ServiceNow."/>
      </property>
      <property name="password" required="true">
        <property-ui type="secureBox"
                     label="ServiceNow Password"
                     description="Provide the password to authenticate with ServiceNow."/>
      </property>
      <property name="table" required="true">
        <property-ui type="textBox"
                     label="CMDB Table Name"
                     description="The name of the table to update. Example: cmdb_ci_appl_list"/>
      </property>
        <property name="fields">
        <property-ui type="textAreaBox"
                     label="Row Fields"
                     description="The fields to insert for this row. Each name-value pair should be on a separate line. A colon separates the name and value. Example: name:value"/>
      </property>
      <property name="proxyHost">
        <property-ui type="textBox"
                     label="HTTP Proxy Host"
                     description="Provide the hostname of the HTTP proxy to use to connect to ServiceNow. Eg proxy.domain.com"/>
      </property>
      <property name="proxyPort">
        <property-ui type="textBox"
                     label="HTTP Proxy Port"
                     description="Provide the port number of the HTTP proxy to use to connect to ServiceNow."/>
      </property>
      <property name="proxyUser">
        <property-ui type="textBox"
                     label="HTTP Proxy User name"
                     description="Provide the user name to authenticate with HTTP proxy."/>
      </property>
      <property name="proxyPass">
        <property-ui type="secureBox"
                     label="HTTP Proxy Password"
                     description="Provide the password to authenticate with HTTP proxy."/>
      </property>
      <property name="newAPI">
        <property-ui type="checkBox"
                     label="Use New ServiceNow API"
                     description="Check this box if you are using ServiceNow version Eureka or later."/>
      </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/log4j.jar;lib/CommonsUtil.jar;lib/httpclient.jar:lib/httpcore.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/commons-lang3.jar:lib/commons-lang.jar:lib/commons-beanutils.jar:lib/commons-collections.jar:lib/commons-codec.jar:lib/HttpComponents-Util.jar"/>
      <arg file="insert_row.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
  
  <step-type name="Delete Row From CMDB Table">
    <description>Deletes a row from the specified table in the ServiceNow CMDB.</description>
    <properties>
      <property name="serverUrl" required="true">
        <property-ui type="textBox"
                     label="Server URL"
                     description="The URL of your ServiceNow portal. Example: https://myaccount.service-now.com"/>
      </property>
      <property name="username" required="true">
        <property-ui type="textBox"
                     label="ServiceNow User name"
                     description="Provide the user name to authenticate with ServiceNow."/>
      </property>
      <property name="password" required="true">
        <property-ui type="secureBox"
                     label="ServiceNow Password"
                     description="Provide the password to authenticate with ServiceNow."/>
      </property>
      <property name="table" required="true">
        <property-ui type="textBox"
                     label="CMDB Table Name"
                     description="The name of the table to update. Example: cmdb_ci_appl_list"/>
      </property>
      <property name="id" required="true">
        <property-ui type="textBox"
                     label="CMDB Row ID"
                     description="The unique ID of the row to delete. Represents the sys_id field."/>
      </property>
      <property name="proxyHost">
        <property-ui type="textBox"
                     label="HTTP Proxy Host"
                     description="Provide the hostname of the HTTP proxy to use to connect to ServiceNow. Eg proxy.domain.com"/>
      </property>
      <property name="proxyPort">
        <property-ui type="textBox"
                     label="HTTP Proxy Port"
                     description="Provide the port number of the HTTP proxy to use to connect to ServiceNow."/>
      </property>
      <property name="proxyUser">
        <property-ui type="textBox"
                     label="HTTP Proxy User name"
                     description="Provide the user name to authenticate with HTTP proxy."/>
      </property>
      <property name="proxyPass">
        <property-ui type="secureBox"
                     label="HTTP Proxy Password"
                     description="Provide the password to authenticate with HTTP proxy."/>
      </property>
      <property name="newAPI">
        <property-ui type="checkBox"
                     label="Use New ServiceNow API"
                     description="Check this box if you are using ServiceNow version Eureka or later."/>
      </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/log4j.jar;lib/CommonsUtil.jar;lib/httpclient.jar:lib/httpcore.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/commons-lang3.jar:lib/commons-lang.jar:lib/commons-beanutils.jar:lib/commons-collections.jar:lib/commons-codec.jar:lib/HttpComponents-Util.jar"/>
      <arg file="delete_row.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
  
  <step-type name="Delete Multiple Rows From CMDB Table">
    <description>Deletes multiple rows from the specified table in the ServiceNow CMDB that match some condition.</description>
    <properties>
      <property name="serverUrl" required="true">
        <property-ui type="textBox"
                     label="Server URL"
                     description="The URL of your ServiceNow portal. Example: https://myaccount.service-now.com"/>
      </property>
      <property name="username" required="true">
        <property-ui type="textBox"
                     label="ServiceNow User name"
                     description="Provide the user name to authenticate with ServiceNow."/>
      </property>
      <property name="password" required="true">
        <property-ui type="secureBox"
                     label="ServiceNow Password"
                     description="Provide the password to authenticate with ServiceNow."/>
      </property>
      <property name="table" required="true">
        <property-ui type="textBox"
                     label="CMDB Table Name"
                     description="The name of the table to update. Example: cmdb_ci_appl_list"/>
      </property>
      <property name="condition" required="true">
        <property-ui type="textBox"
                     label="CMDB Row Condition"
                     description="The condition a row must match for deletion. See http://wiki.servicenow.com/index.php?title=Embedded:Encoded_Query_Strings for examples"/>
      </property>
      <property name="proxyHost">
        <property-ui type="textBox"
                     label="HTTP Proxy Host"
                     description="Provide the hostname of the HTTP proxy to use to connect to ServiceNow. Eg proxy.domain.com"/>
      </property>
      <property name="proxyPort">
        <property-ui type="textBox"
                     label="HTTP Proxy Port"
                     description="Provide the port number of the HTTP proxy to use to connect to ServiceNow."/>
      </property>
      <property name="proxyUser">
        <property-ui type="textBox"
                     label="HTTP Proxy User name"
                     description="Provide the user name to authenticate with HTTP proxy."/>
      </property>
      <property name="proxyPass">
        <property-ui type="secureBox"
                     label="HTTP Proxy Password"
                     description="Provide the password to authenticate with HTTP proxy."/>
      </property>
      <property name="newAPI">
        <property-ui type="checkBox"
                     label="Use New ServiceNow API"
                     description="Check this box if you are using ServiceNow version Eureka or later."/>
      </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/log4j.jar;lib/CommonsUtil.jar;lib/httpclient.jar:lib/httpcore.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/commons-lang3.jar:lib/commons-lang.jar:lib/commons-beanutils.jar:lib/commons-collections.jar:lib/commons-codec.jar:lib/HttpComponents-Util.jar"/>
      <arg file="delete_multiple_rows.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

</plugin>
