<?xml version="1.0" encoding="UTF-8" ?>
<package name="service-mgmt" version="v0.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="plugin-config-v2.xsd">

    <!-- 1.依赖分析 - 描述运行本插件包需要的其他插件包 -->
    <packageDependencies>
    </packageDependencies>

    <!-- 2.菜单注入 - 描述运行本插件包需要注入的菜单 -->
    <menus>
        <menu code='JOBS_SERVICE_CATALOG_MANAGEMENT' cat='JOBS' displayName="Servive Catalogs" localDisplayName="服务目录管理">/service-mgmt/service-catalog</menu>
        <menu code='JOBS_TASK_MANAGEMENT' cat='JOBS' displayName="Tasks" localDisplayName="任务管理">/service-mgmt/task-management</menu>
    </menus>

    <!-- 3.数据模型 - 描述本插件包的数据模型,并且描述和Framework数据模型的关系 -->
    <dataModel>
        <entity name="serviceCatalogue" displayName="服务目录" description="服务目录模型">
            <attribute name="id" datatype="str" description="唯一ID"/>
            <attribute name="name" datatype="str" description="目录名称"/>
            <attribute name="status" datatype="str" description="状态"/>
        </entity>
        <entity name="servicePipeline" displayName="服务通道" description="服务通道模型">
            <attribute name="id" datatype="str" description="唯一ID"/>
            <attribute name="serviceCatalogueId" datatype='ref' description="所属服务目录"
                       refPackage="" refVersion="" refEntity="serviceCatalogue" ref="id"/>
            <attribute name="name" datatype="str" description="通道名称"/>
            <attribute name="description" datatype="str" description="描述"/>
            <attribute name="ownerRole" datatype="str" description="所属角色"/>
            <attribute name="status" datatype="str" description="状态"/>
        </entity>
        <entity name="serviceRequestTemplate" displayName="服务请求模板" description="服务请求模板模型">
            <attribute name="id" datatype="str" description="唯一ID"/>
            <attribute name="servicePipelineId" datatype='ref' description="所属服务通道"
                       refPackage="" refVersion="" refEntity="servicePipeline" ref="id"/>
            <attribute name="name" datatype="str" description="模板名称"/>
            <attribute name="description" datatype="str" description="描述"/>
            <attribute name="processDefinedKey" datatype="str" description="编排唯一Key"/>
            <attribute name="status" datatype="str" description="状态"/>
        </entity>
        <entity name="serviceRequest" displayName="服务请求" description="服务请求模型">
            <attribute name="id" datatype="str" description="唯一ID"/>
            <attribute name="templateId" datatype='ref' description="所属服务模板"
                       refPackage="" refVersion="" refEntity="serviceRequestTemplate" ref="id"/>
            <attribute name="name" datatype="str" description="请求名称"/>
            <attribute name="reporter" datatype="str" description="上报人"/>
            <attribute name="reporterRoleId" datatype="str" description="上报角色ID"/>
            <attribute name="reportTime" datatype="timestamp" description="上报时间"/>
            <attribute name="emergency" datatype="str" description="紧急程度"/>
            <attribute name="description" datatype="str" description="描述"/>
            <attribute name="attachFileId" datatype='ref' description="附件ID"
                       refPackage="" refVersion="" refEntity="attachFile" ref="id"/>
            <attribute name="result" datatype="str" description="结果"/>
            <attribute name="status" datatype="str" description="状态"/>
            <attribute name="envType" datatype="str" description="所属环境"/>
            <attribute name="requestNo" datatype="int" description="请求单号"/>
        </entity>
        <entity name="attachFile" displayName="附件信息" description="附件信息模型">
            <attribute name="id" datatype="str" description="唯一ID"/>
            <attribute name="attachFileName" datatype="str" description="附件名称"/>
            <attribute name="s3Url" datatype="str" description="文件临时地址"/>
            <attribute name="s3BucketName" datatype="str" description="文件所在桶"/>
            <attribute name="s3KeyName" datatype="str" description="文件名称"/>
        </entity>
        <entity name="task" displayName="任务" description="任务模型">
            <attribute name="id" datatype="str" description="唯一ID"/>
            <attribute name="serviceRequestId" datatype='ref' description="所属服务请求"
                       refPackage="" refVersion="" refEntity="serviceRequest" ref="id"/>
            <attribute name="callbackUrl" datatype="str" description="回调url"/>
            <attribute name="name" datatype="int" description="任务名称"/>
            <attribute name="reporter" datatype="str" description="上报人"/>
            <attribute name="reportTime" datatype="timestamp" description="上报时间"/>
            <attribute name="operatorRole" datatype="str" description="操作角色ID"/>
            <attribute name="operator" datatype="str" description="操作人"/>
            <attribute name="operatorTime" datatype="timestamp" description="操作时间"/>
            <attribute name="inputParameters" datatype="int" description="输入参数"/>
            <attribute name="description" datatype="str" description="描述"/>
            <attribute name="result" datatype="int" description="结果"/>
            <attribute name="resultMessage" datatype="int" description="处理结果"/>
            <attribute name="status" datatype="str" description="状态"/>
            <attribute name="callbackParameter" datatype="str" description="唯一回调参数"/>
        </entity>
    </dataModel>
    
    <!-- 4.系统参数 - 描述运行本插件包需要的系统参数 -->
    <systemParameters>
    </systemParameters>

    <!-- 5.权限设定 -->
    <authorities>
        <authority systemRoleName="SUPER_ADMIN">
            <menu code="JOBS_SERVICE_CATALOG_MANAGEMENT"/>
            <menu code="JOBS_TASK_MANAGEMENT"/>
        </authority>
    </authorities>

    <!-- 6.运行资源 - 描述部署运行本插件包需要的基础资源(如主机、虚拟机、容器、数据库等) -->
    <resourceDependencies>
        <docker imageName="service-mgmt:v0.4.1" containerName="service-mgmt-v0.4.1" portBindings="{{ALLOCATE_PORT}}:21000" volumeBindings="{{BASE_MOUNT_PATH}}/service-mgmt/log:/log,/etc/localtime:/etc/localtime" envVariables="DB_HOST={{DB_HOST}},DB_PORT={{DB_PORT}},DB_SCHEMA={{DB_SCHEMA}},DB_USER={{DB_USER}},DB_PWD={{DB_PWD}},CORE_ADDR={{CORE_ADDR}},S3_ENDPOINT={{S3_SERVER_URL}},S3_ACCESS_KEY={{S3_ACCESS_KEY}},S3_SECRET_KEY={{S3_SECRET_KEY}}"/>
        <mysql schema="service_mgmt" initFileName="init.sql" upgradeFileName="upgrade.sql"/>
    </resourceDependencies>

    <!-- 7.插件列表 - 描述插件包中单个插件的输入和输出 -->
    <plugins>
        <plugin name="task" targetPackage="" targetEntity="" registerName="" targetEntityFilterRule="">
            <interface action="create" path="/service-mgmt/v1/tasks" isAsyncProcessing="Y" type="APPROVAL" filterRule="">
                <inputParameters>
                    <parameter datatype="string" required="Y" sensitiveData="N" mappingType="system_variable" mappingSystemVariableName="CALLBACK_URL">callbackUrl</parameter>
                    <parameter datatype="string" required="Y" sensitiveData="N" mappingType="constant">taskName</parameter>
                    <parameter datatype="string" required="Y" sensitiveData="N" mappingType="constant">roleName</parameter>
                    <parameter datatype="string" required="N" sensitiveData="N" mappingType="constant">reporter</parameter>
                    <parameter datatype="string" required="N" sensitiveData="N" mappingType="constant">taskDescription</parameter>
                </inputParameters>
                <outputParameters>
                    <parameter datatype="string" sensitiveData="N" mappingType="context">errorCode</parameter>
                    <parameter datatype="string" sensitiveData="N" mappingType="context">errorMessage</parameter>
                    <parameter datatype="string" sensitiveData="N" mappingType="context">comment</parameter>
                </outputParameters>
            </interface>
        </plugin>

        <!--最佳实践-->

        <plugin name="task"  targetPackage="wecube-monitor" targetEntity="alarm" registerName="alarm" targetEntityFilterRule="">
            <interface action="create" path="/service-mgmt/v1/tasks" isAsyncProcessing="Y" type="APPROVAL" filterRule="">
                <inputParameters>
                    <parameter datatype="string" required="Y" sensitiveData="N" mappingType="system_variable" mappingSystemVariableName="CALLBACK_URL">callbackUrl</parameter>
                    <parameter datatype="string" required="Y" sensitiveData="N" mappingType="entity" mappingEntityExpression="wecube-monitor:alarm.subject">taskName</parameter>
                    <parameter datatype="string" required="Y" sensitiveData="N" mappingType="entity" mappingEntityExpression="wecube-monitor:alarm.toRole">roleName</parameter>
                    <parameter datatype="string" required="N" sensitiveData="N" mappingType="system_variable" mappingSystemVariableName="MONITOR_MAIL_SENDER_USER">reporter</parameter>
                    <parameter datatype="string" required="Y" sensitiveData="N" mappingType="entity" mappingEntityExpression="wecube-monitor:alarm.content">taskDescription</parameter>
                </inputParameters>
                <outputParameters>
                    <parameter datatype="string" sensitiveData="N" mappingType="context">errorCode</parameter>
                    <parameter datatype="string" sensitiveData="N" mappingType="context">errorMessage</parameter>
                    <parameter datatype="string" sensitiveData="N" mappingType="context">comment</parameter>
                </outputParameters>
            </interface>
        </plugin>
        <plugin name="task" targetPackage="" targetEntity="" registerName="custom" targetEntityFilterRule="">
            <interface action="create" path="/service-mgmt/v1/tasks" isAsyncProcessing="Y" type="APPROVAL" filterRule="">
                <inputParameters>
                    <parameter datatype="string" required="Y" sensitiveData="N" mappingType="system_variable" mappingSystemVariableName="CALLBACK_URL">callbackUrl</parameter>
                    <parameter datatype="string" required="Y" sensitiveData="N" mappingType="constant">taskName</parameter>
                    <parameter datatype="string" required="Y" sensitiveData="N" mappingType="constant">roleName</parameter>
                    <parameter datatype="string" required="N" sensitiveData="N" mappingType="constant">reporter</parameter>
                    <parameter datatype="string" required="Y" sensitiveData="N" mappingType="constant">taskDescription</parameter>
                </inputParameters>
                <outputParameters>
                    <parameter datatype="string" sensitiveData="N" mappingType="context">errorCode</parameter>
                    <parameter datatype="string" sensitiveData="N" mappingType="context">errorMessage</parameter>
                    <parameter datatype="string" sensitiveData="N" mappingType="context">comment</parameter>
                </outputParameters>
            </interface>
        </plugin>
    </plugins>
</package>
