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

feat(filemanager): accept multiple keys in API #596

Merged
merged 6 commits into from
Oct 8, 2024

Conversation

mmalenic
Copy link
Member

@mmalenic mmalenic commented Oct 8, 2024

Closes #595

Changes

  • The filemanager API can now accept multiple keys in the API, where each additional key represents an or statement in the SQL query.
    • Additional keys need to use the [] syntax to specify a list. E.g. /api/v1/s3?key[]=key1&key[]=key2.
  • Multiple keys are also supported on attributes.
    • The logic involving attributes has been fixed so that JSON arrays represent an or condition.

@mmalenic mmalenic self-assigned this Oct 8, 2024
@mmalenic mmalenic added feature New feature filemanager an issue relating to the filemanager labels Oct 8, 2024
curl -H "Authorization: Bearer $TOKEN" "https://file.dev.umccr.org/api/v1/s3?bucket[]=bucket1&bucket[]=bucket2" | jq
```

Note that the extra `[]` is required in the query parameters to specify multiple keys with the same name. Multiple keys
Copy link
Member

@williamputraintan williamputraintan Oct 8, 2024

Choose a reason for hiding this comment

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

What is the reason behind it where it needs to have the [] for a multiple key? Will this be mutually exclusive with the params that does not have the []? Say ...s3?bucket=bucket1&bucket[]=bucket2 is not possible?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's required in the library that parses the query string: https://github.com/samscott89/serde_qs. I think the choice by the author has to do with matching the style of ruby on rails.

Yes, this is mutually exclusive, you can't combine keys with [] and without it.

For example, this works:

  1. /api/v1/s3?key=...
  2. /api/v1/s3?key[]=...
  3. /api/v1/s3?key[]=...&key[]=...

But this results in an error:

  1. /api/v1/s3?key=...&key[]=...

@mmalenic mmalenic requested a review from brainstorm October 8, 2024 03:24
Copy link
Member

@williamputraintan williamputraintan left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the quick feature request update.

@mmalenic mmalenic merged commit fc3e9a1 into main Oct 8, 2024
6 checks passed
@mmalenic mmalenic deleted the filemanager/api-improvements branch October 8, 2024 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature filemanager an issue relating to the filemanager
Projects
None yet
Development

Successfully merging this pull request may close these issues.

filemanager: allow API to accept multiple filter parameters with the same key
3 participants