-
Notifications
You must be signed in to change notification settings - Fork 252
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
Use cursor based pagination for endpoints that support it #614
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I cannot test them. As said in the
Last PR, even if we don't implement 100% of zendesk APIs it might be great to start to provide a stable API and to have a formal versioning.
(Especially if we can get some official support from Zendesk like here)
@PierreBtz 🌞 Looking for administrative review 🌞 |
Sorry I didn't have time to progress on this. I'll progress on the review and testing next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good to me, but there is a big issue in that the Rest API documentation hasn't been properly updated for me to validate the changes (except by trial and error...).
The doc clearly states that CBP works in two different ways (Paginating with the next link
and Paginating with the after cursor
), and that we should refer to each individual endpoint documentation to know what is supported, but, except if I missed something, there are a large number of endpoints that either do not specify anything, or show examples using the old OBP.
This makes it hard to entirely review this change, and be confident things won't break in the future.
This has nothing to do with your PR per-se, thanks a lot for the work you put into this, but I think we should clarify and have the documentation updated.
I can take care of this through the support but maybe things will go faster if you ask internally?
public List<Brand> getBrands() { | ||
return complete(submit(req("GET", cnst("/brands.json")), handleList(Brand.class, "brands"))); | ||
public Iterable<Brand> getBrands() { | ||
return new PagedIterable<>(cbp("/brands.json"), handleList(Brand.class, "brands")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change doesn't match the current Rest API documentation.
According to it:
- a endpoint may or may not support CBP, I need to refer to the endpoint documentation (https://developer.zendesk.com/documentation/api-basics/pagination/paginating-through-lists-using-cursor-pagination/).
- refering to the brand endpoint, the only example I see uses OBP (https://developer.zendesk.com/api-reference/ticketing/account-configuration/brands/)
This is of importance, because according to the documentation, depending on the endpoint we need to check the endpoint doc to choose between "Paginating with the after cursor" and "Paginating with the next link".
Usually I would open a ticket with Zendesk support to get clarification and update of the doc if necessary, but in this case I trust you'll have a quicker answer by yourself :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This endpoint is not in the list provided in https://support.zendesk.com/hc/en-us/articles/5591904358938-New-limits-for-offset-based-pagination#h_01GNCT8Z7DJ7G4TQ3CFFXQ007Z
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PierreBtz The support for Cursor Model is determined based on the endpoint use case and the depth of records we saw in the system for all customers.
We are working on your feedback and currently evaluating the pagination information in the developer docs. We will get the right details added to every endpoint. There is active work in progress now on this outcome. Should be done soon.
@PierreBtz Here is an article that outlines every endpoint that has CBP (as a choice by passing page[size]=XXX). I will advise internal documentation of the gap and they'll proceed with your suggestions or answer them!. |
Thanks for the article, it indeed gives a list of endpoints supporting CBP, I'll use that as a reference for this PR, hoping to see the rest api doc updated in the future :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're nearly ready to merge.
I still found a handful of endpoints without any documentation suggesting CBP support (either in the announcement post or the endpoint doc). Once this is sorted out, I think this will be ready.
public List<Brand> getBrands() { | ||
return complete(submit(req("GET", cnst("/brands.json")), handleList(Brand.class, "brands"))); | ||
public Iterable<Brand> getBrands() { | ||
return new PagedIterable<>(cbp("/brands.json"), handleList(Brand.class, "brands")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This endpoint is not in the list provided in https://support.zendesk.com/hc/en-us/articles/5591904358938-New-limits-for-offset-based-pagination#h_01GNCT8Z7DJ7G4TQ3CFFXQ007Z
submit( | ||
req("GET", tmpl("/tickets/{id}/incidents.json").set("id", id)), | ||
handleList(Ticket.class, "tickets"))); | ||
public Iterable<Ticket> getTicketIncidents(long id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in the list provided in https://support.zendesk.com/hc/en-us/articles/5591904358938-New-limits-for-offset-based-pagination#h_01GNCT8Z7DJ7G4TQ3CFFXQ007Z
The endpoint documentation doesn't include CBP either (https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-ticket-incidents)
@@ -1500,18 +1505,18 @@ public Iterable<AgentRole> getCustomAgentRoles() { | |||
|
|||
public Iterable<org.zendesk.client.v2.model.Request> getRequests() { | |||
return new PagedIterable<>( | |||
cnst("/requests.json"), handleList(org.zendesk.client.v2.model.Request.class, "requests")); | |||
cbp("/requests.json"), handleList(org.zendesk.client.v2.model.Request.class, "requests")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in the list provided in support.zendesk.com/hc/en-us/articles/5591904358938-New-limits-for-offset-based-pagination#h_01GNCT8Z7DJ7G4TQ3CFFXQ007Z
The endpoint documentation doesn't include CBP either https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#list-requests
} | ||
|
||
public Iterable<org.zendesk.client.v2.model.Request> getOpenRequests() { | ||
return new PagedIterable<>( | ||
cnst("/requests/open.json"), | ||
cbp("/requests/open.json"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
handleList(org.zendesk.client.v2.model.Request.class, "requests")); | ||
} | ||
|
||
public Iterable<org.zendesk.client.v2.model.Request> getSolvedRequests() { | ||
return new PagedIterable<>( | ||
cnst("/requests/solved.json"), | ||
cbp("/requests/solved.json"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
"GET", | ||
tmpl("/users/{user_id}/organization_memberships.json").set("user_id", user_id)), | ||
handleList(OrganizationMembership.class, "organization_memberships"))); | ||
public Iterable<OrganizationMembership> getOrganizationMembershipByUser(long user_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, we could probably deprecate this method for later deletion, but outside of the scope of this PR.
@@ -2583,7 +2580,7 @@ public Iterable<DynamicContentItemVariant> getDynamicContentItemVariants( | |||
DynamicContentItem item) { | |||
checkHasId(item); | |||
return new PagedIterable<>( | |||
tmpl("/dynamic_content/items/{id}/variants.json").set("id", item.getId()), | |||
cbp("/dynamic_content/items/{id}/variants.json").set("id", item.getId()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in the list provided in support.zendesk.com/hc/en-us/articles/5591904358938-New-limits-for-offset-based-pagination#h_01GNCT8Z7DJ7G4TQ3CFFXQ007Z
The endpoint documentation doesn't include CBP either https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content/#list-items
@@ -2537,7 +2534,7 @@ public SatisfactionRating createSatisfactionRating( | |||
|
|||
public Iterable<DynamicContentItem> getDynamicContentItems() { | |||
return new PagedIterable<>( | |||
cnst("/dynamic_content/items.json"), handleList(DynamicContentItem.class, "items")); | |||
cbp("/dynamic_content/items.json"), handleList(DynamicContentItem.class, "items")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in the list provided in support.zendesk.com/hc/en-us/articles/5591904358938-New-limits-for-offset-based-pagination#h_01GNCT8Z7DJ7G4TQ3CFFXQ007Z
The endpoint documentation doesn't include CBP either developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content/#list-items
I took the liberty of refreshing your branch onto the latest master commits, and also fix the formatting, so that we have a fresh CI run. Btw I finally understood the trouble you had with spotless. It turns out the formatting is different between a jdk8 and a jdk11/17... The project is still compatible with Java 8, so you need to format using a jdk8. |
@PierreBtz We're going to address your concerns. Thanks so much for looking all this up. |
@cryptomail @sircpl any news on your side, you did a good and important work and I'm a bit sad to see it blocked for some documentation issues. |
@cryptomail @sircpl I had a quick look and the endpoints are still not officially compatible with CBP. My proposal to get this moving is to partially revert the problematic endpoints and merge the rest of the work. Would that work for you? I can take care of the partial revert. |
@PierreBtz Let me have a talk with product and follow up with their documentation efforts: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed privately with the Zendesk team, I'm going ahead with the merge in advance of the documentation update.
Use CBP for all endpoints that support it.
This PR does not include any of the newly added endpoints in #608. New endpoints supporting CBP will be added after this PR is merged (since this PR contains the
cbp
method).