diff --git a/CHANGELOG.md b/CHANGELOG.md index 618e5016aa..989bf3727b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and what APIs have changed, if applicable. ## [Unreleased] +## [29.48.3] - 2023-11-28 +- Add standardized models for cursor based pagination + ## [29.48.2] - 2023-11-27 - Remove usage of Optional from SimpleLoadBalancer @@ -5569,7 +5572,8 @@ patch operations can re-use these classes for generating patch messages. ## [0.14.1] -[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.48.2...master +[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.48.3...master +[29.48.3]: https://github.com/linkedin/rest.li/compare/v29.48.2...v29.48.3 [29.48.2]: https://github.com/linkedin/rest.li/compare/v29.48.1...v29.48.2 [29.48.1]: https://github.com/linkedin/rest.li/compare/v29.48.0...v29.48.1 [29.48.0]: https://github.com/linkedin/rest.li/compare/v29.47.0...v29.48.0 diff --git a/gradle.properties b/gradle.properties index 4224297576..3ee0a628a2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=29.48.2 +version=29.48.3 group=com.linkedin.pegasus org.gradle.configureondemand=true org.gradle.parallel=true diff --git a/restli-common/src/main/pegasus/com/linkedin/restli/common/CursorPagination.pdl b/restli-common/src/main/pegasus/com/linkedin/restli/common/CursorPagination.pdl new file mode 100644 index 0000000000..b4683af6c8 --- /dev/null +++ b/restli-common/src/main/pegasus/com/linkedin/restli/common/CursorPagination.pdl @@ -0,0 +1,13 @@ +namespace com.linkedin.restli.common + +/** + * Metadata for cursor based pagination with collections. + */ +record CursorPagination { + + /** + * Pagination cursor that points to the end of the current page and can be used to fetch the next page. + * Not populated if the current page is the last page. + */ + next: optional string +} \ No newline at end of file diff --git a/restli-common/src/main/resources/legacyPegasusSchemas/com/linkedin/restli/common/CursorPagination.pdsc b/restli-common/src/main/resources/legacyPegasusSchemas/com/linkedin/restli/common/CursorPagination.pdsc new file mode 100644 index 0000000000..45949aa27e --- /dev/null +++ b/restli-common/src/main/resources/legacyPegasusSchemas/com/linkedin/restli/common/CursorPagination.pdsc @@ -0,0 +1,12 @@ +{ + "type" : "record", + "name" : "CursorPagination", + "namespace" : "com.linkedin.restli.common", + "doc" : "Metadata for cursor based pagination with collections.", + "fields" : [ { + "name" : "next", + "type" : "string", + "doc" : "Pagination cursor that points to the end of the current page and can be used to fetch the next page.\nNot populated if the current page is the last page.", + "optional" : true + } ] +} diff --git a/restli-server/src/main/java/com/linkedin/restli/server/CursorCollectionResult.java b/restli-server/src/main/java/com/linkedin/restli/server/CursorCollectionResult.java new file mode 100644 index 0000000000..2e9b04acb5 --- /dev/null +++ b/restli-server/src/main/java/com/linkedin/restli/server/CursorCollectionResult.java @@ -0,0 +1,23 @@ +package com.linkedin.restli.server; + +import com.linkedin.data.template.RecordTemplate; +import com.linkedin.restli.common.CursorPagination; +import java.util.List; + + +/** + * Convenience extension to {@link CollectionResult} for use with cursor based pagination. + */ +public class CursorCollectionResult extends CollectionResult +{ + /** + * Constructor + * + * @param elements List of elements in the current page. + * @param pagination The cursor pagination metadata. + */ + public CursorCollectionResult(final List elements, CursorPagination pagination) + { + super(elements, null, pagination); + } +}