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

Low Level Client functions should accept fully qualified endpoints #44

Open
brianjwilson opened this issue Aug 13, 2019 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@brianjwilson
Copy link

These functions expect a relative path to the resource:

client.get("<path>")
client.delete("<path>")
client.put("<path>", <data>)
client.post("<path>", <data>)

In my initial tests I was passing in a fully qualified URL and getting back 404, but it was unclear why. Reviewing the docs and then passing in only the path element got the right result, but it should be possible to pass either, especially if you improve the API to provide links to the resources (and not just the bare ID's) in the future. This would let a client just nab the links and come right back in through the library without having to assemble the paths, etc.

@garethr
Copy link
Collaborator

garethr commented Aug 14, 2019

Thanks for reporting. Doing more validation on the argument would help here, at least to provide a better error message.

The rationale for not passing the full URL is that the client can connect to different Snyk instances, and that's set at the client level which stores the authorisation details. For example:

client = snyk.SnykClient("<your-api-token>", "https://mysnyk.example.com/v1/")

Allowing for passing the full URL into the low level API risks trying to use the client from one Snyk instance with a different one. This is a case we could validate for as well in those methods (ie. if the two URLs don't match) which would allow for supporting this.

If the Snyk API supports more hypermedia functionality in the future it should definitely be a goal of this client to better support that.

@garethr garethr added the enhancement New feature or request label Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants