<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 23, 2017 at 11:43 AM, Brian Bouterse <span dir="ltr"><<a href="mailto:bbouters@redhat.com" target="_blank">bbouters@redhat.com</a>></span> wrote:<br><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">There is a lot of good discussion here. See inline about the motivation to not add additional fields to the task model.<br><div><div><div class="gmail_extra"><br><div class="gmail_quote"><span class="gmail-">On Mon, Oct 23, 2017 at 10:55 AM, Michael Hrivnak <span dir="ltr"><<a href="mailto:mhrivnak@redhat.com" target="_blank">mhrivnak@redhat.com</a>></span> wrote:<br><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">Unless the publication can be created before the response is returned, the response code will need to still be 202.<div><br></div><div>As for the path, either way seems workable, although I have two hesitations about POSTing to publications/.</div><div><br></div><div>1) Normally in REST when a user creates a resource via POST to a collection endpoint, they are expected to provide a representation of the new resource, even if it is only partial. In the case of initiating a publish task, we do not want the user to provide any part of the new publication's state. We only want the user to optionally provide a bit of information about *how* to create a new publication. Should the publication be incremental or not? Which repo version should be published? etc. The difference may seem subtle, but I think it's important.</div><div><br></div><div>2) The act of creating a publication may also change state of other resources, and not only subordinate resources such as a publication artifact. For example, if there is a Distribution with auto_update set to True, its state will be changed by a publish task. That could be seen as an unexpected side effect when merely POSTing to a publications/ endpoint. When an operation affects state across multiple resources and resource types, that's usually a good time to use a "controller" type endpoint that is specific to the operation.<br><div><br></div><div>Our asynchronous tasks will often need to create one or more resources. A publish task creates a publication. An upload-related task may create one or more content units. A sync/associate/unassociate task will create a new repository version. New resources are the output of those tasks. However each of those tasks will sometimes not create any resources, such as when an equivalent resource already exists. Creating resources is a common characteristic of tasks, so it would make sense to report that in a standard part of the task status.</div><div><br></div><div>A task status should not include an exhaustive list of every resource created. For example, a publish task should not include a reference to every metadata artifact it made. It would be sufficient to include a reference to the publication, the task's primary output, which then can be used to reference subordinate resources.</div><div><br></div><div>On a task status representation, this could be included in a field called "created_resources", "output", "return_value", or similar.</div><div><br></div><div>Thoughts on that idea?</div></div></div></blockquote><div><br></div></span><div>This is similar to what we did on Pulp2 where task status field semantics are different task by task. In other words this field's usage and data differs depending on the task type making it like a mutating field. This was a real challenge for users in Pulp2 because the data semantics and format are all different which prevents users from handling that field generically. Currently all fields on a task status are semantically concrete. I think we should continue to do that.</div></div></div></div></div></div></blockquote><div><br></div><div> I completely agree. A key aspect of REST, which we have not achieved with Pulp 2, is depending on media types to express what each returned link references. As an example, HAL is one common way to do this:</div><div><br></div><div><a href="http://stateless.co/hal_specification.html">http://stateless.co/hal_specification.html</a><br></div><div><br></div><div>In any scenario where we included links to created resources, I would expect those links to come with enough information for a client to understand what type of resource the link references. That's a standard REST practice that would be especially useful in this scenario to ensure that task status representations are semantically concrete.</div><div><br></div></div>-- <br><div class="gmail_signature"><div dir="ltr"><p style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px;padding:0px"><span style="margin:0px;padding:0px">Michael</span> <span style="margin:0px;padding:0px">Hrivnak</span></p><p style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px;padding:0px"></p><span style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px;padding:0px"><span style="margin:0px;padding:0px">Principal Software Engineer</span><span style="margin:0px;padding:0px">, <span style="margin:0px;padding:0px">RHCE</span></span> </span><span style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px"></span><br style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px;padding:0px"><p style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px;padding:0px">Red Hat</p></div></div>
</div></div>