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

clientcore, PagedIterable / PagedResponse / PagingOptions #43484

Merged
merged 26 commits into from
Jan 10, 2025

Conversation

weidongxu-microsoft
Copy link
Member

@weidongxu-microsoft weidongxu-microsoft commented Dec 19, 2024

design https://gist.github.com/srnagar/e9373153593920dcf1977c928c59e988

code in impl would be like

    public PagedIterable<TodoItem> list(RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(requestOptions != null && requestOptions.getContext() != null
            ? requestOptions.getContext()
            : Context.none());
        return new PagedIterable<>(() -> listSinglePage(requestOptions),
            nextLink -> listNextSinglePage(nextLink, requestOptionsForNextPage));
    }

    private PagedResponse<TodoItem> listSinglePage(RequestOptions requestOptions) {
        final String accept = "application/json";
        Response<TodoPage> res = service.listSync(this.client.getEndpoint(), accept, requestOptions);
        return new PagedResponse<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getBody(),
            res.getValue().getItems(), res.getValue().getNextLink());
    }

    private PagedResponse<TodoItem> listNextSinglePage(String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        Response<TodoPage> res = service.listNextSync(nextLink, this.client.getEndpoint(), accept, requestOptions);
        return new PagedResponse<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getBody(),
            res.getValue().getItems(), res.getValue().getNextLink());
    }

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

io.clientcore:core

@weidongxu-microsoft weidongxu-microsoft changed the title [draft] add a simple PagedIterable / PagedResponse [draft] a simple PagedIterable / PagedResponse Dec 19, 2024
Copy link
Contributor

@XiaofeiCao XiaofeiCao left a comment

Choose a reason for hiding this comment

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

LGTM for nextLink.

@weidongxu-microsoft weidongxu-microsoft changed the title [draft] a simple PagedIterable / PagedResponse clientcore, PagedIterable / PagedResponse Jan 9, 2025
@weidongxu-microsoft weidongxu-microsoft changed the title clientcore, PagedIterable / PagedResponse clientcore, PagedIterable / PagedResponse / PagingOptions Jan 9, 2025
@weidongxu-microsoft weidongxu-microsoft enabled auto-merge (squash) January 10, 2025 06:02
@weidongxu-microsoft weidongxu-microsoft merged commit 15b2a10 into main Jan 10, 2025
16 checks passed
@weidongxu-microsoft weidongxu-microsoft deleted the clientcore-paged branch January 10, 2025 06:05
github-merge-queue bot pushed a commit to microsoft/typespec that referenced this pull request Jan 20, 2025
depends on Azure/azure-sdk-for-java#43484 and
release of clientcore beta.2

back to draft: there is lots of changes to clientcore right now

test
827f4ec
code is scattered as there is multiple commits to adapt core changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants