Azure-devops rest api - 分页和速率限制

Azure-devops rest api - pagination and rate limit

我正在尝试提取 Azure-Devops 实体数据(团队、项目、存储库、成员等...)并在本地处理该数据, 我找不到任何关于速率限制和分页的文档, 有人有这方面的经验吗?

有一些关于成员分页的文档api:
https://docs.microsoft.com/en-us/rest/api/azure/devops/memberentitlementmanagement/members/get?view=azure-devops-rest-6.0

但这是唯一的,我找不到任何 git 实体的任何文档,
例如:存储库。
https://docs.microsoft.com/en-us/rest/api/azure/devops/git/repositories/list?view=azure-devops-rest-6.0

如果有人能指出正确的文档, 或者阐明这些主题会很棒。

谢谢。

I cannot find any documentation regarding rate-limiting and pagination, does anyone has any experience with that?

有一份关于Service limits and rate limits的文档,其中介绍了所有项目和组织都要遵守的服务限制和速率限制。

对于速率限制:

Azure DevOps Services, like many Software-as-a-Service solutions, uses multi-tenancy to reduce costs and to enhance scalability and performance. This leaves users vulnerable to performance issues and even outages when other users of their shared resources have spikes in their consumption. To combat these problems, Azure DevOps Services limits the resources individuals can consume and the number of requests they can make to certain commands. When these limits are exceeded, subsequent requests may be either delayed or blocked.

详情可参考Rate limits documentation

对于分页,一般来说,REST API 会有分页响应,而 ADO REST API 通常在每个响应中每页限制为 100 / 200(取决于哪个 API) .检索下一页信息的方法是引用响应 header x-ms-continuationtoken 并将其用于下一个请求参数作为 continuationToken.

但是 Microsoft 没有很好地记录这一点 - 这应该在支持 continuation 令牌的每个 API 调用中提到:

Builds - List

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds?definitions={definitions}&continuationToken={continuationToken}&maxBuildsPerDefinition={maxBuildsPerDefinition}&deletedFilter={deletedFilter}&queryOrder={queryOrder}&branchName={branchName}&buildIds={buildIds}&repositoryId={repositoryId}&repositoryType={repositoryType}&api-version=5.1

如果我使用上面的 REST API 和 $top=50,正如预期的那样,我得到 50 和一个名为“x-ms-continuationtoken”的 header,那么我们可以循环输出结果 continuationtoken:

您可以查看此 similar thread 了解更多详细信息。

我认为对于大多数具有查询参数的 api,如 $top/$skip.You 可以使用这些参数进行分页。假设默认 运行 在响应中给出了 200 个文档。对于下一个 运行,通过在请求的查询参数中提供 $skip=200 来跳过这 200 个项目以获取接下来的 200 个项目。您可以继续迭代,直到响应的计数属性变为 0。

对于那些您没有这些参数的 api,您可以使用 continuation-token,如 Leo Liu-MSFT 所述。

看来您可以通过 $topcontinuationToken 来列出 Azure Git 参考资料。

文档在这里:

https://docs.microsoft.com/en-us/rest/api/azure/devops/git/refs/list?view=azure-devops-rest-6.0