Unleash/unleash

API query parameter for sorting tokens list

gelm0 opened this issue · 1 comments

gelm0 commented

Describe the feature request

I would like these two endpoints to have a query parameter for sorting tokens in ascending/descending order based on the creation date.

Some suggestions:
https://<url>/api/admin/api-tokens?sort=asc
https://<url>/api/admin/api-tokens?sort=desc

If you wanna be fancy you could include the option to also sort by all the date keys
https://<url>/api/admin/api-tokens?sort=asc&key=createdAt
https://<url>/api/admin/api-tokens?sort=asc&key=expiredAt
https://<url>/api/admin/api-tokens?sort=asc&key=seenAt

https://docs.getunleash.io/reference/api/unleash/get-all-api-tokens
https://docs.getunleash.io/reference/api/unleash/get-api-tokens-by-name

Background

It's nice to have when doing some API operations. It's more of a nice to have since I can always sort the data from the request afterwards.

Solution suggestions

Some additional logic here should probably do the trick, if you want I can whip up a PR:

private async accessibleTokensByName(

private async accessibleTokens(user: User): Promise<IApiToken[]> {

Tymek commented

I don't feel like this is the approach we will take. Sort/filter on API queries should be consistent with other endpoints. Adding it to only one will create an expectation for other endpoints. We are considering adding backend search to api, but it's not scheduled yet. Our priorities are listed here: https://github.com/orgs/Unleash/projects/5