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

Pagination refactor + Space awareness for Kibana #721

Conversation

lucabelluccini
Copy link
Contributor

@lucabelluccini lucabelluccini commented Aug 20, 2024

Attempt to solve #578

Checklist

  • Test with older versions of Kibana
  • Review the list of APIs and make them paginated, space aware (or both)

Notes/Obs

The KibanaUrl code could be integrated in the RestEntry - if we agree on that we can change it.


Hold prior merging.

@lucabelluccini
Copy link
Contributor Author

Thank you @pickypg for the review - I'll work on #721 (comment)

Copy link
Member

@pickypg pickypg left a comment

Choose a reason for hiding this comment

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

I am going to merge this and make a few tweaks to push.

Comment on lines +107 to +119
if(current.isSpaceAware()) {
for(String spaceId : spacesIds) {
RestEntry tmp = new RestEntry(current);
// The calls made for the default Space will be written without a subpath
if(!spaceId.equals("default")) {
tmp.url = String.format("/s/%s%s", spaceId, tmp.getUrl());
// Sanitizing the spaceId to make it "safe" for a filepath
tmp.subdir = Paths.get(tmp.subdir, "space_" + spaceId.replaceAll("[^a-zA-Z0-9-_]", "_")).normalize().toString();
}
if(current.isPageable()) {
getAllPages(client, queries, context.perPage, tmp, current.getPageableFieldName());
} else {
queries.add(tmp);
Copy link
Member

Choose a reason for hiding this comment

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

tmp is a bit of an ambiguous name for this usage. We should name it so a future reader can understand it.
 

Suggested change
if(current.isSpaceAware()) {
for(String spaceId : spacesIds) {
RestEntry tmp = new RestEntry(current);
// The calls made for the default Space will be written without a subpath
if(!spaceId.equals("default")) {
tmp.url = String.format("/s/%s%s", spaceId, tmp.getUrl());
// Sanitizing the spaceId to make it "safe" for a filepath
tmp.subdir = Paths.get(tmp.subdir, "space_" + spaceId.replaceAll("[^a-zA-Z0-9-_]", "_")).normalize().toString();
}
if(current.isPageable()) {
getAllPages(client, queries, context.perPage, tmp, current.getPageableFieldName());
} else {
queries.add(tmp);
if (current.isSpaceAware()) {
for (String spaceId : spacesIds) {
RestEntry spaceEntry = new RestEntry(current);
// The calls made for the default Space will be written without a subpath
if (!spaceId.equals("default")) {
spaceEntry.url = String.format("/s/%s%s", spaceId, spaceEntry.getUrl());
// Sanitizing the spaceId to make it "safe" for a filepath
spaceEntry.subdir = Paths.get(spaceEntry.subdir, "space_" + spaceId.replaceAll("[^a-zA-Z0-9-_]", "_")).normalize().toString();
}
if(current.isPageable()) {
getAllPages(client, queries, context.perPage, spaceEntry, current.getPageableFieldName());
} else {
queries.add(spaceEntry);

Comment on lines +96 to +99
if(pageableFieldName != null) {
this.pageableFieldName = pageableFieldName;
this.isPageable = true;
}
Copy link
Member

Choose a reason for hiding this comment

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

In the [unlikely] event where we're unsetting it, we need to properly reflect that state.

Suggested change
if(pageableFieldName != null) {
this.pageableFieldName = pageableFieldName;
this.isPageable = true;
}
this.pageableFieldName = pageableFieldName;
this.isPageable = pageableFieldName != null;

Comment on lines +24 to +25
">= 7.0.0":
url: "/api/actions"
Copy link
Member

Choose a reason for hiding this comment

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

There's no harm in it, but we don't need to specify the "verbose" format when we don't need it.

We could just do

Suggested change
">= 7.0.0":
url: "/api/actions"
">= 7.0.0": "/api/actions"

@pickypg pickypg merged commit eccc36c into elastic:main Sep 6, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants