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

Add API version to the http request header #695

Open
vsedmik opened this issue Jan 17, 2020 · 2 comments
Open

Add API version to the http request header #695

vsedmik opened this issue Jan 17, 2020 · 2 comments

Comments

@vsedmik
Copy link
Contributor

vsedmik commented Jan 17, 2020

According to the documantation here [1] the http request header should contain version reference "Accept:application/json,version=2" for API v2, which is Satellite6 default. AFAIK this is missing in nailgun, potentially making some endpoints unreachable.

[1] https://access.redhat.com/documentation/en-us/red_hat_satellite/6.6/html/api_guide/chap-red_hat_satellite-api_guide-api_reference#sect-API_Guide-Understanding_the_API_Syntax

@mirekdlugosz
Copy link
Contributor

There are at least three ways to force specific version of API:

  1. Request header, as noted in report
  2. Include API version in request body
  3. Send request to endpoint that has API version in URL

We use method no. 3, but as it turns out - not exhaustively. There are couple of endpoints that define unversioned url:

$ ack 'api_path.*api/(?!v2)'
nailgun/entities.py
486:            'api_path': 'api/compliance/arf_reports',
678:            'api_path': 'katello/api/capsules',
1544:            'api_path': 'api/job_invocations',
3076:            'api_path': 'foreman_tasks/api/tasks',
5491:            'api_path': '/katello/api/products/bulk',
5914:            'api_path': 'foreman_tasks/api/recurring_logics',
7938:            'api_path': 'api/compliance/scap_contents',

nailgun/entity_mixins.py
341:    ...         self._meta = {'api_path': 'api/users'}

Also, having each entity specifying it's own URL was maybe not the best decision we ever made.

It's worth pointing out that APIv2 has been default for years and APIv1 is not even available in current versions of Satellite.


@vsedmik if you want to tackle this, I would suggest adding version to url of endpoints listed above (that will require confirmation that versioned URLs are indeed valid). If we are to add header with version, we should first think harder on how we are going to handle API versions generally.

@vsedmik
Copy link
Contributor Author

vsedmik commented Jan 31, 2020

@mirekdlugosz Ok, thank you for clarificaton. If version specification in url works the same as in header I'm ok with that.
I looked into the /apidoc and there are some endpoints with and without v2 too, perhaps this may be the reason why it's done this way in Nailgun.

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

No branches or pull requests

2 participants