Project

Profile

Help

Task #2823

In the REST API, nest importers and publishers under the repositories path

Added by mhrivnak over 2 years ago. Updated 6 months ago.

Status:
MODIFIED
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
Start date:
Due date:
% Done:

100%

Platform Release:
Blocks Release:
Backwards Incompatible:
No
Groomed:
Yes
Sprint Candidate:
Yes
Tags:
QA Contact:
Complexity:
Smash Test:
Verified:
No
Verification Required:
No
Sprint:
Sprint 22

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

Associated revisions

Revision ca8f6390 View on GitHub
Added by mhrivnak over 2 years ago

Nests importer and publisher REST API paths under repositories

https://pulp.plan.io/issues/2823
closes #2823

Revision ca8f6390 View on GitHub
Added by mhrivnak over 2 years ago

Nests importer and publisher REST API paths under repositories

https://pulp.plan.io/issues/2823
closes #2823

Revision ca8f6390 View on GitHub
Added by mhrivnak over 2 years ago

Nests importer and publisher REST API paths under repositories

https://pulp.plan.io/issues/2823
closes #2823

History

#1 Updated by mhrivnak over 2 years ago

  • Description updated (diff)

#2 Updated by amacdona@redhat.com over 2 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.

#3 Updated by amacdona@redhat.com over 2 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.

#4 Updated by mhrivnak over 2 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/

#5 Updated by amacdona@redhat.com over 2 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

#6 Updated by mhrivnak over 2 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.

#7 Updated by mhrivnak over 2 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

#8 Updated by amacdona@redhat.com over 2 years ago

  • Groomed changed from No to Yes
  • Sprint Candidate changed from No to Yes

#9 Updated by mhrivnak over 2 years ago

  • Sprint/Milestone set to 41

#10 Updated by mhrivnak over 2 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to mhrivnak

#11 Updated by mhrivnak over 2 years ago

  • Description updated (diff)

#12 Updated by mhrivnak over 2 years ago

  • Status changed from ASSIGNED to POST

#13 Updated by mhrivnak over 2 years ago

  • Status changed from POST to MODIFIED
  • % Done changed from 0 to 100

#14 Updated by bmbouter over 1 year ago

  • Sprint set to Sprint 22

#15 Updated by bmbouter over 1 year ago

  • Sprint/Milestone deleted (41)

#16 Updated by daviddavis 6 months ago

  • Sprint/Milestone set to 3.0

#17 Updated by bmbouter 6 months ago

  • Tags deleted (Pulp 3)

Please register to edit this issue

Also available in: Atom PDF