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

Use cursor based pagination for endpoints that support it #614

Merged
merged 5 commits into from
Nov 6, 2023

Conversation

sircpl
Copy link
Contributor

@sircpl sircpl commented Aug 30, 2023

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).

@sircpl sircpl mentioned this pull request Aug 30, 2023
Copy link
Contributor

@aheritier aheritier left a 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)

@cryptomail
Copy link

@PierreBtz 🌞 Looking for administrative review 🌞

@PierreBtz
Copy link
Collaborator

Sorry I didn't have time to progress on this. I'll progress on the review and testing next week.

@PierreBtz PierreBtz added the chore label Sep 4, 2023
Copy link
Collaborator

@PierreBtz PierreBtz left a 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"));
Copy link
Collaborator

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:

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 :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

@cryptomail
Copy link

cryptomail commented Sep 4, 2023

@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!.

@PierreBtz
Copy link
Collaborator

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 :)

Copy link
Collaborator

@PierreBtz PierreBtz left a 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"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

submit(
req("GET", tmpl("/tickets/{id}/incidents.json").set("id", id)),
handleList(Ticket.class, "tickets")));
public Iterable<Ticket> getTicketIncidents(long id) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -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"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

}

public Iterable<org.zendesk.client.v2.model.Request> getOpenRequests() {
return new PagedIterable<>(
cnst("/requests/open.json"),
cbp("/requests/open.json"),
Copy link
Collaborator

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"),
Copy link
Collaborator

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) {
Copy link
Collaborator

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()),
Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -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"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

@PierreBtz
Copy link
Collaborator

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.

@cryptomail
Copy link

@PierreBtz We're going to address your concerns. Thanks so much for looking all this up.
You're 100% correct that article is incomplete. Just from cursory inspection and execution of the endpoint https://mydomain.zendesk.com/api/v2/dynamic_content/items?page[size]=1 returns CBP as the output protocol.
Again you have pointed out clean deficiencies within the documentation of our API that must be addressed.

@PierreBtz
Copy link
Collaborator

@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.

@PierreBtz
Copy link
Collaborator

@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.

@cryptomail
Copy link

@PierreBtz Let me have a talk with product and follow up with their documentation efforts:

Copy link
Collaborator

@PierreBtz PierreBtz left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants