# 执行配置文件

Availability-note[测试版](https://help.talend.com/r/en-US/Cloud/labels-on-talend-help-center/availability-beta)

测试版内容

在此场景中，您使用 Talend API 来执行配置文件以提高项目质量。

## 关于本任务

以下是有关 API 调用的一些详细信息：

```
Method: POST
endpoint: api/v1/projects/quality/profiles/{id}/executions
payload:
    {
  "repository": "string",
  "authentication": {
    "username": "string",
    "passcode": "string"
  },
  "branch": "string",
  "workspace": "string",
  "client": "UI"
    }
```

该端点使用配置文件 ID 作为参数，其中包含要在 Talend 项目上执行的规范列表。

## 程序

1. 调用 GET api/v1/projects/quality/profiles 端点以获取要执行的配置文件的 ID。
2. 记下要执行的配置文件的 ID。
3. 调用 POST api/v1/projects/quality/profiles/{id}/executions 端点以执行配置文件。将要执行的配置文件的ID作为参数添加。
4. 在 正文 区域中，输入以下信息：
   | 参数名称 | 值 |
   | --- | --- |
   | 储存库 | 输入储存库的名称。 |
   | 用户名 | 输入您的用户名。 |
   | 密码 | 输入您的密码。 |
   | 分支 | 输入分支名称。 |
   | 工作空间 | 输入工作空间名称。 |
   | 客户端 | 输入客户端名称。 |

   示例：
   ```
    {
     "repository": "GIT",
     "authentication": {
       "username": "******",
       "passcode": "*************"
     },
     "branch": "master",
     "workspace": "PROJECT_73",
     "client": "UI"
   }
   ```
5. 点击执行以发出您的调用。

## 结果

以下是一个响应示例：

```
{
  "id": "67",
  "status": "FAILED",
  "startTimestamp": "2023-10-13 17:36",
  "duration": "2s",
  "specifications": [
    {
      "id": "69",
      "specification": {
        "id": "2",
        "name": "best-practice",
        "description": "This specification contains rules related to best practices",
        "operator": "is_Equal_to",
        "threshold": 100,
        "thresholdType": "PERCENTAGE",
        "createdBy": "system"
      },
      "status": "FAILED",
      "rules": [
        {
          "id": "77",
          "rule": {
            "id": "4",
            "name": "Active-tLogRow",
            "description": "Identify jobs with tLogRow components",
            "category": "COMPONENT",
            "severity": "MINOR",
            "operator": "is_less_than_or_Equal",
            "threshold": "5",
            "thresholdType": "PERCENTAGE",
            "createdBy": "system"
          },
          "result": "30",
          "status": "FAILED"
        },
        {
          "id": "78",
          "rule": {
            "id": "5",
            "name": "JavaLogs",
            "description": "Identify jobs that contain java logs.",
            "category": "COMPONENT",
            "severity": "INFO",
            "operator": "is_less_than_or_Equal",
            "threshold": "50",
            "thresholdType": "PERCENTAGE",
            "createdBy": "system"
          },
          "result": "4.56",
          "status": "PASSED"
        }
      ],
      "duration": "1s"
    }
  ],
  "sourceProvider": {
    "providerType": "LOCAL",
    "workspace": "D:\\Talend_Studio\\studio\\workspaces\\qtcmt_test",
    "project": "PROJECT_73"
  },
  "info": {
    "version": "7.3.1",
    "label": "PROJECT_73",
    "description": "Project imported from TalendPS organization",
    "productVersion": "Talend Real-time Big Data Platform-7.3.1.20221115_1012-patch",
    "type": "DQ",
    "bigData": false,
    "local": false
  },
  "inventory": {
    "total_artifact_assets": 258,
    "context_group": 11,
    "standard_job": 210,
    "standard_job_versions": 211,
    "standard_joblet": 24,
    "standard_joblet_versions": 24,
    "resource": 2,
    "resource_versions": 24,
    "bd_batch": 1,
    "bd_batch_versions": 1,
    "bd_batch_joblet": 0,
    "bd_batch_joblet_versions": 0,
    "bd_streaming": 1,
    "bd_streaming_versions": 1,
    "bd_streaming_joblet": 0,
    "bd_streaming_joblet_versions": 0,
    "route": 46,
    "route_versions": 46,
    "routelet": 1,
    "routelet_versions": 1
  },
  "commits": [
    {
      "id": "24b228d45561e0a741a0409195ef492437bf3",
      "date": "Tue Feb 21 01:29:11 2023 +0000",
      "author": "talend <talend@3bed803c5b79>",
      "message": "\tCreate Project: PRJ_731\n"
    }
  ]
}
```

在此示例中，Active-tLogRow 规则查找包含 tLogRow 组件的作业。根据条件定义，识别到的资产总数应小于最大阈值，此处为5。

此示例的结果是 30。规则的质量检查失败。规则的状态为失败。每条规则的状态根据结果与阈值之间的比较进行评估。

项目的整体质量由规范的状态决定。规范的状态由所有规则的累积结果或状态验证。在此示例中，阈值设置为100%。在此，即使单个条件或规则失败，规范也会失败，并且状态设置为 失败。

阈值、阈值类型和运算符可以根据规则和规范对您的 Talend 项目质量的影响进行更新。

当所有规范都执行完毕后，执行状态将根据以下条件设置：

* 通过：如果所有规范都已通过，则为该状态。
* 失败：如果任何规范失败，则为该状态。
* 已取消：如果执行被取消，则为该状态。
* 正在运行：如果执行正在进行中，则为该状态。

可以使用 GET /api/v1/projects/quality/profiles/executions 端点访问执行。执行可以根据多个条件进行筛选：从某个开始时间起的执行状态或项目名称。![选择用于获取所有执行的API。](https://help.qlik.com/Resources/Images/qlik-talend-cloud-migration-toolkit-user-guide/tcmp-execution-api.png)

执行也可以通过其执行ID或其状态、开始时间或项目名称删除。![删除所有执行的API。](https://help.qlik.com/Resources/Images/qlik-talend-cloud-migration-toolkit-user-guide/tcmp-delete-executions-api.png)