Skip to content

feat: enhance admin api filter#12291

Merged
bzp2010 merged 14 commits into
apache:masterfrom
bzp2010:bzp/feat-admin-api-filter-enhance
Jun 11, 2025
Merged

feat: enhance admin api filter#12291
bzp2010 merged 14 commits into
apache:masterfrom
bzp2010:bzp/feat-admin-api-filter-enhance

Conversation

@bzp2010

@bzp2010 bzp2010 commented Jun 6, 2025

Copy link
Copy Markdown
Contributor

Description

Added filter enhancements to the Admin API, allowing routes and stream routes to be filtered by service_id and upstream_id.

This is mainly used to enhance the APISIX dashboard.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@bzp2010
bzp2010 marked this pull request as ready for review June 6, 2025 09:10
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jun 6, 2025
Comment thread docs/en/latest/admin-api.md
Comment thread docs/en/latest/admin-api.md Outdated
SkyeYoung
SkyeYoung previously approved these changes Jun 9, 2025
AlinsRan
AlinsRan previously approved these changes Jun 9, 2025
Comment thread apisix/admin/v3_adapter.lua Outdated
@bzp2010
bzp2010 requested a review from nic-6443 June 9, 2025 06:16
@bzp2010
bzp2010 dismissed stale reviews from AlinsRan and SkyeYoung via f776dfe June 9, 2025 10:33
@bzp2010
bzp2010 requested a review from kayx23 June 9, 2025 12:08
Comment thread docs/en/latest/admin-api.md Outdated
Comment thread apisix/admin/v3_adapter.lua
The following example filters routes using `service_id`. Applying multiple filters simultaneously will return results that match all filter conditions.

```shell
curl 'http://127.0.0.1:9180/apisix/admin/routes?filter=service_id%3D1' \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

one question: can we adjust to use the format a[b]=c&a[d]=e? It seems more common. https://www.npmjs.com/package/qs

@bzp2010 bzp2010 Jun 11, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is no existing API for parsing query strings for such objects in OpenResty, so it may have to use regular expressions to do so.
I don't want to do that right now. The existing format can be implemented in any language client, it's nothing more than a URI-encoded string.

ngx.log(ngx.ERR, require("cjson").encode(ngx.decode_args("filter%5Bservice_id%5D=a&filter%5Bservice_id%5D=b&b=c&c=c")))
[lua] test.lua:1: {"filter[service_id]":["a","b"],"b":"c","c":"c"}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

image

It's too complicated to support something like this.

@bzp2010
bzp2010 requested review from SkyeYoung, kayx23 and membphis June 11, 2025 04:18
kayx23
kayx23 previously approved these changes Jun 11, 2025

@kayx23 kayx23 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

docs LGTM

SkyeYoung
SkyeYoung previously approved these changes Jun 11, 2025
nic-6443
nic-6443 previously approved these changes Jun 11, 2025
Comment thread docs/en/latest/admin-api.md Outdated
Comment thread docs/zh/latest/admin-api.md Outdated
@bzp2010
bzp2010 dismissed stale reviews from nic-6443, SkyeYoung, and kayx23 via 0cac9bf June 11, 2025 06:33
@bzp2010
bzp2010 requested a review from juzhiyuan June 11, 2025 06:34

@juzhiyuan juzhiyuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@bzp2010
bzp2010 requested review from SkyeYoung and nic-6443 June 11, 2025 06:40
@bzp2010
bzp2010 requested review from AlinsRan and kayx23 June 11, 2025 07:11
@bzp2010
bzp2010 merged commit 460c3be into apache:master Jun 11, 2025
36 of 37 checks passed
laz-xyr pushed a commit to laz-xyr/apisix that referenced this pull request Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants