Re: Link relation types for non-GET links

Klaus Hartke <hartke@tzi.org> Sat, 15 August 2015 12:22 UTC

Return-Path: <hartke@tzi.org>
X-Original-To: link-relations@ietfa.amsl.com
Delivered-To: link-relations@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id DE4081A87CA for <link-relations@ietfa.amsl.com>; Sat, 15 Aug 2015 05:22:41 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.928
X-Spam-Level:
X-Spam-Status: No, score=-0.928 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, FM_FORGED_GMAIL=0.622, HELO_EQ_DE=0.35] autolearn=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Bf1ToZbK3dCG for <link-relations@ietfa.amsl.com>; Sat, 15 Aug 2015 05:22:40 -0700 (PDT)
Received: from mailhost.informatik.uni-bremen.de (mailhost.informatik.uni-bremen.de [IPv6:2001:638:708:30c9::12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 4B01E1A87BB for <link-relations@ietf.org>; Sat, 15 Aug 2015 05:22:40 -0700 (PDT)
X-Virus-Scanned: amavisd-new at informatik.uni-bremen.de
Received: from submithost.informatik.uni-bremen.de (submithost.informatik.uni-bremen.de [IPv6:2001:638:708:30c9::b]) by mailhost.informatik.uni-bremen.de (8.14.5/8.14.5) with ESMTP id t7FCMaUS024919 for <link-relations@ietf.org>; Sat, 15 Aug 2015 14:22:36 +0200 (CEST)
Received: from mail-ig0-f171.google.com (mail-ig0-f171.google.com [209.85.213.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by submithost.informatik.uni-bremen.de (Postfix) with ESMTPSA id 3mtgkh45mKz4vk0 for <link-relations@ietf.org>; Sat, 15 Aug 2015 14:22:36 +0200 (CEST)
Received: by igfj19 with SMTP id j19so29079789igf.0 for <link-relations@ietf.org>; Sat, 15 Aug 2015 05:22:35 -0700 (PDT)
X-Received: by 10.50.25.226 with SMTP id f2mr7967045igg.87.1439641355276; Sat, 15 Aug 2015 05:22:35 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.79.39.210 with HTTP; Sat, 15 Aug 2015 05:21:55 -0700 (PDT)
In-Reply-To: <55CD15FF.2060805@berkeley.edu>
References: <CAAzbHvb==Sn_4UUFHKs3H9GYbEfiX=TUjv4FSmNi9R4NEB+DvQ@mail.gmail.com> <CAPW_8m5CU++j=8tNBK1Q7KszxsfORnK1-6mxcgUwz9X2R2JTyA@mail.gmail.com> <CAAzbHvZGYGNOkuAkc7Fu29maDcbjSf_o54q93Xa+Ggk_fkGHAw@mail.gmail.com> <55CD15FF.2060805@berkeley.edu>
From: Klaus Hartke <hartke@tzi.org>
Date: Sat, 15 Aug 2015 14:21:55 +0200
Message-ID: <CAAzbHvZMtGdzN4WE0OzmUEuY6Pi1JE-6rQqs-u_0pHMvX+Cd+w@mail.gmail.com>
Subject: Re: Link relation types for non-GET links
To: Erik Wilde <dret@berkeley.edu>
Content-Type: text/plain; charset="UTF-8"
Archived-At: <http://mailarchive.ietf.org/arch/msg/link-relations/FOtGgoTyorrBnrU0MXoNIIZiADI>
Cc: link-relations <link-relations@ietf.org>
X-BeenThere: link-relations@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <link-relations.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/link-relations>, <mailto:link-relations-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/link-relations/>
List-Post: <mailto:link-relations@ietf.org>
List-Help: <mailto:link-relations-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/link-relations>, <mailto:link-relations-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 15 Aug 2015 12:22:42 -0000

Erik Wilde wrote:
>> Would it make sense to
>> register a bunch of generic non-GET link relation types, like
>> "create", "execute", "update", "delete"?
>
> not any more than it would make sense to have a generic GET relation type
> that says "read"...

The most common type of links in the web are simple <a href=""></a>
links that could be interpreted as having a "read" relation type.

> link relation types should primarily indicate why
> somebody would want to follow a link. in HTTP-land, that may sometime
> require using methods other than GET, so that the uniform interface is used
> correctly. if so, the link relation definition (or the service making use of
> it) should say so, so that clients know how to engage in the interaction.

Right. For example, if you have a collection resource, you might want
to provide a link that, when followed, creates a new item in the
collection. Or each item might have links to update or delete the
item:

  <tasks>
    <link rel="create" href="/tasks" method="POST"
accept="application/task+xml application/task+json"/>
    <task id="t1">
      <description>Take out the trash.</description>
      <link rel="update" href="/tasks/1" method="PUT"
accept="application/task+xml"/>
      <link rel="delete" href="/tasks/1" method="DELETE"/>
    </task>
    <task id="t2">
      <description>Pick up the kids.</description>
      <!--readonly-->
    </task>
    <task id="t3">
      <description>Return books to the library.</description>
      <link rel="update" href="/tasks/3" method="PUT"
accept="application/task+xml"/>
    </task>
  </tasks>

IMO it makes sense to provide one link per action rather than
providing a single "edit" link, because some actions might be invalid
for the current state of the resource, or the user might not be
authorized to perform all actions.

> defining a general-purpose format that captures all possible ways in which
> link relations may have rules associated with them is hard, and personally,
> my link description mentioned above draft has stalled because without a
> better picture of what should and shouldn't be covered, this is a typical
> "designing into the void" scenario.

I'm not trying to design something; I'm trying to collect best
practices. However, while safe links seem to be well understood, there
does not really seem to be consensus on how hypermedia controls for
manipulating resource states should look like.

Based on what I've seen so far, to me it seems that such a hypermedia
control is modelled best like safe links with the following
information:

* an identifier identifying the semantics of the hypermedia control
(the relation type),
* the subject of the hypermedia control (i.e., the resource that is
being manipulated, the context), and
* enough information for the client to construct a request to
manipulate the resource, which includes
       - the request method to use,
       - the request URI to use, and
       - a machine-readable description of the payload to include in
the request.

So the major difference between a safe link and an unsafe one is the
non-GET request method and the description of the payload. I don't
think that a lot more than this is needed.

(Background: people are looking for advice on how to build
applications on top of CoAP [1]. I've started to collect some best
practices in a draft [2], and made an attempt at defining some
terminology for hypermedia controls [3]. The idea is, if we cannot
provide advice for RESTful Web APIs in general, maybe it's possible to
establish consensus on how RESTful Web APIs in constrained
environments [4] should look like.)

Klaus

[1] https://tools.ietf.org/html/rfc7252
[2] https://tools.ietf.org/html/draft-hartke-core-apps-01
[3] https://tools.ietf.org/html/draft-hartke-core-apps-01#section-2.4
[4] https://tools.ietf.org/html/rfc7228