Open vsedmik opened 4 years ago
There are at least three ways to force specific version of API:
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.
@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.
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