搜索

28.2. 支持的知识库存储 REST API 端点

download PDF

知识库存储 REST API 提供了在 Red Hat Process Automation Manager 中管理空格和项目的端点,以及检索之前关于 REST API 请求的信息,或 作业

28.2.1. 空格

知识库存储 REST API 支持以下端点来管理 Business Central 中的空格。知识库存储 REST API 基本 URL 是 http://SERVER:PORT/business-central/rest/。所有请求都需要 HTTP 基本身份验证或基于令牌的验证用于 rest-all 用户角色。

[GET] /spaces

返回 Business Central 中的所有空格。

服务器响应示例(JSON)

[
  {
    "name": "MySpace",
    "description": null,
    "projects": [
      {
        "name": "Employee_Rostering",
        "spaceName": "MySpace",
        "groupId": "employeerostering",
        "version": "1.0.0-SNAPSHOT",
        "description": "Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill.",
        "publicURIs": [
          {
            "protocol": "git",
            "uri": "git://localhost:9418/MySpace/example-Employee_Rostering"
          },
          {
            "protocol": "ssh",
            "uri": "ssh://localhost:8001/MySpace/example-Employee_Rostering"
          }
        ]
      },
      {
        "name": "Mortgage_Process",
        "spaceName": "MySpace",
        "groupId": "mortgage-process",
        "version": "1.0.0-SNAPSHOT",
        "description": "Getting started loan approval process in BPMN2, decision table, business rules, and forms.",
        "publicURIs": [
          {
            "protocol": "git",
            "uri": "git://localhost:9418/MySpace/example-Mortgage_Process"
          },
          {
            "protocol": "ssh",
            "uri": "ssh://localhost:8001/MySpace/example-Mortgage_Process"
          }
        ]
      }
    ],
    "owner": "admin",
    "defaultGroupId": "com.myspace"
  },
  {
    "name": "MySpace2",
    "description": null,
    "projects": [
      {
        "name": "IT_Orders",
        "spaceName": "MySpace",
        "groupId": "itorders",
        "version": "1.0.0-SNAPSHOT",
        "description": "Case Management IT Orders project",
        "publicURIs": [
          {
            "protocol": "git",
            "uri": "git://localhost:9418/MySpace/example-IT_Orders-1"
          },
          {
            "protocol": "ssh",
            "uri": "ssh://localhost:8001/MySpace/example-IT_Orders-1"
          }
        ]
      }
    ],
    "owner": "admin",
    "defaultGroupId": "com.myspace"
  }
]

[GET] /spaces/{spaceName}

返回有关指定空间的信息。

表 28.1. 请求参数
名称描述类型要求

spaceName

要检索的空间的名称

字符串

必填

服务器响应示例(JSON)

{
  "name": "MySpace",
  "description": null,
  "projects": [
    {
      "name": "Mortgage_Process",
      "spaceName": "MySpace",
      "groupId": "mortgage-process",
      "version": "1.0.0-SNAPSHOT",
      "description": "Getting started loan approval process in BPMN2, decision table, business rules, and forms.",
      "publicURIs": [
        {
          "protocol": "git",
          "uri": "git://localhost:9418/MySpace/example-Mortgage_Process"
        },
        {
          "protocol": "ssh",
          "uri": "ssh://localhost:8001/MySpace/example-Mortgage_Process"
        }
      ]
    },
    {
      "name": "Employee_Rostering",
      "spaceName": "MySpace",
      "groupId": "employeerostering",
      "version": "1.0.0-SNAPSHOT",
      "description": "Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill.",
      "publicURIs": [
        {
          "protocol": "git",
          "uri": "git://localhost:9418/MySpace/example-Employee_Rostering"
        },
        {
          "protocol": "ssh",
          "uri": "ssh://localhost:8001/MySpace/example-Employee_Rostering"
        }
      ]
    },
    {
      "name": "Evaluation_Process",
      "spaceName": "MySpace",
      "groupId": "evaluation",
      "version": "1.0.0-SNAPSHOT",
      "description": "Getting started Business Process for evaluating employees",
      "publicURIs": [
        {
          "protocol": "git",
          "uri": "git://localhost:9418/MySpace/example-Evaluation_Process"
        },
        {
          "protocol": "ssh",
          "uri": "ssh://localhost:8001/MySpace/example-Evaluation_Process"
        }
      ]
    },
    {
      "name": "IT_Orders",
      "spaceName": "MySpace",
      "groupId": "itorders",
      "version": "1.0.0-SNAPSHOT",
      "description": "Case Management IT Orders project",
      "publicURIs": [
        {
          "protocol": "git",
          "uri": "git://localhost:9418/MySpace/example-IT_Orders"
        },
        {
          "protocol": "ssh",
          "uri": "ssh://localhost:8001/MySpace/example-IT_Orders"
        }
      ]
    }
  ],
  "owner": "admin",
  "defaultGroupId": "com.myspace"
}

[POST] /spaces

在 Business Central 中创建空间。

表 28.2. 请求参数
名称描述类型要求

正文(body)

名称描述所有者defaultGroupId 以及新空间的任何其他组件

请求正文

必填

请求正文示例(JSON)

{
  "name": "NewSpace",
  "description": "My new space.",
  "owner": "admin",
  "defaultGroupId": "com.newspace"
}

服务器响应示例(JSON)

{
  "jobId": "1541016978154-3",
  "status": "APPROVED",
  "spaceName": "NewSpace",
  "owner": "admin",
  "defaultGroupId": "com.newspace",
  "description": "My new space."
}

[PUT] /spaces

更新 Business Central 中空间 的描述所有者和 defaultGroupId

请求正文示例(JSON)

{
  "name": "MySpace",
  "description": "This is updated description",
  "owner": "admin",
  "defaultGroupId": "com.updatedGroupId"
}

服务器响应示例(JSON)

{
  "jobId": "1592214574454-1",
  "status": "APPROVED",
  "spaceName": "MySpace",
  "owner": "admin",
  "defaultGroupId": "com.updatedGroupId",
  "description": "This is updated description"
}

[DELETE] /spaces/{spaceName}

从 Business Central 中删除指定空间。

表 28.3. 请求参数
名称描述类型要求

spaceName

要删除的空间的名称

字符串

必填

服务器响应示例(JSON)

{
  "jobId": "1541127032997-8",
  "status": "APPROVED",
  "spaceName": "MySpace",
  "owner": "admin",
  "description": "My deleted space.",
  "repositories": null
}

28.2.2. 项目

知识库存储 REST API 支持以下端点,以便在 Business Central 中管理、构建和部署项目。知识库存储 REST API 基本 URL 是 http://SERVER:PORT/business-central/rest/。所有请求都需要 HTTP 基本身份验证或基于令牌的验证用于 rest-all 用户角色。

[GET] /spaces/{spaceName}/projects

返回指定空间中的项目。

表 28.4. 请求参数
名称描述类型要求

spaceName

检索项目的空间名称

字符串

必填

服务器响应示例(JSON)

[
  {
    "name": "Mortgage_Process",
    "spaceName": "MySpace",
    "groupId": "mortgage-process",
    "version": "1.0.0-SNAPSHOT",
    "description": "Getting started loan approval process in BPMN2, decision table, business rules, and forms.",
    "publicURIs": [
      {
        "protocol": "git",
        "uri": "git://localhost:9418/MySpace/example-Mortgage_Process"
      },
      {
        "protocol": "ssh",
        "uri": "ssh://localhost:8001/MySpace/example-Mortgage_Process"
      }
    ]
  },
  {
    "name": "Employee_Rostering",
    "spaceName": "MySpace",
    "groupId": "employeerostering",
    "version": "1.0.0-SNAPSHOT",
    "description": "Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill.",
    "publicURIs": [
      {
        "protocol": "git",
        "uri": "git://localhost:9418/MySpace/example-Employee_Rostering"
      },
      {
        "protocol": "ssh",
        "uri": "ssh://localhost:8001/MySpace/example-Employee_Rostering"
      }
    ]
  },
  {
    "name": "Evaluation_Process",
    "spaceName": "MySpace",
    "groupId": "evaluation",
    "version": "1.0.0-SNAPSHOT",
    "description": "Getting started Business Process for evaluating employees",
    "publicURIs": [
      {
        "protocol": "git",
        "uri": "git://localhost:9418/MySpace/example-Evaluation_Process"
      },
      {
        "protocol": "ssh",
        "uri": "ssh://localhost:8001/MySpace/example-Evaluation_Process"
      }
    ]
  },
  {
    "name": "IT_Orders",
    "spaceName": "MySpace",
    "groupId": "itorders",
    "version": "1.0.0-SNAPSHOT",
    "description": "Case Management IT Orders project",
    "publicURIs": [
      {
        "protocol": "git",
        "uri": "git://localhost:9418/MySpace/example-IT_Orders"
      },
      {
        "protocol": "ssh",
        "uri": "ssh://localhost:8001/MySpace/example-IT_Orders"
      }
    ]
  }
]

[GET] /spaces/{spaceName}/projects/{projectName}

返回指定空间中指定项目的信息。

表 28.5. 请求参数
名称描述类型要求

spaceName

项目所在的空间名称

字符串

必填

projectName

要检索的项目的名称

字符串

必填

服务器响应示例(JSON)

{
  "name": "Employee_Rostering",
  "spaceName": "MySpace",
  "groupId": "employeerostering",
  "version": "1.0.0-SNAPSHOT",
  "description": "Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill.",
  "publicURIs": [
    {
      "protocol": "git",
      "uri": "git://localhost:9418/MySpace/example-Employee_Rostering"
    },
    {
      "protocol": "ssh",
      "uri": "ssh://localhost:8001/MySpace/example-Employee_Rostering"
    }
  ]
}

[POST] /spaces/{spaceName}/projects

在指定空间中创建项目。

表 28.6. 请求参数
名称描述类型要求

spaceName

创建新项目的空间名称

字符串

必填

正文(body)

新项目 的其他组件、groupId版本描述 和任何其他组件

请求正文

必填

请求正文示例(JSON)

{
  "name": "Employee_Rostering",
  "groupId": "employeerostering",
  "version": "1.0.0-SNAPSHOT",
  "description": "Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill."
}

服务器响应示例(JSON)

{
  "jobId": "1541017411591-6",
  "status": "APPROVED",
  "spaceName": "MySpace",
  "projectName": "Employee_Rostering",
  "projectGroupId": "employeerostering",
  "projectVersion": "1.0.0-SNAPSHOT",
  "description": "Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill."
}

[DELETE] /spaces/{spaceName}/projects/{projectName}

从指定空间中删除指定项目。

表 28.7. 请求参数
名称描述类型要求

spaceName

项目所在的空间名称

字符串

必填

projectName

要删除的项目的名称

字符串

必填

服务器响应示例(JSON)

{
  "jobId": "1541128617727-10",
  "status": "APPROVED",
  "projectName": "Employee_Rostering",
  "spaceName": "MySpace"
}

[POST] /spaces/{spaceName}/git/clone

将项目从指定的 Git 地址克隆到指定空间中。

表 28.8. 请求参数
名称描述类型要求

spaceName

克隆项目的空间名称

字符串

必填

正文(body)

要克隆的项目的名称描述 和 Git 存储库 userNamepasswordgitURL

请求正文

必填

请求正文示例(JSON)

{
  "name": "Employee_Rostering",
  "description": "Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill.",
  "userName": "baAdmin",
  "password": "password@1",
  "gitURL": "git://localhost:9418/MySpace/example-Employee_Rostering"
}

服务器响应示例(JSON)

{
  "jobId": "1541129488547-13",
  "status": "APPROVED",
  "cloneProjectRequest": {
    "name": "Employee_Rostering",
    "description": "Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill.",
    "userName": "baAdmin",
    "password": "password@1",
    "gitURL": "git://localhost:9418/MySpace/example-Employee_Rostering"
  },
  "spaceName": "MySpace2"
}

[POST] /spaces/{spaceName}/projects/{projectName}/maven/compile

在指定空间中编译指定项目(等同于 mvn 编译)。

表 28.9. 请求参数
名称描述类型要求

spaceName

项目所在的空间名称

字符串

必填

projectName

要编译的项目的名称

字符串

必填

服务器响应示例(JSON)

{
  "jobId": "1541128617727-10",
  "status": "APPROVED",
  "projectName": "Employee_Rostering",
  "spaceName": "MySpace"
}

[POST] /spaces/{spaceName}/projects/{projectName}/maven/test

在指定空间中测试指定项目(等同于 mvn 测试)。

表 28.10. 请求参数
名称描述类型要求

spaceName

项目所在的空间名称

字符串

必填

projectName

要测试的项目的名称

字符串

必填

服务器响应示例(JSON)

{
  "jobId": "1541132591595-19",
  "status": "APPROVED",
  "projectName": "Employee_Rostering",
  "spaceName": "MySpace"
}

[POST] /spaces/{spaceName}/projects/{projectName}/maven/install

在指定空间中安装指定项目(等同于 mvn install)。

表 28.11. 请求参数
名称描述类型要求

spaceName

项目所在的空间名称

字符串

必填

projectName

要安装的项目名称

字符串

必填

服务器响应示例(JSON)

{
  "jobId": "1541132668987-20",
  "status": "APPROVED",
  "projectName": "Employee_Rostering",
  "spaceName": "MySpace"
}

[POST] /spaces/{spaceName}/projects/{projectName}/maven/deploy

以指定空间(等同于 mvn deploy)部署指定项目。

表 28.12. 请求参数
名称描述类型要求

spaceName

项目所在的空间名称

字符串

必填

projectName

要部署的项目的名称

字符串

必填

服务器响应示例(JSON)

{
  "jobId": "1541132816435-21",
  "status": "APPROVED",
  "projectName": "Employee_Rostering",
  "spaceName": "MySpace"
}

28.2.3. 作业(API 请求)

除返回的请求详情外,知识库存储 REST API 中的所有 POSTDELETE 请求都会返回与每个请求关联的作业 ID。您可以使用作业 ID 查看请求状态或删除发送的请求。

知识存储 REST API 请求或作业可以具有以下状态:

表 28.13. 作业状态(API 请求状态)
状态描述

已接受

请求已被接受,正在处理。

BAD_REQUEST

请求包含不正确的内容,且不接受。

RESOURCE_NOT_EXIST

请求的资源(路径)不存在。

DUPLICATE_RESOURCE

资源已存在。

SERVER_ERROR

KIE 服务器中出现错误。

SUCCESS

请求成功完成。

FAIL

请求失败。

已批准

请求已批准。

已拒绝

请求被拒绝。

停用

因为以下原因之一,无法找到请求的作业 ID:

  • 请求被明确删除。
  • 请求已完成,已从状态缓存中删除。缓存达到其最大容量后,会从状态缓存中删除请求。
  • 请求永不存在。

知识库存储 REST API 支持以下端点来检索或删除发送的 API 请求。知识库存储 REST API 基本 URL 是 http://SERVER:PORT/business-central/rest/。所有请求都需要 HTTP 基本身份验证或基于令牌的验证用于 rest-all 用户角色。

[GET] /jobs/{jobId}

返回指定作业的状态(之前发送的 API 请求)。

表 28.14. 请求参数
名称描述类型要求

jobId

要检索的作业 ID (例如:1541010216919-1

字符串

必填

服务器响应示例(JSON)

{
  "status": "SUCCESS",
  "jobId": "1541010216919-1",
  "result": null,
  "lastModified": 1541010218352,
  "detailedResult": [
    "level:INFO, path:null, text:Build of module 'Mortgage_Process' (requested by system) completed.\n Build: SUCCESSFUL"
  ]
}

[DELETE] /jobs/{jobId}

删除指定的作业(之前发送的 API 请求)。如果还没有处理作业,此请求会从作业队列中删除作业。此请求不会取消或停止持续的作业。

表 28.15. 请求参数
名称描述类型要求

jobId

要删除的作业的 ID (例如:1541010216919-1

字符串

必填

服务器响应示例(JSON)

{
  "status": "GONE",
  "jobId": "1541010216919-1",
  "result": null,
  "lastModified": 1541132054916,
  "detailedResult": [
    "level:INFO, path:null, text:Build of module 'Mortgage_Process' (requested by system) completed.\n Build: SUCCESSFUL"
  ]
}

28.2.4. 分支

知识库存储 REST API 支持以下端点来管理 Business Central 中的分支。知识库存储 REST API 基本 URL 是 http://SERVER:PORT/business-central/rest/。所有请求都需要 HTTP 基本身份验证或基于令牌的验证用于 rest-all 用户角色。

[GET] /spaces/{spaceName}/projects/{projectName}/branches

返回指定项目和空间中的所有分支。

表 28.16. 请求参数
名称描述类型要求

spaceName

检索项目的空间名称

字符串

必填

projectName

您要检索分支的项目的名称

字符串

必填

服务器响应示例(JSON)

[
  {
    "name":"master"
  }
]

[POST] /spaces/{spaceName}/projects/{projectName}/branches

在指定的项目和空间中添加指定的分支。

表 28.17. 请求参数
名称描述类型要求

spaceName

项目所在的空间名称

字符串

必填

projectName

需要在其中创建新分支的项目的名称

字符串

必填

正文(body)

项目的 newBranchNamebaseBranchName

请求正文

必填

请求正文示例(JSON)

{
   "newBranchName":  "branch01",
   "baseBranchName": "master"
}

服务器响应示例(JSON)

{
    "jobId":          "1576175811141-3",
    "status":         "APPROVED",
    "spaceName":      "Space123",
    "projectName":    "ProjABC",
    "newBranchName":  "b1",
    "baseBranchName": "master",
    "userIdentifier": "bc"
}

[DELETE] /spaces/{spaceName}/projects/{projectName}/branches/{branchName}

删除指定项目和空间中的指定分支。

表 28.18. 请求参数
名称描述类型要求

spaceName

项目所在的空间名称

字符串

必填

projectName

分支所在的项目名称

字符串

必填

branchName

要删除的分支名称

字符串

必填

服务器响应示例(JSON)

{
    "jobId":          "1576175811421-5",
    "status":         "APPROVED",
    "spaceName":      "Space123",
    "projectName":    "ProjABC",
    "branchName":     "b1",
    "userIdentifier": "bc"
}

[POST] /spaces/{spaceName}/projects/{projectName}/branches/{branchName}/maven/compile

在指定项目和空间中编译指定的分支。如果没有指定 branchName,则请求将应用到 master 分支。

表 28.19. 请求参数
名称描述类型要求

spaceName

项目所在的空间名称

字符串

必填

projectName

分支所在的项目名称

字符串

必填

branchName

要编译的分支的名称

字符串

必填

服务器响应示例(JSON)

{
    "jobId":       "1576175811233-4",
    "status":      "APPROVED",
    "spaceName":   "Space123",
    "projectName": "ProjABC",
    "branchName":  "b1",
}

[POST] /spaces/{spaceName}/projects/{projectName}/branches/{branchName}/maven/install

在指定的项目和空格中安装指定的分支。如果没有指定 branchName,则请求将应用到 master 分支。

表 28.20. 请求参数
名称描述类型要求

spaceName

项目所在的空间名称

字符串

必填

projectName

分支所在的项目名称

字符串

必填

branchName

要安装的分支名称

字符串

必填

服务器响应示例(JSON)

{
    "jobId":       "1576175811233-4",
    "status":      "APPROVED",
    "spaceName":   "Space123",
    "projectName": "ProjABC",
    "branchName":  "b1",
}

[POST] /spaces/{spaceName}/projects/{projectName}/branches/{branchName}/maven/test

在指定项目和空间中测试指定的分支。如果没有指定 branchName,则请求将应用到 master 分支。

表 28.21. 请求参数
名称描述类型要求

spaceName

项目所在的空间名称

字符串

必填

projectName

分支所在的项目名称

字符串

必填

branchName

要测试的分支的名称

字符串

必填

服务器响应示例(JSON)

{
    "jobId":       "1576175811233-4",
    "status":      "APPROVED",
    "spaceName":   "Space123",
    "projectName": "ProjABC",
    "branchName":  "b1",
}

[POST] /spaces/{spaceName}/projects/{projectName}/branches/{branchName}/maven/deploy

在指定的项目和空间中部署指定的分支。如果没有指定 branchName,则请求将应用到 master 分支。

表 28.22. 请求参数
名称描述类型要求

spaceName

项目所在的空间名称

字符串

必填

projectName

分支所在的项目名称

字符串

必填

branchName

要部署的分支的名称

字符串

必填

服务器响应示例(JSON)

{
    "jobId":       "1576175811233-4",
    "status":      "APPROVED",
    "spaceName":   "Space123",
    "projectName": "ProjABC",
    "branchName":  "b1",
}

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.