-
Notifications
You must be signed in to change notification settings - Fork 135
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
API keys: tidy up the routes #4555
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4555 +/- ##
==========================================
- Coverage 58.50% 58.41% -0.10%
==========================================
Files 883 883
Lines 29239 29298 +59
Branches 4234 4252 +18
==========================================
+ Hits 17105 17113 +8
- Misses 12134 12185 +51 |
bba394c
to
295a030
Compare
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.
Need to ...
- associate with an issue as a breaking change, Neil or I will do this
- decide what serves Swagger UI and how swagger.json is generated, Neil will do this
- do a second pass to additional routes from from
pp
intoapi
, I will create an issue for this - thoroughly test when ready to merge
- echo update related things, lile web sockets
- deployment mechanisms (cf push, AIO, etc) for swagger file changes
@@ -12,6 +12,16 @@ const PROXY_CONFIG = { | |||
"ws": true, | |||
"secure": false, | |||
"changeOrigin": true, | |||
}, | |||
"/api": { | |||
"target": { |
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.
There's a node script ./build/dev-setup.js
that copies this file to proxy.conf.js
. For people who already have this their copy won't get update. The script should, if it already exists, replace "/pp"
with `"/api".
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.
Not all of the /pp
endpoints have been migrated to /api
, just the ones outlined in #4532. So replacing /pp
with /api
will break the leftover endpoints.
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.
@nwmac hmm, should I add some fancy logic to ./build/dev-setup.js
to add an /api
section to proxy.conf.localdev.js
if it's missing, or should this be left to the developer?
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.
@ikapelyukhin I think we should add the fancy logic OR if that's a i real pain, a simpler option is:
- if the file
proxy.conf.js
does not exist, create it as we do now - if
proxy.conf.js
exists but has not been changed (same MD5), then overwrite it with the new version - otherwise, warn the user that they need to update it manyally
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.
OK, sounds reasonable, done.
src/jetstream/docs/swagger.json
Outdated
@@ -0,0 +1,56 @@ | |||
{ |
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 file won't automatically be include when deployed, we'd need to ensure it gets included in container images.
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.
It doesn't need to be deployed. There's docs/docs.go
which is then served as /swagger/doc.json
by the middleware.
Assuming that we want to use the middleware approach that is.
@ikapelyukhin Had a look through with Richard - he's left some comments. I like the godoc comments for the APIs - you mentioned that it doesn't support OpenAPI V3, specifically the bearer auth - one option would be to submit a PR to swaggo with support for that feature, if that is what is needed to use it. I think there are two main use cases for the OpenAPI:
|
That'd probably result in a non-standard API doc (a mix of v2 and v3) -- that doesn't sound too thrilling. Implementing a middleware for OpenAPI v3 or just bundling some front-end code to render the API doc seems like a more realistic solution.
@nwmac @richard-cox run the code from the current branch and see https://localhost:5443/swagger/index.html and https://localhost:5443/swagger/doc.json. Sorry, I should have probably mentioned that earlier. |
b351060
to
551d059
Compare
I've dropped |
curl commands for testing the API: export API_SECRET='replaceme'
export USERNAME='replaceme'
export PASSWORD='replaceme'
export API_ENDPOINT='https://api.cap.explore.suse.dev/'
# add endpoint
curl -k -X POST "https://localhost:5443/api/v1/endpoints" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET" -F "endpoint_type=cf" -F "cnsi_name=Potato" -F "api_endpoint=$API_ENDPOINT"
# list endpoints
curl -k -X GET "https://localhost:5443/api/v1/endpoints" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET"
endpoint_guid=$(curl -k -X GET "https://localhost:5443/api/v1/endpoints" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET" | jq -r '.[] | select(.name=="Potato").guid')
# login to endpoint
curl -k -X POST "https://localhost:5443/api/v1/tokens" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET" -F "cnsi_guid=$endpoint_guid" -F "system_shared=false" -F "connect_type=creds" -F "username=$USERNAME" -F "password=$PASSWORD"
# rename endpoint
curl -k -X POST "https://localhost:5443/api/v1/endpoints/$endpoint_guid" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET" -F "name=Endpoint McEndpointface"
# log out from endpoint
curl -k -X DELETE "https://localhost:5443/api/v1/tokens/$endpoint_guid" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET"
# delete endpoint
curl -k -X DELETE "https://localhost:5443/api/v1/endpoints/$endpoint_guid" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET" |
3ae4726
to
9babf6a
Compare
curl commands with JSON bodies: export API_SECRET='replaceme'
export USERNAME='replaceme'
export PASSWORD='replaceme'
export API_ENDPOINT='https://api.cap.explore.suse.dev/'
# add endpoint
curl -k -X POST "https://localhost:5443/api/v1/endpoints" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET" -H "Content-Type: application/json" -d "{\"endpoint_type\":\"cf\",\"cnsi_name\":\"Potato\",\"api_endpoint\":\"$API_ENDPOINT\"}"
# list endpoints
curl -k -X GET "https://localhost:5443/api/v1/endpoints" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET"
endpoint_guid=$(curl -k -X GET "https://localhost:5443/api/v1/endpoints" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET" | jq -r '.[] | select(.name=="Potato").guid')
# login to endpoint
curl -k -X POST "https://localhost:5443/api/v1/tokens" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET" -H "Content-Type: application/json" -d "{\"cnsi_guid\":\"$endpoint_guid\",\"system_shared\":\"false\",\"connect_type\":\"creds\",\"username\":\"$USERNAME\",\"password\":\"$PASSWORD\"}"
# rename endpoint
curl -k -X POST "https://localhost:5443/api/v1/endpoints/$endpoint_guid" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET" -H "Content-Type: application/json" -d "{\"name\": \"Endpoint McEndpointface\"}"
# log out from endpoint
curl -k -X DELETE "https://localhost:5443/api/v1/tokens/$endpoint_guid" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET"
# delete endpoint
curl -k -X DELETE "https://localhost:5443/api/v1/endpoints/$endpoint_guid" -H "accept: application/json" -H "Authentication: Bearer $API_SECRET" |
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.
LGTM
Description
A subset of API endpoints moved under
/api/v1
and documented with Swagger.Motivation and Context
#4532
How Has This Been Tested?
Tested manually & with existing test suite.
Types of changes
Checklist: