In earlier versions of the Azure DevOps Python API (until 6.0.0b4), when making a request on some items (e.g. WorkItems, Test Suites, ...), you had a response object with a value
and a continuation_token
that you could use to make a new request and continue parsing.
For example, here is the prototype of such function:
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>`
So you could do something like:
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
With more recent versions (in particular 7.0), you now get a list returned (but with the limit of size imposed by the API).
For example, a version of similar function would be:
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]>`
"""
How to retrieve the continuation token to continue parsing the other results?
Note: I have also created an issue in GitHub repo of Azure DevOps Python API: https://github.com/microsoft/azure-devops-python-api/issues/461
from How to retrieve continuation token in Azure DevOps Python API version 7.0 and above?
No comments:
Post a Comment