此bounty已结束。回答此问题可获得+100声望奖励。赏金宽限期17小时后结束。Jean-Francois T.正在寻找规范答案:请为这个问题提供一个官方的答案,而不仅仅是一个(脏)补丁。
在早期版本的Azure DevOps Python API(6.0.0b4之前)中,当对某些项目(例如WorkItems,Test Suites,...),您有一个带有value
和continuation_token
的响应对象,您可以使用它来发出新的请求并继续解析。
例如,下面是这样的函数的原型:
def get_test_suites_for_plan(self, project, plan_id, expand=None, continuation_token=None, as_tree_view=None):
"""GetTestSuitesForPlan.
[Preview API] Get test suites for plan.
:param str project: Project ID or project name
:param int plan_id: ID of the test plan for which suites are requested.
:param str expand: Include the children suites and testers details.
:param str continuation_token: If the list of suites returned is not complete, a continuation token to query next batch of suites is included in the response header as "x-ms-continuationtoken". Omit this parameter to get the first batch of test suites.
:param bool as_tree_view: If the suites returned should be in a tree structure.
:rtype: :class:`<GetTestSuitesForPlanResponseValue>`
所以你可以这样做:
resp = client.get_test_suites_for_plan(project, my_plan_id)
suites = resp.value
while resp.continuation_token:
resp = client.get_test_suites_for_plan(project, my_plan_id)
suites += resp.value
在最近的版本(特别是7.0)中,现在返回的是一个列表(但受API的大小限制)。
例如,类似函数的版本将是:
def get_test_suites_for_plan(self, project, plan_id, expand=None, continuation_token=None, as_tree_view=None):
"""GetTestSuitesForPlan.
[Preview API] Get test suites for plan.
:param str project: Project ID or project name
:param int plan_id: ID of the test plan for which suites are requested.
:param str expand: Include the children suites and testers details.
:param str continuation_token: If the list of suites returned is not complete, a continuation token to query next batch of suites is included in the response header as "x-ms-continuationtoken". Omit this parameter to get the first batch of test suites.
:param bool as_tree_view: If the suites returned should be in a tree structure.
:rtype: :class:`<[TestSuite]> <azure.devops.v6_0.test_plan.models.[TestSuite]>`
"""
如何检索继续标记以继续解析其他结果?
注意:我还在Azure DevOps Python API的GitHub存储库中创建了一个问题:https://github.com/microsoft/azure-devops-python-api/issues/461
1条答案
按热度按时间k4emjkb11#
我目前对
client.Client
类做了一个丑陋的补丁,添加了一个属性,在每次发送请求时(使用方法_send
)存储一个延续令牌。这是超级丑陋,但至少它的工作然后,在创建客户端之前,您只需要导入并调用
patch_azure_devops_client
函数,它将向客户端添加continuation_token_last_request。