您如何通过 Azure DevOps Rest API 获得对给定服务连接的批准和检查?

How do you get approvals and checks for a given service connection via the Azure DevOps Rest API?

查看了 Azure DevOps REST API 文档,并尝试了几次猜测端点的失败尝试,似乎没有提及如何查看或创建 'Approvals and checks' 关联使用给定的服务连接:

https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints?view=azure-devops-rest-6.1

是否有关于如何执行此操作的任何想法,或者 approvals/checks 的服务连接的其余 API 文档在哪里?

关于背景信息,当通过 REST API 创建服务连接时,我们的目标是为服务连接分配一个检查,以便它使用给定的 YAML 模板,因为服务连接本身已经被作为自动化流程的一部分创建。

您可以使用未录制的 REST API:

POST https://dev.azure.com/{organization}/{project}/_apis/pipelines/checks/configurations?api-version=5.2-preview.1

这里是请求正文的一个例子:

{
    "type": {
        "name": "ExtendsCheck"
    },
    "settings": {
        "extendsChecks": [
            {
                "repositoryType": "git",
                "repositoryName": "{project}/{repository}",
                "repositoryRef": "refs/heads/master",
                "templatePath": "templates.yml"
            }
        ]
    },
    "resource": {
        "type": "endpoint",
        "id": "{service connection id}",
        "name": "{service connection name}"
    }
}

要获取服务连接 ID,您可以使用 REST API Endpoints - Get Service Endpoints or Endpoints - Get Service Endpoints By Names.