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

Admin API part 3 #983

Merged
merged 12 commits into from
Aug 14, 2024
Merged

Admin API part 3 #983

merged 12 commits into from
Aug 14, 2024

Conversation

jbygdell
Copy link
Collaborator

@jbygdell jbygdell commented Aug 8, 2024

Related issue(s) and PR(s)
None

Description
This PR mainly adds the ways to define which users should have admin access.

How to test

@jbygdell jbygdell self-assigned this Aug 8, 2024
@jbygdell jbygdell requested a review from a team August 8, 2024 12:49
@jbygdell jbygdell marked this pull request as ready for review August 8, 2024 12:50
aaperis
aaperis previously approved these changes Aug 8, 2024
Copy link
Contributor

@aaperis aaperis left a comment

Choose a reason for hiding this comment

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

Nice!

sda/cmd/api/api.md Outdated Show resolved Hide resolved
sda/internal/database/db_functions.go Outdated Show resolved Hide resolved
sda/cmd/api/api.md Outdated Show resolved Hide resolved
sda/cmd/api/api.go Show resolved Hide resolved
sda/cmd/api/api.md Outdated Show resolved Hide resolved
Copy link
Contributor

@nanjiangshu nanjiangshu left a comment

Choose a reason for hiding this comment

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

Great work!

Apart from the comments in the code, I have a few other comments:

  1. When I tested with the following command
$ curl -s -w "%{http_code}\n" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -X POST -d '{"accession_id": "my-id-01", "filepath": "/uploads/file.c4gh", "user": "testuser"}' http://localhost:8090/file/accession

It's a bit weird that the return code is 000.

  1. I got an empty list for the following command
curl -H "Authorization: Bearer $token"  "http://localhost:8090/users/[email protected]/files" 

However, I got

$ curl -H "Authorization: Bearer $token"  "http://localhost:8090/files"
[{"inboxPath":"requester_demo.org/data/file1.c4gh","fileStatus":"uploaded","createAt":"2024-08-09T14:28:14.43718Z"}]

and

$ curl -H "Authorization: Bearer $token"  "http://localhost:8090/users"
["[email protected]","[email protected]"] 

What did I do wrong?

  1. Formatting in the README: Error code for each API endpoint section should be under the section, for example
* /file/ingest
    - accepts POST requests with JSON data with the format: {"filepath": "</PATH/TO/FILE/IN/INBOX>", "user": "<USERNAME>"}
    - triggers the ingestion of the file.
* Error codes
    - 200 Query execute ok.
    - 400 Error due to bad payload i.e. wrong user + filepath combination.

should be changed to

- /file/ingest
    - accepts POST requests with JSON data with the format: {"filepath": "</PATH/TO/FILE/IN/INBOX>", "user": "<USERNAME>"}
    - triggers the ingestion of the file.

    * Error codes
        - 200 Query execute ok.
        - 400 Error due to bad payload i.e. wrong user + filepath combination.

pontus
pontus previously approved these changes Aug 13, 2024
@pontus
Copy link
Contributor

pontus commented Aug 13, 2024

Would admin.usersFile work instead of admin.configFile, while it is undoubtedly a configuration, configFile makes me think it could possibly controls more things.

@jbygdell jbygdell dismissed stale reviews from pontus and aaperis via dab44e2 August 13, 2024 08:33
@jbygdell jbygdell force-pushed the feature/api-part-3 branch 3 times, most recently from 02bc0ad to 898e3a7 Compare August 13, 2024 08:42
@jbygdell
Copy link
Collaborator Author

Would admin.usersFile work instead of admin.configFile, while it is undoubtedly a configuration, configFile makes me think it could possibly controls more things.

Yes, that would improve readability.

@jbygdell jbygdell force-pushed the feature/api-part-3 branch from ba98238 to 1d3af59 Compare August 13, 2024 08:48
@jbygdell jbygdell requested a review from pontus August 13, 2024 09:11
pontus
pontus previously approved these changes Aug 13, 2024
MalinAhlberg
MalinAhlberg previously approved these changes Aug 13, 2024
nanjiangshu
nanjiangshu previously approved these changes Aug 13, 2024
@jbygdell jbygdell added this pull request to the merge queue Aug 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 13, 2024
aaperis
aaperis previously approved these changes Aug 13, 2024
Copy link
Contributor

@aaperis aaperis left a comment

Choose a reason for hiding this comment

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

Minor suggestions :-)

.github/integration/tests/sda/60_api_admin_test.sh Outdated Show resolved Hide resolved
sda/cmd/api/api_test.go Show resolved Hide resolved
sda/cmd/api/api_test.go Show resolved Hide resolved
@jbygdell jbygdell dismissed stale reviews from aaperis, nanjiangshu, MalinAhlberg, and pontus via 87f8a7f August 14, 2024 05:26
@jbygdell jbygdell enabled auto-merge August 14, 2024 05:27
MalinAhlberg
MalinAhlberg previously approved these changes Aug 14, 2024
Copy link
Contributor

@aaperis aaperis left a comment

Choose a reason for hiding this comment

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

Looks good :-)

@jbygdell jbygdell added this pull request to the merge queue Aug 14, 2024
Merged via the queue into main with commit f071caf Aug 14, 2024
24 checks passed
@jbygdell jbygdell deleted the feature/api-part-3 branch August 14, 2024 13:33
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.

5 participants