Task #2823
closedIn the REST API, nest importers and publishers under the repositories path
100%
Description
Recent work has concluded that we can use drf-nested-routers to have nested paths in Pulp 3.
https://github.com/alanjds/drf-nested-routers/
This task is to:
- introduce a dependency on the above library
- nest importers and publishers under the path for individual repositories as shown below
- rework the flow [0] of viewsets being registered to the DRF router, given that there will now be multiple routers
Since we need to support nesting with the master/detail approach, importers and publishers make a natural starting point for nesting. Paths will look like this:
/api/v3/repositories/
/api/v3/repositories/<repo_name>/
/api/v3/repositories/<repo_name>/importers/<type>/
/api/v3/repositories/<repo_name>/importers/<type>/<importer_name>/
As an example, if you had a repo with name "r1" and a file importer with name "i1", and you were to
GET http://192.168.121.135:8000/api/v3/repositories/r1/
you would see
{
"_href": "http://192.168.121.135:8000/api/v3/repositories/r1/",
"description": "",
"notes": {},
"scratchpad": {},
"last_content_added": null,
"last_content_removed": null,
"importers": [
"http://192.168.121.135:8000/api/v3/repositories/r1/importers/file/i1/"
],
"publishers": [],
"content": "http://192.168.121.135:8000/api/v3/repositories/r1/content/"
}
Or if you
GET http://192.168.121.135:8000/api/v3/repositories/r1/importers/file/
you would see all importers of type file:
[
{
"_href": "http://192.168.121.135:8000/api/v3/repositories/r1/importers/file/i1/",
"type": "file",
"name": "i1",
"last_updated": "2017-06-08T03:00:53.361829Z",
"feed_url": "",
"validate": true,
"ssl_validation": true,
"proxy_url": "",
"download_policy": "",
"last_sync": null,
"repository": "http://192.168.121.135:8000/api/v3/repositories/r1/"
}
]
[0] https://github.com/pulp/pulp/blob/64741860/platform/pulpcore/app/urls.py#L20
Updated by amacdona@redhat.com over 7 years ago
I would also like to see `/v3/repositories/importers/`, though I am not sure if it would be appropriate to add here or not.
This should do something like list the <types>, or links to them.
Updated by amacdona@redhat.com over 7 years ago
Are there any other URLs that might need to use nesting? It might be worth listing them before we get started on this. In particular, I am wondering if there are nested URLs that will not be nested under repositories.
Updated by mhrivnak over 7 years ago
I agree the "importers/" endpoint would be nice. The master-detail pattern doesn't make that easy, but maybe we could figure a way to add it. That said, I don't think it's required.
If we did have it, I'd suggest it should return representations of each importer regardless of type.
There will be other nested paths. Here are ones I can think of as likely possibilities. The consumer ones of course are contingent on what our applicability plan will be, but I think it's a reasonable bet that we'll continue doing it as part of Pulp.
/api/v3/repositories/<repo_name>/versions/
/api/v3/repositories/<repo_name>/versions/<version_number>/content/
/api/v3/consumers/<consumer_name>/bindings/
/api/v3/content/<content_type>/<identifier>/catalog_entries/
/api/v3/tasks/<task_id>/progress_reports/
Updated by amacdona@redhat.com over 7 years ago
For these:
/api/v3/repositories/<repo_name>/versions/
/api/v3/consumers/<consumer_name>/bindings/
/api/v3/tasks/<task_id>/progress_reports/
We don't really need true "nested URLs". These can all be implemented directly on the ViewSet as a detail route:
https://github.com/pulp/pulp/blob/3.0-dev/platform/pulpcore/app/viewsets/repository.py#L33
Updated by mhrivnak over 7 years ago
Good point. However, in any case where we want more than just a read-only list of resources, then we need more than just the detail route. If you want to get a specific resource in the collection, add one, remove one, modify one, or otherwise take action on one, then we need real nesting. I think that is the case for most or all of these nested collections.
Updated by mhrivnak over 7 years ago
- Subject changed from [WIP] in REST API, nest importers and publishers under repositories path to In the REST API, nest importers and publishers under the repositories path
Updated by amacdona@redhat.com over 7 years ago
- Groomed changed from No to Yes
- Sprint Candidate changed from No to Yes
Updated by mhrivnak over 7 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to mhrivnak
Updated by mhrivnak over 7 years ago
- Status changed from ASSIGNED to POST
Added by mhrivnak over 7 years ago
Added by mhrivnak over 7 years ago
Revision ca8f6390 | View on GitHub
Nests importer and publisher REST API paths under repositories
Updated by mhrivnak over 7 years ago
- Status changed from POST to MODIFIED
- % Done changed from 0 to 100
Applied in changeset pulp|ca8f6390daf553efe43e9e9a6ba05b84ecd68213.
Updated by bmbouter almost 5 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Nests importer and publisher REST API paths under repositories
https://pulp.plan.io/issues/2823 closes #2823