-
Notifications
You must be signed in to change notification settings - Fork 0
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
MIDRC-901 Add S3 endpoint #30
Conversation
The style in this PR agrees with This formatting comment was generated automatically by a script in uc-cdis/wool. |
620a009
to
303c570
Compare
866b9de
to
4032cc4
Compare
be generated properly. This ensures unique operation IDs are generated for all routes. | ||
""" | ||
existing_routes = set() | ||
for route in app.routes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this section seems suspicious, although I think I see what you're doing.
making existing_routes a set is a good start.
we can filter out non api routes via
for route in app.routes: | |
api_routes_only = list(filter(lambda r: isinstance(r, APIRoute), app.routes) |
then, you could do a for index, route in api_routes_only
sort of thing.
the index is going to be unique for each route, so I don't think you'd need the while loop.
e.g.
for route in app.routes: | |
for index, route in enumerate(api_routes_only): | |
route.op_id = f"{route.name}_{index}" | |
existing_routes.add(route.operating_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the goal is to avoid duplicate route IDs by calling them get_status
, get_status_2
, get_status_3
etc. Not adding a digit to all routes, although of course that would make them unique too 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tentative approval. I am not that familiar with s3 stuff, so I would suggest seeking a few more eyes before merging.
logger.error(f"Error from AWS: {response.status_code} {response.text}") | ||
|
||
# return the response from AWS S3 | ||
if "Content-Type" in response.headers: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we only want to return response if the content-type is set? Probably true, but just curious 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still return the response if the content-type isn't set, but in that case we don't include media_type=response.headers["Content-Type"]
👍
Apart from that one question this is very cool. This will be great! |
Link to JIRA ticket if there is one: https://ctds-planx.atlassian.net/browse/MIDRC-901
New Features
/s3
endpoint, which receives incoming S3 requests, re-signs them with internal credentials, and forwards them to AWS S3Improvements