<div dir="ltr">After some discussions, we’ve decided to change course and not support IDs in our API. Instead, we’ll be relying on hrefs to reference objects. <div><br></div><div>Below is the new plan. Feedback as always is welcome. Please respond by the end of next week (August 31, 2018).<div><br><div># Summary<br><div><br></div><div><div>We will use hrefs to refer to resources. This is how the code currently works today.</div><div><br></div><div># Response Data</div><div><br></div><div>Use relative URIs. e.g. <a href="https://example.com/pulp/api/v3/repositories/file/1/">https://example.com/pulp/api/v3/repositories/file/1/</a> -> /pulp/api/v3/repositories/file/1/</div><div><br></div><div># Submitting Data (both work)</div><div><br></div><div>Preferred:</div><div><br></div><div>POST '<a href="https://example.com/pulp/api/v3/remote/file/4/sync/">https://example.com/pulp/api/v3/remote/file/4/sync/</a>' repository='/pulp/api/v3/repositories/file/1/‘<br></div><div><br></div><div>This also works too:</div><div><br></div><div>POST '<a href="https://example.com/pulp/api/v3/remote/file/4/sync/">https://example.com/pulp/api/v3/remote/file/4/sync/</a>' repository='<a href="https://example.com/pulp/api/v3/repositories/file/1/">https://example.com/pulp/api/v3/repositories/file/1/</a>'</div><div><br></div><div># Binding example</div><div><br></div><div><a href="https://github.com/dkliban/pulp3-python-bindings/blob/href-as-identifier/swagger_client/api/content_api.py#L234">https://github.com/dkliban/pulp3-python-bindings/blob/href-as-identifier/swagger_client/api/content_api.py#L234</a></div><div><br></div><div># Reasons</div><div><br></div><div>(a) it's a simpler user experience. They only store 1 string, not json hashes including the type and possible multiple pks</div><div>(b) resources like repositoryVersion don’t have to be un-nested</div><div>(c) simpler, don't have to support both ID and href</div><div>(d) it already works</div><div><br></div><div># Next Steps</div><div><br></div><div>* enable the bindings by merging <a href="https://github.com/pulp/pulp/pull/3561">https://github.com/pulp/pulp/pull/3561</a></div><div>* Need to switch full hrefs currently returned for relative href's to be returned. i.e. <a href="https://example.com/pulp/api/v3/repositories/file/1/">https://example.com/pulp/api/v3/repositories/file/1/</a>   -> /pulp/api/v3/repositories/file/1/</div><div>  - Issue: <a href="https://pulp.plan.io/issues/3850">https://pulp.plan.io/issues/3850</a></div><div><div dir="ltr" class="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></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 8, 2018 at 12:22 PM David Davis <<a href="mailto:daviddavis@redhat.com">daviddavis@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Yea, the names here are in terms of the names we use today and are subject to the outcome of the field naming thread.<br clear="all"><div><div dir="ltr" class="m_6568508160981025729m_-6513711847925840592m_-7084889148794164446gmail_signature" 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><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 8, 2018 at 12:17 PM Daniel Alley <<a href="mailto:dalley@redhat.com" target="_blank">dalley@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div> As per the other discussion thread, I assume the names will actually be _id, _type, _href?</div><div><br></div><div class="gmail_extra">Errata have both "id" and "type" fields, so if we're going to attempt to keep the Pulp metadata field names out of the way of Content field names, we need to do it for all of them.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_quote">On Wed, Aug 8, 2018 at 12:02 PM, David Davis <span dir="ltr"><<a href="mailto:daviddavis@redhat.com" target="_blank">daviddavis@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>After recent meetings with stakeholders, we've arrived at a solution on how to handle ids and hrefs in the Pulp 3 API. The plan is to stop accepting hrefs for fields to instead rely solely on IDs. Hrefs will still be displayed in the API as a convenience to users but will not be accepted for fields in POST/PUT requests.</div><div><br></div><div>In order to support polymorphic fields, we'll also be adding a 'type' field that will be returned for all objects that will contain the package name and resource name (e.g. pulp_file.FileContent). This will allow these objects to be posted to polymorphic fields like add_content_units/remove_content_units (see below).</div><div><br></div><div>Lastly, we also propose un-nesting the repository versions endpont and making it a top-level resources. Filtering of repository versions associated with a specific repo will be handled by repo filters, e.g. /pulp/api/v3/repository_versions/?repository=3</div><div><br></div><div><br></div><div>RETURNING DATA</div><div><br></div><div>Return for all objects:</div><div>- id</div><div>- _href</div><div>- type</div><div><br></div><div>e.g. {'id': 4, 'type': 'pulp_file.FileContent', '_href': '<a href="http://localhost:8000/pulp/api/v3/content/file/files/4/" target="_blank">http://localhost:8000/pulp/api/v3/content/file/files/4/</a>'}</div><div><br></div><div>This includes polymorphic fields (e.g. created_resource on TaskStatus)</div><div><br></div><div><br></div><div>POSTING DATA</div><div><br></div><div>Submitting data in general will use id only (no hrefs). For example:</div><div><br></div><div>http <a href="http://localhost:8000/pulp/api/v3/remotes/file/3/sync" target="_blank">http://localhost:8000/pulp/api/v3/remotes/file/3/sync</a> repository=3</div><div><br></div><div>Submitting polymorphic fields can be handled in the following way: </div><div><br></div><div>add_content_units=[</div><div>    {'id': 4, 'type': 'pulp_file.FileContent', '_href': '<a href="http://localhost:8000/pulp/api/v3/content/file/files/4/'" target="_blank">http://localhost:8000/pulp/api/v3/content/file/files/4/'</a>},</div><div>    {'id': 4, 'type': 'pulp_python.PythonContent', '_href': '<a href="http://localhost:8000/pulp/api/v3/content/python/p/4/" target="_blank">http://localhost:8000/pulp/api/v3/content/python/p/4/</a>'}</div><div>]</div><div><br></div><div>Note: the only fields that are inspected are id and type. the rest are ignored. This simply allows users to pass back the data they receive from the content endpoint.</div><div><br></div><div><br></div><div>We're holding off on proceeding until August 15th to allow time for comment. Please respond with any concerns or feedback before then. </div><div><br></div></div>
<br>_______________________________________________<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>
<br></blockquote></div><br></div></div>
</blockquote></div>
</blockquote></div>