Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python] support continuation token for paging #6242

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Conversation

msyyc
Copy link
Contributor

@msyyc msyyc commented Mar 4, 2025

fix #5791
API design: https://gist.github.com/msyyc/02463a6dc5a150772bd8f0ae42d4cd37

Summary for this PR:

  • Changes for continuation token in paging:
  1. add new property isContinuationToken in parameter
  2. add new property ContinuationTokenRequest/ContinuationTokenResponse for paging operation whose type is {wireName: string, position: "header" | "query" | "body"}
  3. With new property isContinuationToken/ContinuationTokenRequest/ContinuationTokenResponse, it is much easier for pygen to generate related API
  4. replace continuationTokenName which is actually used as with nextLinkName with nextLinkName
  • replace some deprecated property of TCGC with recommended property
  • optimize the logic to report diagnostics

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Mar 4, 2025
@azure-sdk
Copy link
Collaborator

azure-sdk commented Mar 4, 2025

All changed packages have been documented.

  • @typespec/http-client-python
Show changes

@typespec/http-client-python - feature ✏️

support continuation token for paging

@azure-sdk
Copy link
Collaborator

azure-sdk commented Mar 4, 2025

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@msyyc msyyc changed the title [python] support continuation token for paging [python] support continuation token for paging (not ready to review) Mar 4, 2025
@msyyc msyyc changed the title [python] support continuation token for paging (not ready to review) [python] support continuation token for paging Mar 4, 2025
Comment on lines +102 to +110
if (segments.length > 0 && segments[0].kind === "property") {
const result = [];
for (const segment of segments) {
if (segment.kind === "property") {
result.push(segment.serializationOptions.json?.name ?? "");
}
}
return result.join(".");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (segments.length > 0 && segments[0].kind === "property") {
const result = [];
for (const segment of segments) {
if (segment.kind === "property") {
result.push(segment.serializationOptions.json?.name ?? "");
}
}
return result.join(".");
}
if (segments[0]?.kind === "property") {
return segments.filter(s=>s.kind === "property").map(s=>s.serializationOptions.json?.name ?? "").join(".");
}

Comment on lines +115 to +116
if self.is_continuation_token:
return f"{self.client_name} if _next_token is _Unset else _next_token"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we do not need _Unset as i mentioned in the generated code change pr, then we do not need this is_continuation_token, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:client:python Issue for the Python client emitter: @typespec/http-client-python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http-client-python Paging ContinuationToken Implementation
3 participants