<div dir="ltr">No, it's more complicated than that. There's a bit of magic for Master/Detail model endpoints[0] where the NamedModelViewSet tries to form the endpoint by looking up the master_endpoint, app_label, and endpoint_name (and combining them). In the case of distribution_trees, there is no master viewset so the master_endpoint becomes 'distribution_trees' and thus the url we end up with is /pulp/api/v3/distribution_trees/rpm/distribution_trees/. If we used 'content', it would just be /pulp/api/v3/distribution_trees/rpm/content/.<div><br></div><div>This is a problem we should probably fix regardless of how we handle Tanya's problem. To restate the problem: it's impossible (or very hard) to create your own endpoint for a Detail model because the code automatically tries to namespace your endpoint for you. I can file an issue if others agree.<br><div><br></div><div>[0] <a href="https://github.com/pulp/pulpcore/blob/5bd0f31604de3079c8bb1b710155d7c6e94d7425/pulpcore/app/viewsets/base.py#L185-L216" target="_blank">https://github.com/pulp/pulpcore/blob/5bd0f31604de3079c8bb1b710155d7c6e94d7425/pulpcore/app/viewsets/base.py#L185-L216</a><br clear="all"><div><div dir="ltr" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><br></div><div>David<br></div></div></div></div></div></div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 2, 2019 at 12:52 PM Brian Bouterse <<a href="mailto:bmbouter@redhat.com" target="_blank">bmbouter@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 2, 2019 at 12:44 PM David Davis <<a href="mailto:daviddavis@redhat.com" target="_blank">daviddavis@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 2, 2019 at 12:37 PM Brian Bouterse <<a href="mailto:bmbouter@redhat.com" target="_blank">bmbouter@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 2, 2019 at 11:03 AM Tatiana Tereshchenko <<a href="mailto:ttereshc@redhat.com" target="_blank">ttereshc@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thank you! Good idea to have an additional one.</div></blockquote><div>I agree</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I'm on the fence between ReadOnly and just Generic one without any mixins. <br></div></div></blockquote><div>I see having the ReadOnlyContentViewset as overall being slightly better than a Generic option for plugin writers for two reasons.</div><div><br></div><div>1) the majority of cases (if not all) will want both list and get() mixins so we're handling the common case with this.<br></div><div>2) In the event a plugin writer needs to not have list and/or get(), they could could use NamedModelViewset directly still. Is this accurate?<br></div></div></div></blockquote><div><br></div><div><div>Per Tanya's original email it sounds like it was hard/impossible to roll a viewset at /pulp/api/v3/content/rpm/distribution_trees/.</div></div></div></div></blockquote><div><br></div><div>Oh I see, but isn't that an outcome of `endpoint_name <span>=</span> <span><span>'</span>distribution_trees<span>'` <a href="https://github.com/pulp/pulp_rpm/blob/master/pulp_rpm/app/viewsets.py#L256" target="_blank">here</a>? What happens if that becomes `endpoint_name <span>=</span> <span><span>'</span>content<span>'`. I believe the NamedModelViewset would translate that into the url /pulp/api/v3/content/rpm/distribution_trees/ where the `distribution_trees` part comes fro the classname. I haven't looking into it in a while though, so let me know if I'm still not getting it right.</span></span></span></span></div><div><span><span><span><span><br></span></span></span></span></div><div><span><span><span><span>In the event it's not easy for the plugin writer to be in control of that then I would be in favor of GenericContentViewset.</span></span></span></span></div><div><span><span><span><span><br></span></span></span></span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div></div><div><br></div><div>Just to write it out for clarity I imagine it would be:         ReadOnlyContentViewset(NamedModelViewset, mixins.RetrieveModelMixin, mixins.ListModelMixin)</div><div><br></div><div>What do you think?<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Any other opinions/suggestions?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 2, 2019 at 4:35 PM Matthias Dellweg <<a href="mailto:dellweg@atix.de" target="_blank">dellweg@atix.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I would do a variation of 1. :<br>
Provide a ReadonlyContentViewSet with only GET mixed in and leave the<br>
'standard' ContentViewset as is.<br>
Cheers, Matthias<br>
<br>
On Wed, 2 Oct 2019 16:16:14 +0200<br>
Tatiana Tereshchenko <<a href="mailto:ttereshc@redhat.com" target="_blank">ttereshc@redhat.com</a>> wrote:<br>
<br>
> Current implementation of ContentViewset<br>
> <<a href="https://github.com/pulp/pulpcore/blob/master/pulpcore/app/viewsets/content.py#L98-L102" rel="noreferrer" target="_blank">https://github.com/pulp/pulpcore/blob/master/pulpcore/app/viewsets/content.py#L98-L102</a>><br>
> includes<br>
> mixins for create (POST) and retrieve/list (GET).<br>
> In case a plugin doesn't need to support POST for a content endpoint,<br>
> a plugin writer compiles a viewset from the mixins they need, e.g.<br>
> distribution trees and custom metadata<br>
> <<a href="https://github.com/pulp/pulp_rpm/blob/master/pulp_rpm/app/viewsets.py#L233-L258" rel="noreferrer" target="_blank">https://github.com/pulp/pulp_rpm/blob/master/pulp_rpm/app/viewsets.py#L233-L258</a>><br>
> (same<br>
> use case is expected for modularity endpoints)<br>
> This leads to the inconsistent REST API.<br>
> <br>
> # ContentViewset is used<br>
> /pulp/api/v3/content/rpm/advisories/<br>
> <br>
> # custom plugin content viewset<br>
> /pulp/api/v3/distribution_trees/rpm/distribution_trees/<br>
> <br>
> Possible solutions:<br>
> 1. Make ContentViewset more generic (no mixins, or only GET ones?)<br>
> and let plugins include any mixins they need.<br>
> This option might be painful to switch to for plugin writers, because<br>
> every plugin will be affected and will need to make this change.<br>
> At the same time probably not many plugins support upload for every<br>
> content type, so in many cases the POST is broken/not used anyway.<br>
> <br>
> 2. Disable POST at the plugin level in some other way.<br>
> I'm not sure if there is any native option to disable it.<br>
> Hacky way is to override `create` method which will return<br>
> appropriate HTTP error that POST is not supported.<br>
> <br>
> 3. Make plugin writers manually define a proper endpoint name.<br>
> Apart from not being reliable, I'm not sure how to do it because of<br>
> how we tweak endpoint generation.<br>
> Notice the distribution trees example ^, "distribution_trees" is used<br>
> twice in the endpoint.<br>
> <br>
> 4. Any other solutions? Easy ones which I missed?<br>
> <br>
> Thank you,<br>
> Tanya<br>
</blockquote></div>
_______________________________________________<br>
Pulp-dev mailing list<br>
<a href="mailto:Pulp-dev@redhat.com" target="_blank">Pulp-dev@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/pulp-dev</a><br>
</blockquote></div></div>
_______________________________________________<br>
Pulp-dev mailing list<br>
<a href="mailto:Pulp-dev@redhat.com" target="_blank">Pulp-dev@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/pulp-dev</a><br>
</blockquote></div>
</div>
</blockquote></div></div>
</blockquote></div>