Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: feature
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Support nested nextLink for paging operation
4 changes: 2 additions & 2 deletions packages/autorest.python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "~0.17.0",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTMzNzIyOC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.17.0.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand All @@ -47,4 +47,4 @@
"requirements.txt",
"generator/"
]
}
}
4 changes: 2 additions & 2 deletions packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"js-yaml": "~4.1.0",
"semver": "~7.6.2",
"tsx": "~4.19.1",
"@typespec/http-client-python": "~0.17.0",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTMzNzIyOC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.17.0.tgz",
"fs-extra": "~11.2.0"
},
"devDependencies": {
Expand Down Expand Up @@ -103,4 +103,4 @@
"chalk": "5.3.0",
"@types/fs-extra": "11.0.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ async def extract_data(pipeline_response):
list_of_elem = _deserialize(list[_models3.Pet], deserialized.get("nestedItems", {}).get("pets", []))
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.get("nestedNext.next") or None, AsyncList(list_of_elem)
return deserialized.get("nestedNext", {}).get("next") or None, AsyncList(list_of_elem)

async def get_next(next_link=None):
_request = prepare_request(next_link)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def extract_data(pipeline_response):
list_of_elem = _deserialize(list[_models2.Pet], deserialized.get("nestedItems", {}).get("pets", []))
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.get("nestedNext.next") or None, iter(list_of_elem)
return deserialized.get("nestedNext", {}).get("next") or None, iter(list_of_elem)

def get_next(next_link=None):
_request = prepare_request(next_link)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ async def test_link(client: PageableClient):
assert_result(result)


@pytest.mark.asyncio
async def test_link_string(client: PageableClient):
result = [p async for p in client.server_driven_pagination.link_string()]
assert_result(result)


@pytest.mark.asyncio
async def test_request_query_response_body(client: PageableClient):
result = [
Expand Down Expand Up @@ -73,3 +79,37 @@ async def test_request_header_response_header(client: PageableClient):
)
]
assert_result(result)


@pytest.mark.asyncio
async def test_nested_link(client: PageableClient):
result = [p async for p in client.server_driven_pagination.nested_link()]
assert_result(result)


@pytest.mark.asyncio
async def test_request_query_nested_response_body(client: PageableClient):
result = [
p
async for p in client.server_driven_pagination.continuation_token.request_query_nested_response_body(
foo="foo", bar="bar"
)
]
assert_result(result)


@pytest.mark.asyncio
async def test_request_header_nested_response_body(client: PageableClient):
result = [
p
async for p in client.server_driven_pagination.continuation_token.request_header_nested_response_body(
foo="foo", bar="bar"
)
]
assert_result(result)


@pytest.mark.asyncio
async def test_list_without_continuation(client: PageableClient):
result = [p async for p in client.list_without_continuation()]
assert_result(result)
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def test_link(client: PageableClient):
assert_result(result)


def test_link_string(client: PageableClient):
result = list(client.server_driven_pagination.link_string())
assert_result(result)


def test_request_query_response_body(client: PageableClient):
result = list(client.server_driven_pagination.continuation_token.request_query_response_body(foo="foo", bar="bar"))
assert_result(result)
Expand All @@ -52,3 +57,27 @@ def test_request_header_response_header(client: PageableClient):
client.server_driven_pagination.continuation_token.request_header_response_header(foo="foo", bar="bar")
)
assert_result(result)


def test_nested_link(client: PageableClient):
result = list(client.server_driven_pagination.nested_link())
assert_result(result)


def test_request_query_nested_response_body(client: PageableClient):
result = list(
client.server_driven_pagination.continuation_token.request_query_nested_response_body(foo="foo", bar="bar")
)
assert_result(result)


def test_request_header_nested_response_body(client: PageableClient):
result = list(
client.server_driven_pagination.continuation_token.request_header_nested_response_body(foo="foo", bar="bar")
)
assert_result(result)


def test_list_without_continuation(client: PageableClient):
result = list(client.list_without_continuation())
assert_result(result)
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ async def extract_data(pipeline_response):
list_of_elem = _deserialize(list[_models3.Pet], deserialized.get("nestedItems", {}).get("pets", []))
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.get("nestedNext.next") or None, AsyncList(list_of_elem)
return deserialized.get("nestedNext", {}).get("next") or None, AsyncList(list_of_elem)

async def get_next(next_link=None):
_request = prepare_request(next_link)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def extract_data(pipeline_response):
list_of_elem = _deserialize(list[_models2.Pet], deserialized.get("nestedItems", {}).get("pets", []))
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.get("nestedNext.next") or None, iter(list_of_elem)
return deserialized.get("nestedNext", {}).get("next") or None, iter(list_of_elem)

def get_next(next_link=None):
_request = prepare_request(next_link)
Expand Down
15 changes: 8 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading