REST接口


[CONFIG] 配置管理

Config management.

  • /config/get

    • Method

      GET

    • Params

      key=[string]

  • /config/set

    • Method

      POST

    • Params

      key=[string] value=[string] ttl=[int]

  • /config/del

    • Method

      POST

    • Params

      key=[string]

  • /config/export

    • Method

      GET

    • Params

      key=[string]

  • /config/import

    • Method

      POST

    • Params

      key=[string]

  • Success Response:

    • Code: 200

      Content: { status:"ok", message:{...}}

  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Get configure
    $.ajax({
        url: '/config/get',
        dataType: 'json',
        type: 'GET',
        data: {key:"/matrix/test"},
        success: function(data) {
          console.log(data);
        }
    });
    
    // Set configure
    $.ajax({
        url: '/config/set',
        dataType: 'json',
        type: 'POST',
        data: {key:"/matrix/test", value:"Hello"},
        success: function(data) {
          console.log(data);
        }
    });
    
    // Delete configure
    $.ajax({
        url: '/config/del',
        dataType: 'json',
        type: 'POST',
        data: {key:"/matrix/test"},
        success: function(data) {
          console.log(data);
        }
    });
    
    // Export to configure from key recursive.
    $.ajax({
        url: '/config/export',
        dataType: 'json',
        type: 'GET',
        data: {key:"/matrix/test"},
        success: function(data) {
          console.log(data);
        }
    });
    
    // Import to configure from key recursive.
    var form = new FormData();
    form.append("uploadfile", "/Desktop/config_export_20190505170559.json");
    form.append("key", "/matrix/test");
    $.ajax({
        url: '/config/import',
        dataType: 'json',
        type: 'POST',
        data: form,
        mimeType: "multipart/form-data",
        success: function(data) {
          console.log(data);
        }
    });
    

[OMDB] 对象库类管理

OMDB Schema view.

  • /mxobject/schema/class/list

    • Method

      GET

    • Params

      id=[string]

  • /mxobject/schema/class/tree

    • Method

      GET

    • Params

      id=[string]

  • /mxobject/schema/class/fields

    • Method

      GET

    • Params

      id=[int]

  • /mxobject/schema/class

    • Method

      GET class=[string]

      DELETE cid=[string]

  • Success Response:

    • Code: 200

      Content: { status:"ok", message:{...}}

  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Get class info and subclass name
    $.ajax({
        url: '/mxobject/schema/class/list',
        dataType: 'json',
        type: 'GET',
        data: {id:"/matrix"},
        success: function(data) {
          console.log(data);
        }
    });
    
    // Get class tree
    $.ajax({
        url: '/mxobject/schema/class/tree',
        dataType: 'json',
        type: 'GET',
        data: {id:"/matrix"},
        success: function(data) {
          console.log(data);
        }
    });
    

[MQL] MQL访问对象库

Returns json data about mql.

  • URL

    /mxobject/mql

  • Method:

    GET POST

  • URL Params

    mql=[string] meta=true

  • Body

    mql string

  • Success Response:

    • Code: 200

      Content: { status:"ok", message:[{}, {}, ...] }

  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    $.ajax({
        url: '/mxobject/mql',
        dataType: 'json',
        type: 'GET',
        data: {mql:"select * from /matrix/devops/event"},
        success: function(data) {
          console.log(data);
        }
    });
    

[EXPORT] ODB数据导出

Export odb data.

  • URL

    /mxobject/export

  • Method:

    GET

  • URL Params

    class=[string] recursive=[bool] limit=[int] filetype=[mql | xlsx] template=[bool] ignorefields=[string] ignoreclass=[string] relation_defined=[bool]

  • Body

    None

  • Success Response:

    • Code: 200

      Content: { status:"ok", message:[{}, {}, ...] }

  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Export mql script
    $.ajax({
        url: '/mxobject/export?recursive=true&class=' + encodeURIComponent('/matrix/entity'),
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
          console.log(data);
        }
    });
    
    // Export xlsx
    $.ajax({
        url: '/mxobject/export?recursive=true&filetype=xlsx&ignorefields=refer,runon&class=' + encodeURIComponent('/matrix/entity') + '&ignoreclass=' + encodeURIComponent('/matrix/entity/cassandra'),
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
          console.log(data);
        }
    });
    
    // Export xlsx template
    $.ajax({
        url: '/mxobject/export?recursive=true&filetype=xlsx&templdate=true&class=' + encodeURIComponent('/matrix/entity'),
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
          console.log(data);
        }
    });
    

[IMPORT] ODB数据导入

Export odb data.

  • URL

    /mxobject/import

  • Method:

    POST

  • URL Params

    None

  • Body

    None

  • Success Response:

    • Code: 200

      Content: { status:"ok", message:[{}, {}, ...] }

  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    var form = new FormData();
    form.append("uploadfile", "odb_expoort_matrix_test_20190304113300.mql");
    $.ajax({
        url: '/mxobject/import',
        dataType: 'json',
        type: 'POST',
        data: form,
        mimeType: "multipart/form-data",
        success: function(data) {
          console.log(data);
        }
     });
    

[IMPORTCLASS] ODB创建类模板导入

Export odb data.

  • URL

    /mxobject/importclass

  • Method:

    POST

  • URL Params

    None

  • Body

    None

  • Success Response:

    • Code: 200

      Content: { status:"ok", message:[{}, {}, ...] }

  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    var form = new FormData();
    form.append("uploadfile", "odb_class_template.xlsx");
    $.ajax({
        url: '/mxobject/importclass',
        dataType: 'json',
        type: 'POST',
        data: form,
        mimeType: "multipart/form-data",
        success: function(data) {
          console.log(data);
        }
     });
    



[SEARCH] 一键搜索访问对象库

Returns json data about search.

  • URL

    /mxobject/search

  • Method:

    GET POST

  • URL Params

    cond=[string] meta=true

  • Body

    cond string

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{id:"1",...}, meta:{} }
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

      $.ajax({
        url: '/mxobject/search',
        dataType: 'json',
        type: 'GET',
        data: {cond:'ERROR | top 2'},
        success: function(data) {
          console.log(data);
        }
      });
    

[OMDB SYSTEM] 对象库系统表查询

Returns json data about search.

  • URL

    /mxobject/system/schema/:table

  • Method:

    GET POST

  • URL Params

    None

  • Data Params

    None

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{id:"1",...}, meta:{} }
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

      $.ajax({
        url: '/mxobject/system/schema/ftype',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
          console.log(data);
        }
      });
    



[USER] 用户管理

User Management.

  • /user/login

    • Description

      User login

    • Method

      POST

    • Form Params

      username=[string] password=[string] company=[string] remember=[bool]

  • /user/goauth

    • Description

      User Authentication

    • Method

      POST

    • Form Params

      username=[string] password=[string]

  • /user/vali_password

    • Description

      User Authentication

    • Method

      POST

    • Body

      password string

  • /admin/users

    • Description

      Get user tree

    • Method

      GET

    • Params

      fullname=[string]

  • /admin/users/new

    • Description

      Add user

    • Method

      POST

    • JSON Params

      {
          "parent":    "string",      // required
          "username":  "string",      // required
          "passwd":    "string",      // required
          "auth":      "string",
          "otype":     "usr | org",   // required
          "grpset":    ["string"...],
          "lastname":  "string",
          "firstname": "string",
          "gender":    "string",
          "address":   "string",
          "email":     ["string"...],
          "wechat":    "string",
          "mobile":     ["string"...],
          "telephone": ["string"...],
          "remark":     "string",
          "status":     int,
          "isadmin":   true | false,  // required
          "isactive":  true | false,  // required
          "config":    {"string":"string"},
      }
      
  • /admin/users/:userid:

    • Description

      Update user info

    • Method

      POST

    • JSON Params

      {
          "auth":      "string",
          "grpset":    ["string"...],
          "lastname":  "string",
          "firstname": "string",
          "gender":    "string",
          "address":   "string",
          "email":     ["string"...],
          "wechat":    "string",
          "mobile":     ["string"...],
          "telephone": ["string"...],
          "remark":     "string",
          "status":     int,
          "isadmin":   true | false,
          "isactive":  true | false,
          "config":    {"string":"string"},
      }
      
  • /admin/users/:userid:

    • Description

      Delete user

    • Method

      DELETE

    • Form Params

      None

  • /admin/users/:userid:

    • Description

      Move user to org

    • Method

      GET

    • Params

      to=[string]

    • Success Response:

      • Code: 200
        Content: { status:"ok", message:"uid"}
  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Verify password strength
    $.ajax({
        url: '/admin/users',
        type: 'POST',
        contentType: 'text/plain',
        dataType: 'json',
        data: '1qaZ2wsX!!',
        success: function(data) {
          console.log(data);
      }
    });
    
    // Get user tree  
    $.ajax({
        url: '/admin/users',
        dataType: 'json',
        type: 'GET',
        data: {fullname:'/'},
        success: function(data) {
          console.log(data);
        }
    });
    
    // Add user
    $.ajax({
        url: '/admin/users/new',
        dataType: 'json',
        type: 'POST',
        data: {username:'testuser', parent:'/用户组', otype:'usr', isadmin:false, isactive: true},
        success: function(data) {
          console.log(data);
        }
    });
    
    // Delete user
    $.ajax({
        url: '/admin/users/15305020520705546474',
        dataType: 'json',
        type: 'DELETE',
        data: {},
        success: function(data) {
          console.log(data);
        }
    });
    
    // Update user
    $.ajax({
        url: '/admin/users/8941079917762102962',
        dataType: 'json',
        type: 'POST',
        data: {firstname:'Hui', lastname:'Li'}, // Other attr is empty
        success: function(data) {
          console.log(data);
        }
    });
    
    // Move user to org
    $.ajax({
        url: '/admin/users/15305020520705546474?to=5563373778940200553',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
          console.log(data);
        }
    });
    



[DFS] 分布式文件系统

Distributed file system.

  • /fs/:filepath

    • Method

      GET POST(upload) DELETE PUT

    • Params

      type=[file|dir|attr|download|open|tag|check] issys=[bool] index=[bool]

    • Form

      attr=[string] data=[string] uploadfile=[file] tags=[multi-string]

  • /fs/rename

    • Method

      POST

    • Params

      srcpath=[string] dstpath=[string] issys=[bool]

  • /fs/copy

    • Method

      POST

    • Params

      srcpath=[string] dstpath=[string] issys=[bool]

  • /fs/move

    • Method

      POST

    • Params

      srcpath=[string] dstpath=[string] issys=[bool]

  • /fs/push/:filepath

    • Method

      POST

    • Params

      issys=[bool] version=[string <required>]

  • /fs/pull/:filepath

    • Method

      POST

    • Params

      issys=[bool] version=[string <required>]

  • /fs/search/:filepath

    • Method

      GET

    • Params

      issys=[bool] query=[string]

  • /fs/index/:filepath

    • Method

      POST

    • Params

      issys=[bool]

    • Supported formats

      • text

        ALL

      • binary

        .docx .xlsx .pdf

  • /fs/tolocal/:filepath

    • Description

      Sync dfs file or dir to local file. dfs: /app -> fs: $WEBROOT/public/local/\<keyspace\>/app

    • Method

      POST

    • Params

      issys=[bool]

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}} file
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // show dir
    $.ajax({
        url: '/fs/test?type=dir',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
          console.log(data);
        }
    });
    
    // set attr
    var form = new FormData();
    form.append("attr", "/script");
    $.ajax({
        url: '/fs/test?type=attr',
        dataType: 'json',
        type: 'PUT',
        data: form,
        success: function(data) {
          console.log(data);
        }
    });
    
    // rename
    $.ajax({
        url: '/fs/rename',
        dataType: 'json',
        type: 'POST',
        data: {srcpath:'/home/1.txt', dstpath:'/home/2.txt'},
        success: function(data) {
          console.log(data);
        }
    });
    
    // copy
    $.ajax({
        url: '/fs/copy',
        dataType: 'json',
        type: 'POST',
        data: {srcpath:'/home/1.txt', dstpath:'/home2'},
        success: function(data) {
          console.log(data);
        }
    });
    
    // move
    $.ajax({
        url: '/fs/move',
        dataType: 'json',
        type: 'POST',
        data: {srcpath:'/home/1.txt', dstpath:'/home2'},
        success: function(data) {
          console.log(data);
        }
    });
    
    // push file or dir to server
    $.ajax({
        url: '/fs/push/test?version=v1&issys=true', // push dfs /test dir to server /test
        dataType: 'json',
        type: 'POST',
        data: {},
        success: function(data) {
            // return change file count
            console.log(data);
        }
    });
    
    // pull file or dir from server
    $.ajax({
        url: '/fs/pull/test?version=v1&issys=true', // pull dfs /test dir from server /test
        dataType: 'json',
        type: 'POST',
        data: {},
        success: function(data) {
            // return change file count
            console.log(data);
        }
    });
    
    // check file exists
    $.ajax({
        url: '/fs/home/1.txt?type=check',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
          console.log(data);
        }
    });
    
    // export file, '.zip' file
    var form = new FormData();
    form.append("srcpath", "/script");
    $.ajax({
        url: '/fs/export?issys=true',
        processData: false,
        contentType: false,
        mimeType: "multipart/form-data",
        dataType: 'json',
        type: 'POST',
        data: form,
        success: function(data) {
          console.log(data);
        }
    });
    
    // import file, must be '.zip' file
    var form = new FormData();
    form.append("uploadfile", "script.zip"); // file
    $.ajax({
        url: '/fs/export?issys=true&depth=3',
        processData: false,
        contentType: false,
        mimeType: "multipart/form-data",
        dataType: 'json',
        type: 'POST',
        data: {uploadfile:'script.zip'},
        success: function(data) {
          console.log(data);
        }
    });
    
    // search word 'hello' in /test
    $.ajax({
        url: '/fs/search/test?issys=true&query=hello',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
          console.log(data);
        }
    });
    
    // index file path /test
    $.ajax({
        url: '/fs/index/test?issys=true',
        dataType: 'json',
        type: 'POST',
        data: {},
        success: function(data) {
          console.log(data);
        }
    });
    
    // sync dfs dir /test to local file $WEBROOT/public/local/<keyspace>/test
    // access: <protocol://host:port>/local/<keyspace>/test/1.html
    $.ajax({
        url: '/fs/tolocal/test?issys=true',
        dataType: 'json',
        type: 'POST',
        data: {},
        success: function(data) {
          console.log(data);
        }
    });
    



[STATIC] 分布式文件静态资源访问

Distributed file system.

  • /static/:filepath

    • Method

      GET

    • Params

      None

    • Form

      None

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}} file
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Read static file
    $.ajax({
        url: '/static/app/HelloWorld.html',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
          console.log(data);
        }
    });
    



[JOB] 调度器任务

Job management.

  • /job

    • Description

      Get job list

    • Method

      GET

    • Params

      None

  • /job/:jobname

    • Description

      Get job info

    • Method

      GET

    • Params

      None

  • /job/exec/:jobname

    • Method

      GET

    • Params

      param=[string] receive_output=[bool] timeout=[int]

  • /job/batch

    • Description

      Batch to execute job

    • Method

      POST

    • JSON Params

      {
          "jobs": [
              {
                  "name": "string", // Job full name, required
                  "param": "string", // Job param json string
                  "timeout": 5 // required
              } // Job list
          ],
          "timeout": 5 // batch timeout, if timeout >= 0, waiting to receive output mode
      }
      
  • /job

    • Description

      Add or Edit job

    • Method

      POST PUT

    • Params

      name=[string] dir=[string] description=[string] group=[string] groupmode=[one | parallel | sequence] host=[multi-string] begin=[string] end=[string] exec=[multi-string] schedule=[string] timeout=[int] algorithm=[string] limit=[int] enable=[int] queue=[string] tag=[multi-string]

  • /job/merge

    • Description

      Merge job

    • Method

      POST

    • Params

      name=[string] dir=[string] description=[string] group=[string] groupmode=[one | parallel | sequence] host=[multi-string] begin=[string] end=[string] exec=[multi-string] schedule=[string] timeout=[int] algorithm=[string] limit=[int] enable=[int] queue=[string] tag=[multi-string]

  • /job/exist/:jobname

    • Description

      Check if the job exists

    • Method

      GET

  • /job/enable/:jobname

    • Description

      Enable job

    • Method

      GET

  • /job/disable/:jobname

    • Description

      Disable job

    • Method

      GET

  • /job/sync

    • Description

      Sync job from etcd to db

    • Method

      GET

  • /job/context/:sid

    • Description

      Job context

    • Method

      GET POST PUT DELETE

    • Params

      name=[string] value=[string] ttl=[int] clear=[bool] prefix=[string]

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Get job list
    $.ajax({
        url: '/job',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get job
    $.ajax({
        url: '/job/A@test',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Exec job
    $.ajax({
        url: '/job/exec/A@test',
        dataType: 'json',
        type: 'GET',
        data: {param:'{"cmd":"ls","HOST!":"mxsvr"}'},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Exec batch jobs
    var data = {
        'jobs':[
            {'name': 'testjob@system/test', 'timeout': 10, 'param': '{"HOST!":"wecise"}'},
            {'name': 'testjob2@system/test', 'timeout': 10}
        ],
        'timeout':12
    }
    $.ajax({
        url: '/job/batch',
        dataType: 'json',
        contentType: 'application/json'
        type: 'POST',
        data: data,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Add job
    var form = new FormData();
    form.append("name", "A");
    form.append("dir", "test");
    form.append("exec", "echo");
    form.append("arg", "a2");
    form.append("argenc", "true");
    form.append("groupmode", "sequence");
    form.append("enable", "1");
    form.append("host", "wecise");
    form.append("host", "wecise2");
    form.append("tag", "jobtest1");
    form.append("tag", "jobtest2");
    form.append("schedule", "cron */1 * * * *");
    $.ajax({
        url: '/job',
        dataType: 'json',
        type: 'POST',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Merge job
    var form = new FormData();
    form.append("name", "A");
    form.append("dir", "test");
    form.append("exec", "echo a2");
    form.append("groupmode", "sequence");
    form.append("enable", "1");
    form.append("host", "wecise");
    form.append("host", "wecise2");
    form.append("tag", "jobtest1");
    form.append("tag", "jobtest2");
    form.append("schedule", "cron */1 * * * *");
    $.ajax({
        url: '/job/merge',
        dataType: 'json',
        type: 'POST',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Check job exists
    $.ajax({
        url: '/job/exist/A@test',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete job
    $.ajax({
        url: '/job/A@test',
        dataType: 'json',
        type: 'DELETE',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Sync etcd job to db
    $.ajax({
        url: '/job/sync',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Enable job
    $.ajax({
        url: '/job/enable/A@test',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Disable job
    $.ajax({
        url: '/job/disable/A@test',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Merge job context
    $.ajax({
        url: '/job/context/M201805171740:66591616470',
        dataType: 'json',
        type: 'PUT',
        data: {name:'test', value:'test value', ttl:864000}, // 'test' context save 10 days
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get job context
    $.ajax({
        url: '/job/context/M201805171740:66591616470',
        dataType: 'json',
        type: 'GET',
        data: {prefix:'A'}, // If prefix is empty, get all attribute.
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete job context attribute
    // If clear all attribute, url set clear=true
    $.ajax({
        url: '/job/context/M201805171740:66591616470?name=status', 
        dataType: 'json',
        type: 'DELETE',
        data: {}, // 'test' context save 10 days
        success: function(data) {
            console.log(data);
        }
    });
    



[ENTITY] 实体(已取消)

Entity operation.

  • /entity

    • Method

      GET POST

    • Params

      id=[string]

    • Body

      [{"id":"xxx", "config":{}, "rels":{"contains":["xxx", "xxx"], "depends":["xxx", "xxx"]}}]

  • /entity/policy

    • Method

      GET

    • Params

      class=[string]

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // get entity by id
    $.ajax({
        url: '/entity',
        dataType: 'json',
        type: 'GET',
        data: {id:'host:test'},
        success: function(data) {
          console.log(data);
        }
    });
    
    // update entities relations
    $.ajax({
        url: '/entity',
        dataType: 'json',
        type: 'POST',
        data: '[{"id":"host:test", "config":{}, "rels":{"contain":["a:c", "b:m"], "depend":["x:a", "y:b"]}}]',
        success: function(data) {
          console.log(data);
        }
    });
    
    // get id policy
    $.ajax({
        url: '/entity/policy',
        dataType: 'json',
        type: 'GET',
        data: {class:'/matrix/entity/cassandra'},
        success: function(data) {
          // return column name
          console.log(data.message);
        }
    });
    

[ENTITY RULES] 实体规则(已取消)

Entity operation.

  • URL

    /entity/script

  • Method:

    GET PUT

  • URL Params

    id=[string] name=[string]

  • Form Params

    id=[string] name=[string] script=[string]

  • Body

    None

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    $.ajax({
        url: '/entity/script',
        dataType: 'json',
        type: 'GET',
        data: {id:'host:test'},
        success: function(data) {
          console.log(data);
        }
    });
    
    $.ajax({
        url: '/entity/script',
        dataType: 'json',
        type: 'PUT',
        data: {id:'host:test', name:'BPM', script:'--script'},
        success: function(data) {
          console.log(data);
        }
    });
    



[WEB CONTEXT] 缓存 (已取消)

Cache set or get.

  • URL

    /webcontext/:key

  • Method:

    GET PUT

  • URL Params

    rule=[string] ttl=[int]

  • Form Params

    None

  • Body

    string

  • Success Rdesponse:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // get
    $.ajax({
        url: '/webcontext/test',
        dataType: 'json',
        type: 'GET',
        data: {rule='test.lua'},
        success: function(data) {
          console.log(data);
        }
    });
    
    // set
    $.ajax({
        url: '/webcontext/test',
        dataType: 'json',
        type: 'PUT',
        data: "{\"name\":\"Tom\",\"age\":15}",
        success: function(data) {
          console.log(data);
        }
    });
    

[OMDB TRIGGER] 对象库触发器管理

Trigger management.

  • URL

    /mxobject/trigger

  • Method:

    GET PUT DELETE

  • URL Params

    class=[string] name=[string]

  • JSON Params

    {
        "class":"string",
        "name":"string",
        "script":"string",
        "attr":{
            "disable": "true | false",
            "before": "true | false",
            "level": "1"
        }
    }
    
  • Body

    None

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Get class triggers  
    $.ajax({
        url: '/mxobject/trigger?class=' + encodeURIComponent('/matrix/devops/event'),
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
      });
    
    // Add or update class trigger
    $.ajax({
        url: '/mxobject/trigger',
        contentType: "application/json", // Important attr
        dataType: 'json',
        type: 'PUT',
        data: {class:'/matrix/devops/event', name:'test', script:'log.info(OBJECT.id)', attr:{disable:'false', before: 'true', level: '1'}},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete class trigger
    $.ajax({
        url: '/mxobject/trigger?class=' + encodeURIComponent('/matrix/devops/event') + '&name=test',
        contentType: "application/x-www-form-urlencoded"
        dataType: 'json',
        type: 'DELETE',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    

[RULES] 对象库规则管理

Rules management.

  • URL

    /mxobject/rule GET PUT DELETE

    /maxobject/rule/new GET

  • Method:

    None

  • URL Params

    class=[string] key=[string]

  • Json

    {
        "class":"string",
        "type":"string", // text,json,csv,grok
        "fields":["PATTERN1","PATTERN2"...], // Required if type is 'grok'
        "mapping":{
            "classFieldName1":"PATTERN1",
            "classFieldName2":"PATTERN2",
            ...
        } // Required if type is 'grok'
    }
    
  • Form

    key=[string] value=[string]

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{id:"1",...}, meta:{} }
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Get rules by class
    $.ajax({
        url: '/mxobject/rule?class=' + encodeURIComponent('/matrix/test'),
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Insert or update rule
    $.ajax({
        url: '/mxobject/rule',
        dataType: 'json',
        type: 'PUT',
        data: {key:'/matrix/rules/test', value:'--keyspace = matrix...'},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete rule
    $.ajax({
        url: '/mxobject/rule?key=' + encodeURIComponent('/matrix/rules/test'),
        dataType: 'json',
        type: 'DELETE',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Create base rule by class
    var baseData = {
        "class":"/matrix/test",
        "type":"grok", // text,json,csv,grok
        "fields":["F1","F2"], // Required if type is 'grok'
        "mapping":{"test":"F1","test2":"F2"} // Required if type is 'grok'
    };
    $.ajax({
        url: '/mxobject/rule/new',
        contentType: 'application/json',
        dataType: 'json',
        type: 'POST',
        data: JSON.stringify(baseData),
        success: function(data) {
            console.log(data);
        }
    });
    

[SCRIPT API] 接口方法列表

Get API funcs.

  • URL

    /api/trigger/funcs

    /api/rule/funcs

  • Method:

    GET

  • URL Params

    None

  • Form Params

    None

  • Body

    None

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    $.ajax({
        url: '/trigger/funcs',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    $.ajax({
        url: '/rule/funcs',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    

[DFS PARSING] 文件系统文件解析

Parse file to odb.

  • URL

    /action/parsefile

  • Method:

    GET

  • URL Params

    rule=[string] filename=[string]

  • Form Params

    None

  • Body

    None

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    $.ajax({
        url: '/action/parsefile',
        dataType: 'json',
        type: 'GET',
        data: {rule='/matrix/devops/event', filename='/home/admin/test.csv'},
        success: function(data) {
            console.log(data);
        }
    });
    

[APPCONTEXT] 全局变量缓存

Appcontext cache.

  • /appcontext/:key

    • Method

      GET POST DELETE

    • Params

      ttl=[int]

    • Form

    • Body

      string

  • /appcontext/collection/:name/:id

    • Method

      GET POST PUT DELETE

    • Params

      ttl=[int] where=[string] type=[first|last|]

    • Form

    • Body

      jsonstring

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • JSON query expression

    ||
    &&
    = != > < >= <= ~= !~= is isnot
    + -
    * / %
    ^
    ( )
    
  • Example:

    // raw get
    $.ajax({
        url: '/appcontext/test',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // raw set
    $.ajax({
        url: '/appcontext/test?ttl=600',
        dataType: 'json',
        type: 'POST',
        data: "Hello world",
        success: function(data) {
            console.log(data);
        }
    });
    
    // collection get all
    $.ajax({
        url: '/appcontext/collection/game',
        dataType: 'json',
        type: 'GET',
        data: {where:"name ~= 'PES.*' || company = 'Nintendo'"},
        success: function(data) {
            console.log(data);
        }
    });
    
    // collection get last
    $.ajax({
        url: '/appcontext/collection/game?type=last',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // collection get
    $.ajax({
        url: '/appcontext/collection/game/4f370a0c-672a-11e8-a8d9-9eb6d01c8f95',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // collection create
    $.ajax({
        url: '/appcontext/collection/game?ttl=600',
        dataType: 'json',
        type: 'POST',
        data: '{"name":"Contra", "type":"act", "company":"Konami"}',
        success: function(data) {
            console.log(data);
        }
    });
    
    // collection update
    $.ajax({
        url: '/appcontext/collection/game/4f370a0c-672a-11e8-a8d9-9eb6d01c8f95?ttl=600',
        dataType: 'json',
        type: 'PUT',
        data: '{"name":"Super Mario", "type":"act", "company":"Nintendo"}',
        success: function(data) {
            console.log(data);
        }
    });
    
    // collection delete all
    $.ajax({
        url: '/appcontext/collection/game',
        dataType: 'json',
        type: 'DELETE',
        data: '',
        success: function(data) {
            console.log(data);
        }
    });
    
    // collection delete
    $.ajax({
        url: '/appcontext/collection/game/4f370a0c-672a-11e8-a8d9-9eb6d01c8f95',
        dataType: 'json',
        type: 'DELETE',
        data: '',
        success: function(data) {
            console.log(data);
        }
    });
    

[GROK] Grok样例管理

Grok patterns management.

  • URL

    /pattern GET

    /pattern/:name GET POST DELETE

  • Method:

    None

  • URL Params

    None

  • Form Params

    pattern=[string] eg=[string]

  • Body

    None

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // pattern list
    $.ajax({
        url: '/pattern',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // add pattern
    var form = new FormData();
    form.append("eg", "");
    form.append("pattern", "[0-9]+");
    $.ajax({
        url: '/pattern/MX_TEST',
        dataType: 'json',
        type: 'POST',
        mimeType: 'multipart/form-data',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // delete pattern
    $.ajax({
        url: '/pattern/MX_TEST',
        dataType: 'json',
        type: 'DELETE',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    

[JOB GROUP] 调度器组管理

Scheduler group management.

  • URL

    /group GET POST PUT

    /group/:gtype/:name DELETE

  • Method:

    None

  • URL Params

    None

  • JSON Params

    {
      "name": "string",
      "gtype": "string", // group | proxy
      "hosts": [
        {
          "host": "string",
          "proxy": "string",
          "port": "string",
          "username":"string",
          "password":"string"
        }
      ]
    }
    
  • Body

    None

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // group list
    $.ajax({
        url: '/group',
        dataType: 'json',
        type: 'GET',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // add group
    $.ajax({
        url: '/group',
        dataType: 'json',
        type: 'POST',
        headers: {
          content-type: 'application/json'
        },
        data: "{\"name\":\"test\",\"gtype\":\"group\",\"hosts\":[{\"host\":\"wecise1\"},{\"host\":\"wecise2\"},{\"host\":\"wecise3\"}]}",
        success: function(data) {
            console.log(data);
        }
    });
    
    // delete group
    $.ajax({
        url: '/group/group/test',
        dataType: 'json',
        type: 'DELETE',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    

[SCRIPT] 脚本调用及管理

Script excute and management.

  • URL

    /script/exec/js POST

  • Method:

    None

  • Params

    input=[string] isfile=[bool] filepath=[string] rawdata=[bool]

  • Body

    None

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Execute the js script
    $.ajax({
        url: '/script/exec/js?input=hello',
        dataType: 'json',
        type: 'POST',
        headers: {
            content-type: 'application/json'
        },
        data: "var ret = odb.mql(\"select id from /matrix/devops/event limit 1\");\nOUTPUT = JSON.stringify(ret) + INPUT;",
        success: function(data) {
            console.log(data);
        }
    });
    
    // Execute the js script from dfs file by POST
    $.ajax({
        url: '/script/exec/js?input=hello?isfile=true',
        dataType: 'json',
        type: 'POST',
        data: "test.js",
        success: function(data) {
            console.log(data);
        }
    });
    
    // Execute the js script from dfs file by GET
    $.ajax({
        url: '/script/exec/js?input=hello?filepath=test.js',
        dataType: 'json',
        type: 'GET',
        data: null,
        success: function(data) {
            console.log(data);
        }
    });
    

[MULTI-TENANT] 多租户管理

Multi-tenant management.

  • URL

    /companys/:name

  • Method:

    GET POST PUT DELETE

  • Params

    None

  • Body

    {
      "name": "wecise",
      "fullname": "Wecise Technology Co., Ltd.",
      "icon": "data:image/png;base64",
      "logo": "data:image/png;base64",
      "ospace": "matrix",
      "title": "M3",
      "web": "www.wecise.com",
      "config": {
        "replication_factor": "dc1:1"
      }
    }
    
  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // add company
    var com = {
        "name": "wecise",
        "fullname": "Wecise Technology Co., Ltd.",
        "icon": "data:image/png;base64",
        "logo": "data:image/png;base64",
        "ospace": "matrix",
        "title": "M3",
        "web": "www.wecise.com",
        "config": {
            "replication_factor": "dc1:1"
        }
    }
    $.ajax({
        url: '/companys',
        dataType: 'json',
        type: 'POST',
        headers: {
          content-type: 'application/json'
        },
        data: com,
        success: function(data) {
            console.log(data);
        }
    });
    
    // get company
    $.ajax({
        url: '/companys/wecise',
        dataType: 'json',
        type: 'GET',
        headers: {
            content-type: 'application/json'
        },
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // get company list
    $.ajax({
        url: '/companys',
        dataType: 'json',
        type: 'GET',
        headers: {
            content-type: 'application/json'
        },
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // delete company
    $.ajax({
        url: '/companys/wecise',
        dataType: 'json',
        type: 'DELETE',
        headers: {
            content-type: 'application/json'
        },
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // update company
    $.ajax({
        url: '/companys',
        dataType: 'json',
        type: 'PUT',
        headers: {
            content-type: 'application/json'
        },
        data: com,
        success: function(data) {
            console.log(data);
        }
    });
    

[NOTIFICATIONS] 订阅消息通知

Subscribe to message notifications.

  • URL

    /websocket/:subject

  • Method:

    GET

  • Params

    source=[string] title=[string]

  • Message

    {
      "keyspace": "matrix",
      "source": "test_source",
      "subject": "test_event",
      "title": "test_title",
      "reply": "",
      "msg": "Error event message: mxsvr01 is down."
    }
    
  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    var ws = new WebSocket('ws://127.0.0.1:8080/websocket/event?source=test_source&title=test_title');
    ws.addEventListener('message', function (ev) {
        console.log(ev.data);
    });
    ws.onmessage = function (ev) {
        console.log('Receive message');
        var message = JSON.parse(ev.data);
        console.log(message.subject);
        console.log(message.msg);
    };
    function closeWS() {
        ws.close(1000, 'close');
    }
    

[LICENSE] 系统许可管理

License import or view.

  • URL

    /license/import POST

    /license/info/:name GET

  • Method:

    None

  • Params

    None

  • Form

    uploadfile=[file]

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // import license
    var form = new FormData();
    form.append("uploadfile", "wecise.lic");
    $.ajax({
        url: '/license/import',
        dataType: 'json',
        type: 'POST',
        headers: {
            content-type: 'multipart/form-data',
        },
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // view license
    $.ajax({
        url: '/license/info/wecise',
        dataType: 'json',
        type: 'GET',
        headers: {
          content-type: 'application/json'
        },
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    

[HOST] 主机管理

Agent host managment.

  • URL

    /host GET POST

    /host/:name GET DELETE

  • Method:

    None

  • Params

    tag=[string] status=[bool]

  • JSON Params

    {
        "host": "string",
        "iplist": ["string"...],
        "isagent": 0 | 1,
        "domain": "string",
        "hostgroups": ["string"...],
        "sert": "string",
        "secret": "string",
        "config": {}
    }
    
  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Update host
    var host = {
        "host": "string",
        "iplist": ["string"...],
        "isagent": 0 | 1,
        "domain": "string",
        "hostgroups": ["string"...],
        "sert": "string",
        "secret": "string",
        "config": {"cpu":"80%", "status":"ok"}
    }
    $.ajax({
        url: '/host',
        dataType: 'json',
        type: 'POST',
        headers: {
            content-type: 'application/json'
        },
        data: JSON.stringify(host), // Must be json string, not json object
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get host list
    $.ajax({
        url: '/host?tag=linux&status=true',
        dataType: 'json',
        type: 'GET',
        headers: {
          content-type: 'application/json'
        },
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get host by name
    $.ajax({
        url: '/host/mxsvr1',
        dataType: 'json',
        type: 'GET',
        headers: {
            content-type: 'application/json'
        },
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete host by name
    $.ajax({
        url: '/host/mxsvr1',
        dataType: 'json',
        type: 'GET',
        headers: {
          content-type: 'application/json'
        },
        data: {},
        success: function(data) {
          console.log(data);
        }
    });
    

[DEPOT] 监控脚本管理

Monitoring depot managment.

  • Add depot

    • URL

      /monitoring/depot POST

    • Form Params

      name=[string] require

      version=[string] require

      remark=[string] optional

      tags=[multi-string] optional

      uploadfile=[multi-file] require

      command=[string] optional

  • Update depot

    • URL

      /monitoring/depot PUT

    • Form Params

      name=[string] require

      version=[string] require

      remark=[string] optional

      tags=[multi-string] optional

      uploadfile=[multi-file] require

      overwrite=[bool] optional

      command=[string] optional

  • Get depot list

    • URL

      /monitoring/depot GET

    • Params

      None

  • Delete depot

    • URL

      /monitoring/depot/:name DELETE

    • Params

      None

  • Get depot

    • URL

      /monitoring/depot/:name GET

    • Params

      version=[string] optional

  • Check depot exists

    • URL

      /monitoring/depot/exist/:name GET

    • Params

      version=[string] optional

  • Get depot file content

    • URL

      /monitoring/depot/file/:name GET

    • Params

      version=[string] require

      filepath=[string] require

  • Update depot file content to new version

    • URL

      /monitoring/depot/file/:name PUT

    • Form Params

      name=[string] require

      version=[string] require

      newVersion=[string] require

      remark=[string] optional

      tags=[multi-string] optional

      filepath=[string] require

      content=[string] optional

      type=[string: M | A | D] require

  • Compare versions

    • URL

      /monitoring/depot/diff/:name GET

    • Params

      version=[string] require

      compareVersion=[string] require

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Add depot
    var form = new FormData();
    form.append("name", "test");
    form.append("version", "1.0");
    form.append("remark", "This is test script");
    form.append("uploadfile", "test.sh");
    form.append("tags", "test");
    form.append("tags", "linux");
    form.append("command", "ls -a");
    $.ajax({
        url: '/monitoring/depot',
        dataType: 'json',
        type: 'POST',
        headers: {
            content-type: 'application/json'
        },
        processData: false,
        contentType: false,
        mimeType: "multipart/form-data",
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete depot
    $.ajax({
        url: '/monitoring/depot/test',
        dataType: 'json',
        type: 'DELETE',
        headers: {
            content-type: 'application/json'
        },
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Update depot
    var form = new FormData();
    form.append("name", "test");
    form.append("version", "1.1");
    form.append("remark", "This is test script");
    form.append("uploadfile", "test.sh");
    form.append("tags", "test");
    form.append("tags", "linux");
    form.append("overwrite", "true")
    form.append("command", "ls -a");
    $.ajax({
        url: '/monitoring/depot',
        dataType: 'json',
        type: 'PUT',
        headers: {
            content-type: 'application/json'
        },
        processData: false,
        contentType: false,
        mimeType: "multipart/form-data",
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get depot
    $.ajax({
        url: '/monitoring/depot/test?version=1.0',
        dataType: 'json',
        type: 'GET',
        headers: {
            content-type: 'application/json'
        },
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get depot list
    $.ajax({
        url: '/monitoring/depot',
        dataType: 'json',
        type: 'GET',
        headers: {
            content-type: 'application/json'
        },
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get depot file content
    $.ajax({
        url: '/monitoring/depot/file/test?version=1.0&filepath=testsh/test.sh',
        dataType: 'json',
        type: 'GET',
        headers: {
            content-type: 'application/json'
        },
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get depot diff files
    $.ajax({
        url: '/monitoring/depot/diff/test?version=1.0&compareVersion=1.1',
        dataType: 'json',
        type: 'GET',
        headers: {
            content-type: 'application/json'
        },
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Update depot file to new version
    var form = new FormData();
    form.append("name", "test");
    form.append("version", "1.0"); // Old version
    form.append("newVersion", "1.1") // new version
    form.append("remark", "This is test script");
    form.append("filepath", "tset/test.sh"); // relative path
    form.append("content", "./test.sh -cpu")
    form.append("type", "M") // type: M | A | D
    form.append("tags", "test");
    form.append("tags", "linux");
    $.ajax({
        url: '/monitoring/depot/file',
        dataType: 'json',
        type: 'PUT',
        headers: {
            content-type: 'application/json'
        },
        processData: false,
        contentType: false,
        mimeType: "multipart/form-data",
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    

[DEPLOY] 监控脚本部署管理

Monitoring depot deploy management.

  • URL

    /monitoring/deploy POST

    /monitoring/undeploy POST

  • Method:

    None

  • Params

    None

  • Form Params

    | Name | Type | Default | Required | Description | | ---------- | ------------ | ------- | -------- | --------------------------------- | | hosts | multi-string | | YES | | | depots | multi-string | | YES | | | versions | multi-string | | YES | Must match the number of 'depots' | | command | string | | NO | | | remotepath | string | | NO | | | timeout | int | 60 | NO | Secondes |

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Depot deploy
    var form = new FormData();
    form.append('hosts', 'mxsvr221');
    form.append('depots', "test");
    form.append('versions', "1.0");
    $.ajax({
        url: '/monitoring/deploy',
        dataType: 'json',
        type: 'POST',
        processData: false,
        contentType: false,
        mimeType: 'multipart/form-data',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Depot undeploy
    var form = new FormData();
    form.append('hosts', 'mxsvr221');
    form.append('depots', "test");
    form.append('versions', "1.0");
    $.ajax({
        url: '/monitoring/undeploy',
        dataType: 'json',
        type: 'POST',
        processData: false,
        contentType: false,
        mimeType: 'multipart/form-data',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    /*
    Deploy depot by SSH
    SSH host 的必要属性:
    {
        "host":"<host name>",
        "isagnet":1,
        "config":{
            "username":"<ssh username>",
            "password":"<ssh password>",
            "port":"<ssh port>"
        }
    }
    */
    var form = new FormData();
    form.append('hosts', 'mxsvr221');
    form.append('depots', "test");
    form.append('versions', "1.0");
    form.append('remotepath', '/opt/matrix/test');
    form.append('command', 'echo a > test.conf');
    $.ajax({
        url: '/monitoring/deploy',
        dataType: 'json',
        type: 'POST',
        processData: false,
        contentType: false,
        mimeType: 'multipart/form-data',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    

[POLICY] 监控策略管理

Monitoring policy management.

  • URL

    /monitoring/policy POST

    /monitoring/policy/:name DELETE

    /monitoring/policy/log POST

    /monitoring/policy/deploy/:name POST

    /monitoring/policy/undeploy/:name POST

    /monitoring/policy/extend/:rule GET POST

    /monitoring/policy/deploy/conf/:name PUT

    /monitoring/policy/undeploy/conf/:name DELETE

  • Method:

    None

  • Params

    None

  • JSON Params

    // cmd json
    {
      "name": "string", // required
      "rule": "string", // required
      "command": "string",  // required
      "depotname": "string", // if ctype = 0, not empty
      "depotversion": "string", // if ctype = 0, not empty
      "depotcommand": "string", // if need to deploy
      "ctype": 0 | 1,  // required
      "interval": int, // required
      "unit": "year | month | day | hour | minute | second", // required
      "split": true | false,
      "delimiter":"Regular expression",
      "delimitereol": true | false,
      "isdaemon": true | false,
      "tags": ["string"...],
      "hosts": ["string"...], // If not empty, then auto deploy
      "attrs":{"attrname1":"attrvalue", "attrname2":"attrvalue2"...} // toe protocol attrs
    }
    
    // log json
    {
      "name": "string", // required
      "rule": "string", // required
      "dir": "string", // required
      "match": "Regular expression", // required
      "matchregexp": "Regular expression", // filter log content
      "priority": ["string", "string"...], // for match
      "translation": {"string":{"string":int}...}, // for match to sort
      "differentiator": "string", // differentiator
      "delimiter":"Regular expression",
      "delimitereol": true | false,
      "tags": ["string"...],
      "hosts": ["string"...], // If not empty, then auto deploy
      "attrs":{"attrname1":"attrvalue", "attrname2":"attrvalue2"...} // toe protocol attrs
    }
    
    // log example
    // /var/log/nginx/sally.com/2014/Hadukannas/lunes/access.log
    // /var/log/nginx/sally.com/2014/Turmar/miercoles/access.log
    // /var/log/nginx/sally.com/2014/Karmabatas/jueves/access.log
    // /var/log/nginx/sally.com/2014/Karbasiyas/sabado/access.log
    {
      "match": "(?P<Domain>[^/]+)/(?P<Year>\\d+)/(?P<Month>\\s+)/(?P<Day>[^/])+/access\\.log",
      "priority": [
        "Year",
        "Month",
        "Day"
      ],
      "translation": {
        "Month": {
          "hadukannas": 1,
          "turmar": 2,
          "karmabatas": 4,
          "karbasiyas": 6
        },
        "Day": {
          "lunes": 1,
          "miercoles": 3,
          "jueves": 4,
          "sabado": 6
        }
      }
    }
    
  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Add cmd policy
    var data = '{
      "name": "test",
      "command": "test.sh",
      "depotname": "test",
      "depotversion": "1.1",
      "ctype": 0,
      "interval": 10,
      "unit": "second",
      "rule": "/matrix/rules/test",
      "hosts": [
        "mxsvr221"
      ],
      "split": true,
      "delimiter": "\n",
      "delimitereol":false,
      "isdaemon":false,
      "tags": [
        "test"
      ],
      "attrs": {}
    }';
    $.ajax({
        url: '/monitoring/policy',
        dataType: 'json',
        type: 'POST',
        headers: {
            content-type: 'application/json'
        },
        processData: false,
        data: data,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Add log policy
    var data = '{
      "name": "testlog",
      "rule": "/matrix/rules/log/etcd",
      "dir": "/opt/matrix/var/logs/etcd",
      "match": "out.log",
      "delimiter": "\n",
      "delimitereol": false,
      "hosts": [
        "mxsvr221"
      ],
      "tags": [
        "test"
      ],
      "attrs": {}
    }';
    $.ajax({
        url: '/monitoring/policy/log',
        dataType: 'json',
        type: 'POST',
        headers: {
            content-type: 'application/json'
        },
        processData: false,
        data: data,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete policy
    $.ajax({
        url: '/monitoring/policy/testpolicy',
        dataType: 'json',
        type: 'DELETE',
        headers: {
            content-type: 'application/json'
        },
        processData: false,
        data: data,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Deploy policy
    $.ajax({
        url: '/monitoring/policy/deploy/test',
        dataType: 'json',
        type: 'POST',
        headers: {
            content-type: 'application/json'
        },
        processData: false,
        contentType: false,
        data: data,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Undeploy policy
    $.ajax({
        url: '/monitoring/policy/undeploy/test',
        dataType: 'json',
        type: 'POST',
        headers: {
            content-type: 'application/json'
        },
        processData: false,
        contentType: false,
        data: data,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get policy extend
    $.ajax({
        url: '/monitoring/policy/extend/matrix/rules/test',
        dataType: 'json',
        type: 'GET',
        headers: {
            content-type: 'application/json'
        },
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Update policy extend (format type: ltsv)
    // ltsv detail http://ltsv.org/
    // ltsv delimiter: \t
    $.ajax({
        url: '/monitoring/policy/extend/matrix/rules/test',
        dataType: 'json',
        type: 'POST',
        headers: {
            content-type: 'application/json'
        },
        data: 'key:mxsvr201    val:127.0.0.1',
        success: function(data) {
            console.log(data);
        }
    });
    
    // Deploy policy conf
    var form = new FormData();
    form.append('hosts', 'wecise');
    form.append('hosts', 'wecise2');
    var conf = '[TestConfInput]\n' +
    'type = "LogstreamerInput"\n' + 
    'log_directory = "/opt/matrix/var/test"\n' + 
    'file_match = "test_bucket_object_conf.csv"\n' + 
    'splitter = "split_n"\n' + 
    '\n' + 
    '[TestConfOutput]\n' + 
    'type = "NatsOutput"\n' + 
    'is_streaming = true\n' + 
    'subject = "matrix.rules.test.bucket.object"\n' + 
    'reconnect = true\n' + 
    'message_matcher = "Logger == 'TestConfInput'"\n' + 
    'encoder = "PayloadEncoder"\n' + 
    'use_protocol = true\n' + 
    '[TestConfOutput.attr]'\n' + 
    form.append('conf', conf);
    $.ajax({
        url: '/monitoring/policy/deploy/conf/testconf',
        dataType: 'json',
        type: 'PUT',
        contentType: false,
        mimeType: 'multipart/form-data',
        processData: false,
        contentType: false,
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Undeploy policy conf
    $.ajax({
        url: '/monitoring/policy/undeploy/conf/testconf?hosts=wecise&hosts=wecise2',
        dataType: 'json',
        type: 'DELETE',
        processData: false,
        contentType: false,
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    

[ZABBIX] ZABBIX监控脚本部署管理

Zabbix monitoring depot deploy management.

  • /monitoring/zabbix/deploy

    • Method

      POST

    • Form Params

      hosts=[multi-string] name=[string] version=[string] key=[string] command=[string]

  • /monitoring/zabbix/undeploy

    • Method

      POST

    • Form Params

      hosts=[multi-string] name=[string] version=[string]

  • /monitoring/zabbix/start

    • Method

      POST

    • Form Params

      hosts=[multi-string]

  • /monitoring/zabbix/stop

    • Method

      POST

    • Form Params

      hosts=[multi-string]

  • /monitoring/zabbix/restart

    • Method

      POST

    • Form Params

      hosts=[multi-string]

  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    /*
    Deploy depot to zabbix agent by SSH
    /matrix/system/hostinfo的SSH host的必要属性:
    {
        "host":"<host name>",
        "isagnet":1,
        "iszabbix":1,
        "config":{
            "username":"<ssh username>",
            "password":"<ssh password>",
            "port":"<ssh port>",
            "zabbix_dir":"<zabbix agent daemon dir>",
            "zabbix_start":"<zabbix agent daemon start command>",
            "zabbix_stop":"<zabbix agent daemon stop command>"
        }
    }
    */
    
    // Deploy depot to zabbix agent
    var form = new FormData();
    form.append('hosts', 'mxsvr221');
    form.append('name', 'test');
    form.append('version', '1.0');
    form.append('key', 'test.info');
    form.append('command', 'test.sh');
    $.ajax({
        url: '/monitoring/zabbix/deploy',
        dataType: 'json',
        type: 'POST',
        processData: false,
        contentType: false,
        mimeType: 'multipart/form-data',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Undeploy depot from zabbix agent
    var form = new FormData();
    form.append('hosts', 'mxsvr221');
    form.append('name', "test");
    form.append('version', "1.0");
    $.ajax({
        url: '/monitoring/undeploy',
        dataType: 'json',
        type: 'POST',
        processData: false,
        contentType: false,
        mimeType: 'multipart/form-data',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Start zabbix agent
    var form = new FormData();
    form.append('hosts', 'mxsvr221');
    $.ajax({
        url: '/monitoring/zabbix/start',
        dataType: 'json',
        type: 'POST',
        processData: false,
        contentType: false,
        mimeType: 'multipart/form-data',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Stop zabbix agent
    var form = new FormData();
    form.append('hosts', 'mxsvr221');
    $.ajax({
        url: '/monitoring/zabbix/stop',
        dataType: 'json',
        type: 'POST',
        processData: false,
        contentType: false,
        mimeType: 'multipart/form-data',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Restart zabbix agent
    var form = new FormData();
    form.append('hosts', 'mxsvr221');
    $.ajax({
        url: '/monitoring/zabbix/restart',
        dataType: 'json',
        type: 'POST',
        processData: false,
        contentType: false,
        mimeType: 'multipart/form-data',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    

[TAGS] 标签管理

Tags managment.

  • /tagdir/:domain

    • Method

      GET DELETE POST PUT

    • Params

      tagpath=[string] topath=[string] system=[bool]

    • Success Response

      • Code: 200
        Content: { status:"ok", message:{}}
    • Error Response

      • Code: 500 ERROR
        Content: { status:"error", message:"error message." }
  • /tagdir/:domain/nodata

    • Method

      GET

    • Params

      tagpath=[string]

    • Success Response

      • Code: 200
        Content: { status:"ok", message:{}}
    • Error Response

      • Code: 500 ERROR
        Content: { status:"error", message:"error message." }
  • /tagdir/:domain/rename

    • Method

      PUT

    • Params

      tagpath=[string] topath=[string] system=[bool]

    • Success Response

      • Code: 200
        Content: { status:"ok", message:{}}
    • Error Response

      • Code: 500 ERROR
        Content: { status:"error", message:"error message." }
  • /:domain/addtags

    • Method

      PUT

    • Params

      tag=[multi-string] id=[multi-string] system=[bool]

    • Success Response

      • Code: 200
        Content: { status:"ok", message:{}}
    • Error Response

      • Code: 500 ERROR
        Content: { status:"error", message:"error message." }
  • /:domain/deletetags

    • Method

      DELETE

    • Params

      tag=[multi-string] id=[multi-string]

    • Success Response

      • Code: 200
        Content: { status:"ok", message:{}}
    • Error Response

      • Code: 500 ERROR
        Content: { status:"error", message:"error message." }
  • Example:

    // Update tagdir
    var form = new FormData();
    form.append("system", "true");
    form.append("tagpath", "fruit/apple/red");
    $.ajax({
        url: '/tagdir/apitest',
        dataType: 'json',
        type: 'POST',
        headers: {
            content-type: 'multipart/form-data'
        },
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get tagdir tree
    $.ajax({
        url: '/tagdir/apitest',
        dataType: 'json',
        type: 'GET',
        headers: {
            content-type: 'application/json'
        },
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Move tagdir
    // fruit           ->     fruit
    //   - apple       ->       - apple
    //       - red     ->       - pear
    //   - pear        ->         - red
    var form = new FormData();
    form.append("system", "false");
    form.append("tagpath", "fruit/apple/red");
    form.append("topath", "fruit/pear");
    $.ajax({
        url: '/tagdir/apitest',
        dataType: 'json',
        type: 'PUT',
        headers: {
            content-type: 'multipart/form-data'
        },
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete tag from tagdir
    var tagpath = encodeURIComponent('fruit/apple/red'); // Delete tag 'red'
    $.ajax({
        url: '/tagdir/apitest?tagpath=' + tagpath,
        dataType: 'json',
        type: 'DELETE',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Check if tag has data
    // If no data return true, else return false
    $.ajax({
        url: '/tagdir/apitest/nodata?tagpath=fruit/apple', // Check apple
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Rename tagdir
    var form = new FormData();
    form.append("system", "false");
    form.append("tagpath", "fruit/apple/red");
    form.append("topath", "fruit/apple/blue");
    $.ajax({
        url: '/tagdir/apitest',
        dataType: 'json',
        type: 'PUT',
        headers: {
            content-type: 'multipart/form-data'
        },
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Add tags to data
    var form = new FormData();
    form.append("system", "false");
    form.append("tag", "testtag1");
    form.append("id", "testid1");
    form.append("id", "testid2");
    form.append("tag", "testtag2");
    
    $.ajax({
        url: '/tagdir/apitest/addtags',
        dataType: 'json',
        mimeType: 'multipart/form-data',
        type: 'PUT',
        headers: {
            content-type: 'multipart/form-data'
        },
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete tags of data
    var form = new FormData();
    form.append("tag", "testtag1");
    form.append("id", "testid1");
    form.append("id", "testid2");
    form.append("tag", "testtag2");
    
    $.ajax({
        url: '/tagdir/apitest/deletetags',
        dataType: 'json',
        mimeType: 'multipart/form-data',
        type: 'PUT',
        headers: {
            content-type: 'multipart/form-data'
        },
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    

[BASELINE] 基线管理

Tags managment.

  • URL

    /baseline POST GET

    /baseline/:name GET DELETE

  • Method:

    None

  • Params

    None

  • JSON Params

    {
        "interval": 60, // required (seconds)
        "limitday": 7, // required (days)
        "rawclass": "/matrix/devops/performance", // required
        "baselineclass": "/matrix/devops/performance/baseline", // required
        "avgtype": "avg | median", // required
        "blacklist":["id1", "id2", "id3"],
        "ctypelist":["max", "min", "avg"], // required
        "status":"1", // 1:enable, 0:disable
        "job":{
            "group":"mxsvr", // required
            "cron":"5 0 * * *" // required
        },
        "id":"1",
        "name": "baselinetest", // required
        "description": "baselinetest",
        "ospace":"wecise",
        "user":"admin",
        "time":1555398200000,
        "source": "AI",
        "subject": "BASELINE",
        "title": "Performance baseline",
        "threshold": 2,
        "msg": ""
    }
    
  • Success Response:

    • Code: 200
      Content: { status:"ok", message:{}}
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    // Set baseline
    var obj = {
        "interval": 60,
        "limitday": 3,
        "rawclass": "/matrix/devops/performance",
        "baselineclass": "/matrix/devops/performance/baseline",
        "avgtype": "avg",
        "blacklist":["id1", "id2", "id3"],
        "ctypelist":["max", "min", "avg"],
        "status":1,
    
        "job":{
            "group":"mxsvr",
            "cron":"5 0 * * *"
        },
        "id":"1",
        "name": "baselinetest",
        "description": "baselinetest",
        "ospace":"wecise",
        "user":"admin",
        "time":1555398200000,
        "source": "AI",
        "subject": "BASELINE",
        "title": "Performance baseline",
        "threshold": 2,
        "msg": "Baseline alert:\{\{.name\}\}Over\{\{.threshold\}\}!"
    }
    $.ajax({
        url: '/baseline',
        dataType: 'json',
        contentType: 'json'
        type: 'POST',
        data: JSON.stringify(obj),
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get baseline list
    $.ajax({
        url: '/baseline',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get baseline
    $.ajax({
        url: '/baseline/baseline/test',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete baseline
    $.ajax({
        url: '/baseline/baselinetest',
        dataType: 'json',
        type: 'DELETE',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    

[CLUSTER INFO] 集群信息

Tags managment.

  • URL

    /cluster/info GET

  • Method:

    None

  • Params

    None

  • JSON Params

    None

  • Success Response:

    • Code: 200
      Content:

      {
          "message": {
              "cassandra": [
                  {
                      "datacenter": "dc1",
                      "hostid": "f7a334bc-748c-430a-943b-99d328d1283c",
                      "isup": true,
                      "peer": "192.168.31.221",
                      "port": 9042,
                      "rack": "rack1"
                  }
              ]
          },
          "status": "ok"
      }
      
  • Error Response:

    • Code: 500 ERROR
      Content: { status:"error", message:"error message." }
  • Example:

    ```javascript // Get cluster info $.ajax({

    url: '/cluster/info',
    dataType: 'json',
    type: 'GET',
    data: {},
    success: function(data) {
        console.log(data);
    }
    

    });



## [EXTEND MANAGEMENT] 扩展表管理

 Tags managment.

- **/extend**

  - **Method**

    `GET`

  - **Params**

  - **Success Response:**

    - **Code:** 200 <br />

    - **Content**

      ```json
      ["table1", "table2"...]
  • Error Response:

    • Code: 500 ERROR
  • /extend/:name

    • Method

      GET POST PUT DELETE

    • Body

      [
          {"key1": "value1", "key2": "value2"...},
          {"key1": "value3", "key2": "value4"...},
      ]
      
    • Success Response:

      • Code: 200

      • Content

        [
            {"key1": "value1", "key2": "value2"...},
            {"key1": "value3", "key2": "value4"...},
        ]
        
    • Error Response:

      • Code: 500 ERROR
  • Example:

    // Get extend file list
    $.ajax({
        url: '/extend',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get extend file data
    $.ajax({
        url: '/extend/test',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Add extend file
    var data = json.stringify([{key: "test",val: "192.168.31.201"},{key: "test",val: "192.168.31.201"}])
    $.ajax({
        url: '/extend/test',
        dataType: 'json',
        type: 'POST',
        data: data,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Update extend file
    var data = json.stringify([{key: "test",val: "192.168.31.201"}])
    $.ajax({
        url: '/extend/test',
        dataType: 'json',
        type: 'PUT',
        data: data,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete extend file
    $.ajax({
        url: '/extend/test',
        dataType: 'json',
        type: 'DELETE',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    

[API PERMS] API权限

API permissions.

  • Add api perm

    • URL

      /admin/perms/api

    • Method

      POST

    • Form Params

      name [string] required

      path [multi-string] required

    • Success Response:

      • Code: 200

      • Content

        { status:"ok", message:{}}

    • Error Response:

      • Code: 500 ERROR
  • Delete api perm

    • URL

      /admin/perms/api/:name

    • Method

      DELETE

    • Success Response:

      • Code: 200

      • Content

        { status:"ok", message:{}}

    • Error Response:

      • Code: 500 ERROR
  • Update api perm

    • URL

      /admin/perms/api/:name

    • Method

      PUT

    • Form Params

      path [multi-string] required

    • Success Response:

      • Code: 200

      • Content

        { status:"ok", message:{}}

    • Error Response:

      • Code: 500 ERROR
  • Get api perm list

    • URL

      /admin/perms/api

    • Method

      GET

    • Success Response:

      • Code: 200

      • Content

        { status:"ok", message:{}}

    • Error Response:

      • Code: 500 ERROR
  • Get api perm by name

    • URL

      /admin/perms/api/:name

    • Method

      GET

    • Success Response:

      • Code: 200

      • Content

        { status:"ok", message:{}}

    • Error Response:

      • Code: 500 ERROR
  • Set perm groups

    • URL

      /admin/perms/api/:name/group

    • Method

      PUT

    • Form params

      group [multi-string] required

    • Success Response:

      • Code: 200

      • Content

        { status:"ok", message:{}}

    • Error Response:

      • Code: 500 ERROR
  • Delete perm groups

    • URL

      /admin/perms/api/:name/group

    • Method

      DELETE

    • Params

      group [multi-string] required

    • Success Response:

      • Code: 200

      • Content

        { status:"ok", message:{}}

    • Error Response:

      • Code: 500 ERROR
  • Example:

    // Add api perm
    var form = new FormData();
    form.append("name", "TestAPIPerm");
    form.append("path", "/script/test"); // dir
    form.append("path", "/script/test2"); // dir
    form.append("path", "/script/test3/a.js"); // file
    form.append("path", "/script/test3/b.js"); // file
    $.ajax({
        url: '/admin/perms/api',
        dataType: 'json',
        type: 'POST',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete api perm
    $.ajax({
        url: '/admin/perms/api/TestAPIPerm',
        dataType: 'json',
        type: 'DELETE',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Update api perm
    var form = new FormData();
    form.append("path", "/script/test"); // dir
    form.append("path", "/script/test3/a.js"); // file
    $.ajax({
        url: '/admin/perms/api/TestAPIPerm',
        dataType: 'json',
        type: 'PUT',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get api perm list
    $.ajax({
        url: '/admin/perms/api',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get api perm by name
    $.ajax({
        url: '/admin/perms/api/TestAPIPerm',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Set api perm groups
    var form = new FormData();
    form.append("group", "测试组");
    form.append("group", "测试组2");
    $.ajax({
        url: '/admin/perms/api/TestAPIPerm/group',
        dataType: 'json',
        type: 'PUT',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete api perm groups
    $.ajax({
        url: '/admin/perms/api/TestAPIPerm/group?group=测试组&group=测试组2',
        dataType: 'json',
        type: 'DELETE',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    

[GROUP PERMS] 组权限

API permissions.

  • Add group perm

    • URL

      /admin/perms/group

    • Method

      POST

    • JSON Params

      {
          "name": "string",                   // required
          "parent": "string",                 // if empty is root or group fullname
          "member": ["string","string"...],   // user: start with U, group: start witch G
          "fields": {"string":"string"...},
          "readonly": ["string","string"...],
          "readexps": ["string","string"...],
          "writable": ["string","string"...],
          "tags": ["string","string"...],
      }
      
    • Success Response:

      • Code: 200

      • Content

        { status:"ok", message:{}}

    • Error Response:

      • Code: 500 ERROR
  • Delete group perm

    • URL

      /admin/perms/group/:id

    • Method

      DELETE

    • Success Response:

      • Code: 200

      • Content

        { status:"ok", message:{}}

    • Error Response:

      • Code: 500 ERROR
  • Update group perm

    • URL

      /admin/perms/group

    • Method

      PUT

    • JSON Params

      {
          "name": "string",                   // required
          "parent": "string",                 // if empty is root or group fullname
          "member": ["string","string"...],   // user: start with U, group: start witch G
          "fields": {"string":"string"...},
          "readonly": ["string","string"...],
          "readexps": ["string","string"...],
          "writable": ["string","string"...],
          "tags": ["string","string"...],
      }
      
    • Success Response:

      • Code: 200

      • Content

        { status:"ok", message:{}}

    • Error Response:

      • Code: 500 ERROR
  • Get group perm list

    • URL

      /admin/perms/group

    • Params

      parent=[string]

    • Method

      GET

    • Success Response:

      • Code: 200

      • Content

        { status:"ok", message:{}}

    • Error Response:

      • Code: 500 ERROR
  • Get group perm by id

    • URL

      /admin/perms/group/:id

    • Method

      GET

    • Success Response:

      • Code: 200

      • Content

        { status:"ok", message:{}}

    • Error Response:

      • Code: 500 ERROR
  • Example:

    // Add group perm
    $.ajax({
        url: '/admin/perms/group',
        dataType: 'json',
        type: 'POST',
        data: {name:  "TestGroup2", parent: "", member: ["U/用户组/test1", "G/TestGroup1"]},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete group perm
    $.ajax({
        url: '/admin/perms/group/4370160790923826435',
        dataType: 'json',
        type: 'DELETE',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Update group perm
    $.ajax({
        url: '/admin/perms/group',
        dataType: 'json',
        type: 'PUT',
        data: {name:  "TestGroup2", parent: "", member: ["U/用户组/test1", "G/TestGroup", "G/TestGroup1"]},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get group perm list by parent
    $.ajax({
        url: '/admin/perms/group?parent=',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Get group perm by id
    $.ajax({
        url: '/admin/perms/group/4370160790923826435',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    

[APP PERMS] 应用权限

API permissions.

  • Refresh app perms cache

    • URL

      /admin/perms/app/refresh

    • Method

      POST

    • Params

      None

    • Success Response:

      • Code: 200

      • Content

        { status:"ok", message:{}}

    • Error Response:

      • Code: 500 ERROR
  • Example:

    // Refresh app perms cache
    $.ajax({
        url: '/admin/perms/app/refresh',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    

[CONSOLELOG] 脚本控制台日志

API consolelog.

  • Read rule console log

    • URL

      /consolelog/rule

    • Method

      GET

    • Params

      | Name | Type | Default | Required | Description | | -------- | --------- | ------- | -------- | ----------------------------------------------- | | name | string | | YES | | | limit | int | 200 | NO | | | position | string | | NO | Return the 'position' information in the result | | levels | multi-int | 0 - 6 | NO | | | maxtime | int | - | NO | Timestamp | | mintime | int | - | NO | Timestamp |

    • Success Response:

      • Code: 200

      • Content

        {
            status:"ok",
            message:{
                "logs":[
                    {
                        "edtime": "2021-01-01T17:07:53.472Z",
                        "level": 2,
                        "msg": "2021-01-02 01:07:50.671 /matrix/rules/test:4:1: Test rule log",
                        "sttime": "2021-01-01T17:07:50.472Z"
                    },
                ],
                "position":"2021010201:1609520868407:3:9"
            }
        }
        
    • Error Response:

      • Code: 500 ERROR
  • Delete rule console log by name

    • URL

      /consolelog/rule

    • Method

      DELETE

    • Params

      | Name | Type | Default | Required | Description | | ---- | ------ | ------- | -------- | ----------- | | name | string | | YES | |

    • Success Response:

      • Code: 200

      • Content

        None

    • Error Response:

      • Code: 500 ERROR
  • Truncate rule console log

    • URL

      /consolelog/rule/truncate

    • Method

      DELETE

    • Params

      None

    • Success Response:

      • Code: 200

      • Content

        None

    • Error Response:

      • Code: 500 ERROR
  • Read serverjs console log

    • URL

      /consolelog/serverjs

    • Method

      GET

    • Params

      | Name | Type | Default | Required | Description | | -------- | --------- | ------- | -------- | ----------------------------------------------- | | name | string | | YES | | | limit | int | 200 | NO | | | position | string | | NO | Return the 'position' information in the result | | levels | multi-int | 0 - 6 | NO | | | maxtime | int | - | NO | Timestamp | | mintime | int | - | NO | Timestamp |

    • Success Response:

      • Code: 200

      • Content

        {
            status:"ok",
            message:{
                "logs":[
                    {
                        "edtime": "2021-01-01T17:07:53.472Z",
                        "level": 2,
                        "msg": "2021-01-02 01:07:50.671 /matrix/rules/test:4:1: Test serverjs log",
                        "sttime": "2021-01-01T17:07:50.472Z"
                    },
                ],
                "position":"2021010201:1609520868407:3:9"
            }
        }
        
    • Error Response:

      • Code: 500 ERROR
  • Delete serverjs console log by name

    • URL

      /consolelog/serverjs

    • Method

      DELETE

    • Params

      | Name | Type | Default | Required | Description | | ---- | ------ | ------- | -------- | ----------- | | name | string | | YES | |

    • Success Response:

      • Code: 200

      • Content

        None

    • Error Response:

      • Code: 500 ERROR
  • Truncate serverjs console log

    • URL

      /consolelog/serverjs/truncate

    • Method

      DELETE

    • Params

      None

    • Success Response:

      • Code: 200

      • Content

        None

    • Error Response:

      • Code: 500 ERROR
  • Read trigger console log

    • URL

      /consolelog/trigger

    • Method

      GET

    • Params

      | Name | Type | Default | Required | Description | | -------- | --------- | ------- | -------- | ----------------------------------------------- | | name | string | | YES | | | limit | int | 200 | NO | | | position | string | | NO | Return the 'position' information in the result | | levels | multi-int | 0 - 6 | NO | | | maxtime | int | - | NO | Timestamp | | mintime | int | - | NO | Timestamp |

    • Success Response:

      • Code: 200

      • Content

        {
            status:"ok",
            message:{
                "logs":[
                    {
                        "edtime": "2021-01-01T17:07:53.472Z",
                        "level": 2,
                        "msg": "2021-01-02 01:07:50.671 /matrix/rules/test:4:1: Test trigger log",
                        "sttime": "2021-01-01T17:07:50.472Z"
                    },
                ],
                "position":"2021010201:1609520868407:3:9"
            }
        }
        
    • Error Response:

      • Code: 500 ERROR
  • Delete trigger console log by name

    • URL

      /consolelog/trigger

    • Method

      DELETE

    • Params

      | Name | Type | Default | Required | Description | | ---- | ------ | ------- | -------- | ----------- | | name | string | | YES | |

    • Success Response:

      • Code: 200

      • Content

        None

    • Error Response:

      • Code: 500 ERROR
  • Truncate trigger console log

    • URL

      /consolelog/trigger/truncate

    • Method

      DELETE

    • Params

      None

    • Success Response:

      • Code: 200

      • Content

        None

    • Error Response:

      • Code: 500 ERROR
  • Special Note

    If the condition changes (name, levels, maxtime, mintime), the positon will be invalid, please get the position of the condition again
    
  • Example:

    // Read rule console log
    $.ajax({
        url: '/consolelog/rule?name=/matrix/rules/test&limit=4',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Read rule console log by levels and time
    $.ajax({
        url: '/consolelog/rule?name=/matrix/rules/test&limit=4&levels=1&levels=2&maxtime=1610942841812&mintime=1610942821812
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Read rule console log by position
    $.ajax({
        url: '/consolelog/rule?name=/matrix/rules/test&limit=4&position=2021010201:1609520870472:4:5',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Delete rule console log by name
    $.ajax({
        url: '/consolelog/rule?name=/matrix/rules/test',
        dataType: 'json',
        type: 'DELETE',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Truncate rule console log
    $.ajax({
        url: '/consolelog/rule/truncate',
        dataType: 'json',
        type: 'DELETE',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Read serverjs console log
    $.ajax({
        url: '/consolelog/serverjs?name=/temp/test/test.js&limit=4',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    
    // Read trigger console log
    $.ajax({
        url: '/consolelog/trigger?name=/matrix/test#testtrigger(INSERT)&limit=4',
        dataType: 'json',
        type: 'GET',
        data: {},
        success: function(data) {
            console.log(data);
        }
    });
    

[APP] 小程序

API app.

  • Export app

    • URL

      /app/export

    • Method

      GET

    • Params

      | Name | Type | Default | Required | Description | | ------- | ------------ | ------- | -------- | ------------------------ | | name | string | | YES | App name | | dir | string | | YES | App directory path | | class | multi-string | | NO | App depends on the class | | version | multi-int | 0 - 6 | NO | App version |

    • Success Response:

      • Code: 200

      • App file

        Return \.mxapp

    • Error Response:

      • Code: 500 ERROR
  • Import app

    • URL

      /app/import

    • Method

      POST

    • Params

      | Name | Type | Default | Required | Description | | ---------- | ---- | ------- | -------- | ---------------------------------------- | | uploadfile | file | | YES | Import app file, must be '.mxapp' format |

    • Success Response:

      • Code: 200

      • Content

        None

    • Error Response:

      • Code: 500 ERROR
  • Example:

    // Export app
    $.ajax({
        url: '/app/export?name=测试&dir=/app/test&class=/matrix/test&class=/matrix/test2&version=1.0.0',
        type: 'GET',
        dataType: 'json',
        data: {},
        mimeType: 'multipart/form-data',
        success: function(data) {
            console.log(data);
        }
    });
    
    // Import app
    var form = new FormData();
    form.append("uploadfile", fileInput.files[0], "test2.mxapp");
    $.ajax({
        url: '/app/import',
        type: 'POST',
        mimeType: 'multipart/form-data',
        dataType: 'json',
        data: form,
        success: function(data) {
            console.log(data);
        }
    });
    



results matching ""

    No results matching ""