Story #4279
Namespace plugin endpoints for viewsets of master/detail models.
100%
Description
At the moment plugins specify the plugin name or some identifier to namespace their endpoints manually as a part of endpoint_name
when they write their viewsets,
e.g. for PackageViewSet
: endpoint_name = 'rpm/packages'
, for UpdateRecordViewSet
: endpoint_name = 'rpm/errata'
, etc.
Currently it's mostly a problem for ContentViewSets and less of a problem for Remotes, Publishers, etc, since it's common for a single plugin to support multiple content types.
The suggestion is to prepend endpoint_name of a viewset of any detail model automagically with a plugin name which is defined as a Django app label.
For the plugins it is recommended to drop the 'pulp_' part of their Django app label.
E.g.: For PackageViewSet
: endpoint_name
will be 'packages'
, and the Django label will change "pulp_rpm" -> "rpm", so for there is no change in content endpoints:
/api/v3/content/rpm/packages/
Remotes'/Publishers'/other "detail" endpoints will change this way (first "rpm" is a Django label, second "rpm" is endpoint_name
defined on a viewset):
/api/v3/remotes/rpm/ --> /api/v3/content/remotes/rpm/rpm/
/api/v3/publishers/rpm/ --> /api/v3/content/publishers/rpm/rpm/
Associated revisions
Revision 7654d5d2
View on GitHub
Namespace plugin endpoints with Django app label
closes #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp_file/pull/157
Revision 39f572db
View on GitHub
Change Django app label and adjust endpoint_name
s
re #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp/pull/3836
Revision 39f572db
View on GitHub
Change Django app label and adjust endpoint_name
s
re #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp/pull/3836
Revision 39f572db
View on GitHub
Change Django app label and adjust endpoint_name
s
re #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp/pull/3836
Revision 39f572db
View on GitHub
Change Django app label and adjust endpoint_name
s
re #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp/pull/3836
Revision 118f79ed
View on GitHub
Fix plugins installation due to the app label change
re #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp_file/pull/157
Revision f36b1a8b
View on GitHub
Change Django app label and adjust endpoint_name
s
re #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp/pull/3836
Revision ba6c0a48
View on GitHub
Change Django app label
re #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp/pull/3836
Revision 2dbab818
View on GitHub
Change Django app label and adjust endpoint_name
s
re #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp/pull/3836
Revision f4ad91dc
View on GitHub
Change Django app label and adjust endpoint_name
s
re #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp/pull/3836
Revision f67776df
View on GitHub
Update app_label for plugins
re #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp_file/pull/157
Revision f67776df
View on GitHub
Update app_label for plugins
re #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp_file/pull/157
Revision 7423470a
View on GitHub
Change Django app label and adjust endpoint_name
s
re #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp/pull/3836
History
#1
Updated by ttereshc about 2 years ago
The example of the change which can be added to any "master" viewset.
diff --git a/pulpcore/app/viewsets/content.py b/pulpcore/app/viewsets/content.py
index c42232853..c3d191c57 100644
--- a/pulpcore/app/viewsets/content.py
+++ b/pulpcore/app/viewsets/content.py
@@ -96,6 +96,17 @@ class ContentViewSet(NamedModelViewSet,
serializer_class = ContentSerializer
filterset_class = ContentFilter
+ def __init_subclass__(cls, **kwargs):
+ """
+ For subclasses (plugin viewsets) add a plugin name to the endpoint name.
+ """
+ super().__init_subclass__(**kwargs)
+ app_label = cls.queryset.model._meta.app_label
+ if hasattr(cls, 'endpoint_name'):
+ cls.endpoint_name = '{app_label}/{plugin_endpoint_name}'.format(
+ app_label=app_label,
+ plugin_endpoint_name=cls.endpoint_name)
+
@transaction.atomic
def create(self, request):
"""
#2
Updated by CodeHeeler about 2 years ago
- Tracker changed from Issue to Story
- % Done set to 0
#3
Updated by ttereshc about 2 years ago
- Description updated (diff)
#4
Updated by ttereshc about 2 years ago
Discussion of the issue on the pulp-dev mailing list: https://www.redhat.com/archives/pulp-dev/2019-January/msg00002.html
#5
Updated by ttereshc about 2 years ago
The result of the discussion https://www.redhat.com/archives/pulp-dev/2019-January/msg00045.html
#6
Updated by ttereshc about 2 years ago
- Checklist item Prepend all master/detail related endpoints with a Django app label added
- Checklist item Remove 'pulp_' prefix in Django app labels for all the plugins which core team is responsible for added
- Checklist item Update plugin writer's guidelines to reflect how plugin's Django app label is used in the endpoints added
- Checklist item E-mail pulp-dev list to reach plugin writers with a suggestion to drop 'pulp_' in their Django app label added
- Description updated (diff)
#7
Updated by ttereshc about 2 years ago
- Description updated (diff)
#8
Updated by ttereshc about 2 years ago
- Description updated (diff)
#9
Updated by daviddavis about 2 years ago
- Groomed changed from No to Yes
- Sprint Candidate changed from No to Yes
#10
Updated by ttereshc about 2 years ago
- Sprint set to Sprint 47
#11
Updated by ttereshc about 2 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to ttereshc
#12
Updated by ttereshc about 2 years ago
- Checklist item Prepend all master/detail related endpoints with a Django app label set to Done
- Checklist item Remove 'pulp_' prefix in Django app labels for all the plugins which core team is responsible for set to Done
- Status changed from ASSIGNED to POST
https://github.com/pulp/pulp/pull/3836/
https://github.com/pulp/pulp_file/pull/157/
https://github.com/pulp/pulp_rpm/pull/1257/
https://github.com/pulp/ansible-pulp3/pull/67
https://github.com/pulp/devel/pull/210
https://github.com/pulp/pulp_docker/pull/302
https://github.com/pulp/pulp_python/pull/217
https://github.com/pulp/pulp_ansible/pull/76
https://github.com/pulp/plugin_template/pull/28
#13
Updated by rchan about 2 years ago
- Sprint changed from Sprint 47 to Sprint 48
#14
Updated by ttereshc almost 2 years ago
- Status changed from POST to MODIFIED
- % Done changed from 0 to 100
Applied in changeset pulp|7654d5d2824f51f580e536ba4b5e931baf9f49b5.
#15
Updated by ttereshc almost 2 years ago
- Status changed from MODIFIED to POST
#16
Updated by ttereshc almost 2 years ago
- Status changed from POST to MODIFIED
#17
Updated by ttereshc almost 2 years ago
- Checklist item E-mail pulp-dev list to reach plugin writers with a suggestion to drop 'pulp_' in their Django app label set to Done
#18
Updated by daviddavis almost 2 years ago
- Sprint/Milestone set to 3.0.0
#19
Updated by bmbouter almost 2 years ago
- Tags deleted (
Pulp 3, Pulp 3 RC Blocker)
#20
Updated by bmbouter about 1 year ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Please register to edit this issue
Namespace plugin endpoints with Django app label
closes #4279 https://pulp.plan.io/issues/4279
Required PR: https://github.com/pulp/pulp_file/pull/157