Re: Link relation types for non-GET links

Klaus Hartke <hartke@tzi.org> Sat, 15 August 2015 17:57 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 8348B1A21A8 for <link-relations@ietfa.amsl.com>; Sat, 15 Aug 2015 10:57:10 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0.472
X-Spam-Level:
X-Spam-Status: No, score=0.472 tagged_above=-999 required=5 tests=[BAYES_05=-0.5, 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 DzeBoGi9ss6h for <link-relations@ietfa.amsl.com>; Sat, 15 Aug 2015 10:57:08 -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 3CC4A1A21A5 for <link-relations@ietf.org>; Sat, 15 Aug 2015 10:57:08 -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 t7FHv56U028179 for <link-relations@ietf.org>; Sat, 15 Aug 2015 19:57:05 +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 3mtq8c5dyjz4tvK for <link-relations@ietf.org>; Sat, 15 Aug 2015 19:57:04 +0200 (CEST)
Received: by igfj19 with SMTP id j19so32243648igf.0 for <link-relations@ietf.org>; Sat, 15 Aug 2015 10:57:03 -0700 (PDT)
X-Received: by 10.50.87.74 with SMTP id v10mr9117074igz.37.1439661423261; Sat, 15 Aug 2015 10:57:03 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.79.111.209 with HTTP; Sat, 15 Aug 2015 10:56:23 -0700 (PDT)
In-Reply-To: <CAPW_8m58YoAVcXo9Z48deSEuy9oo26BeS-hrcN2g=mkOCS9vDA@mail.gmail.com>
References: <CAAzbHvb==Sn_4UUFHKs3H9GYbEfiX=TUjv4FSmNi9R4NEB+DvQ@mail.gmail.com> <CAPW_8m5CU++j=8tNBK1Q7KszxsfORnK1-6mxcgUwz9X2R2JTyA@mail.gmail.com> <CAAzbHvZGYGNOkuAkc7Fu29maDcbjSf_o54q93Xa+Ggk_fkGHAw@mail.gmail.com> <55CC8C1D.9060900@gmx.de> <CAAzbHva19zw8tzKxSxhMFUSV0RLMFjq94Pb5Z4mc8GseEgrkBw@mail.gmail.com> <55CF2EBE.5060203@gmx.de> <CAAzbHvaTmB4Qf8XQR-55Eop62rHEnV18bdDOqxSq4UEMHKh-xg@mail.gmail.com> <CAPW_8m58YoAVcXo9Z48deSEuy9oo26BeS-hrcN2g=mkOCS9vDA@mail.gmail.com>
From: Klaus Hartke <hartke@tzi.org>
Date: Sat, 15 Aug 2015 19:56:23 +0200
Message-ID: <CAAzbHvYHC0CBcvDEQzr9fzU9aguZof481RRdM1zkO2sCdZpNPQ@mail.gmail.com>
Subject: Re: Link relation types for non-GET links
To: mike amundsen <mamund@yahoo.com>
Content-Type: text/plain; charset="UTF-8"
Archived-At: <http://mailarchive.ietf.org/arch/msg/link-relations/PDGGBZeD-ehNXJ5mol3lT8soOPI>
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 17:57:10 -0000

Mike Amundsen wrote:
> I think an important design decision is whether you want to overload a link
> rel value ("edit", "item", "collection", "payment") with protocol-level
> information like "idempotent", "safe", etc. or rendering information like
> "transclude", "immutable:, etc.
>
> My advice is to keep them separate.

That's exactly what my initial question was about: should all
hypermedia controls take the shape of a link, with the link relation
types providing all the necessary details (like request method,
presentation, etc.), or should a media type provide a number of
syntactically different hypermedia controls so that the relation type
really only indicates the semantic meaning of the control.

The existence of the "edit" link relation type seems to point at the
former, although I would agree that it's probably better to keep it
separated and do the latter.

So, because I like HAL, I would extend HAL with forms, resulting in a
representation that might look like this:

  {
    "_links": {
      "terms-of-service": {
        "href": "http://example.org/tos",
        "type": "text/html"
      },
    },
    "_forms": {
      "create-a-new-item-in": {
        "href": "http://example.org/collection/",
        "method": "POST",
        "accept": "application/x-www-form-urlencoded",
        "fields": [ "firstName", "lastName", "eMail" ]
      }
    },
    ...
  }

The "create-a-new-item-in" non-GET link is kept separate from the
"terms-of-service" GET link, and has

* a context (a collection resource),
* a "form relation type" that enables a client to decide whether to
follow this link or not,
* a request method which indicates that following the link changes
resource state, is not safe and not idempotent, and
* a description of the payload that the server expects in the request
when following the link.

> Your definitions in 2.4 are a bit unclear (by my reading)
> _link_ promises "navigation" ("transclude=false") but does it also promise
> "safe=true"?
> _embedded_link_ promisses "transclude=true" but does it also promise
> "safe=true"?
> _templated_link_ promises "mutability" but what of safety and transclusion?
> _form_ is promising "safe=false" but some are idempotent, some not.
>
> esp. when working with automated systems, you'll need to sort this out
> explicitly -- preferably inband, i suspect.

I actually based that on H-Factor Link Support, except that I combined
LN and LI:

* link = LO (replaces the application state, safe [1], idempotent [2])
* embedding link = LE (adds to the application state, safe, idempotent)
* templated link = LT (replaces the application state, safe, idempotent)
* form = LN / LI (changes resource state, not safe, may or may not be
idempotent; includes the method to use, so the client would know if
it's idempotent or not)

(I'm not sure I understand what you mean by "mutability".)

> i wrote up a draft paper in 2011 that talks about these[1] "hypermedia
> aspects" (safety, idempotence, mutability, and transclusion) and have a web
> page that lists the most common hypermedia factors[2] (that page could use
> some "love", tho <g>).  This might help you in designing a media type that
> does a good job supporting a wide range of protocol-agnostic actions and
> promises.

The H-Factor page is actually printed and sitting on my desk :-)

> Finally, I am working on a media type design specifically aimed at automated
> agents -- Uniform Basis for Exchanging Representations (UBER -- I
> know...)[3] that you are free to use that for inspiration, caution, etc.

Thanks, this looks interesting.

Klaus

[1] http://tools.ietf.org/html/rfc7231#section-4.2.1
[2] http://tools.ietf.org/html/rfc7231#section-4.2.2