Re: NEW PREFERENCE - return=query-result

Phil Hunt <phil.hunt@oracle.com> Fri, 11 September 2015 21:57 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 873051B4B7A for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Fri, 11 Sep 2015 14:57:39 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.31
X-Spam-Level:
X-Spam-Status: No, score=-6.31 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, J_CHICKENPOX_46=0.6, MIME_QP_LONG_LINE=0.001, RCVD_IN_DNSWL_HI=-5, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=ham
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 5-2TdL8bkoTx for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Fri, 11 Sep 2015 14:57:37 -0700 (PDT)
Received: from frink.w3.org (frink.w3.org [128.30.52.56]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id CE3C41B4A17 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Fri, 11 Sep 2015 14:57:36 -0700 (PDT)
Received: from lists by frink.w3.org with local (Exim 4.80) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1ZaWHT-0007Lh-25 for ietf-http-wg-dist@listhub.w3.org; Fri, 11 Sep 2015 21:54:51 +0000
Resent-Date: Fri, 11 Sep 2015 21:54:51 +0000
Resent-Message-Id: <E1ZaWHT-0007Lh-25@frink.w3.org>
Received: from lisa.w3.org ([128.30.52.41]) by frink.w3.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from <phil.hunt@oracle.com>) id 1ZaWHM-0007L0-JL for ietf-http-wg@listhub.w3.org; Fri, 11 Sep 2015 21:54:44 +0000
Received: from aserp1040.oracle.com ([141.146.126.69]) by lisa.w3.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from <phil.hunt@oracle.com>) id 1ZaWHK-0003PK-LC for ietf-http-wg@w3.org; Fri, 11 Sep 2015 21:54:44 +0000
Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t8BLs93F025780 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 11 Sep 2015 21:54:10 GMT
Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t8BLs93n031535 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 11 Sep 2015 21:54:09 GMT
Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t8BLs908012345; Fri, 11 Sep 2015 21:54:09 GMT
Received: from [25.85.42.40] (/72.143.225.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 11 Sep 2015 14:54:08 -0700
Content-Type: multipart/alternative; boundary="Apple-Mail-D572060C-5AB0-4042-831C-BFCA82A52C1E"
Mime-Version: 1.0 (1.0)
From: Phil Hunt <phil.hunt@oracle.com>
X-Mailer: iPhone Mail (12H321)
In-Reply-To: <CACweHNAk-_EfScpgRigTL4pE5BhTrpN=5m1_DZpdR=NSAJy94A@mail.gmail.com>
Date: Fri, 11 Sep 2015 14:54:01 -0700
Cc: James M Snell <jasnell@gmail.com>, "ietf-http-wg@w3.org" <ietf-http-wg@w3.org>, Ning Dong <ning.dong@oracle.com>
Content-Transfer-Encoding: 7bit
Message-Id: <1206D3FD-4221-4FFC-AD97-BE4B92E749DF@oracle.com>
References: <55F1FAB3.2050808@oracle.com> <44321676-D9B4-484C-A490-F5FFCE071D26@oracle.com> <CABP7RbcMTDEM6VOT7ydBTvbH0B6eTYWqVbeV6qcj-KSh7ertLw@mail.gmail.com> <383F7C4D-A006-420B-9504-FD343996ED95@oracle.com> <CACweHNAk-_EfScpgRigTL4pE5BhTrpN=5m1_DZpdR=NSAJy94A@mail.gmail.com>
To: Matthew Kerwin <matthew@kerwin.net.au>
X-Source-IP: userv0021.oracle.com [156.151.31.71]
Received-SPF: pass client-ip=141.146.126.69; envelope-from=phil.hunt@oracle.com; helo=aserp1040.oracle.com
X-W3C-Hub-Spam-Status: No, score=-7.2
X-W3C-Hub-Spam-Report: AWL=-0.001, BAYES_00=-1.9, HTML_MESSAGE=0.001, MIME_QP_LONG_LINE=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, W3C_AA=-1, W3C_IRA=-1, W3C_WL=-1
X-W3C-Scan-Sig: lisa.w3.org 1ZaWHK-0003PK-LC 741a973fe82b01ca86068439f243a60d
X-Original-To: ietf-http-wg@w3.org
Subject: Re: NEW PREFERENCE - return=query-result
Archived-At: <http://www.w3.org/mid/1206D3FD-4221-4FFC-AD97-BE4B92E749DF@oracle.com>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/30201
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <http://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

If you mean have multiple endpoints I agree. 

Another possibility that has been suggested to me is using content-type to signal processing behavior. But this might be a good example as to why it is not the best. It strikes me as more confusing when the content is the same but using content type to signal processing instructions. It then gets complex if you want to signal different permutations and combinations of processing behaviors. 

"post creates a resource" becomes nice and consistent if we move reporting processing functions out of POST(things that do not change state) into a new method like SEARCH. 

Phil

> On Sep 11, 2015, at 14:37, Matthew Kerwin <matthew@kerwin.net.au> wrote:
> 
> If a resource can be coded to have two behaviours (and branch on the 'prefer' header), why not just code two resources?
> 
> It seems much cleaner to me to have one URI that always stores a query and returns 201, and another that always executes immediately and returns 200, when POSTed to.
> 
> They're both valid uses of POST.
> 
>> On 12/09/2015 6:08 AM, "Phil Hunt" <phil.hunt@oracle.com> wrote:
>> Agree. If we had search then I would say post should create a resource by default.
>> 
>> But without search I think many are stuck with using post to search given concerns about passing PII and other restricted info on url with GET.
>> 
>> Phil
>> 
>> > On Sep 11, 2015, at 10:10, James M Snell <jasnell@gmail.com> wrote:
>> >
>> > To be honest, I'm entirely  -1 on a preference for query-result. If
>> > you want something like this, use PUT or POST to create the stored
>> > query, then create a new resource that you can either use GET or
>> > SEARCH (http://tools.ietf.org/html/draft-snell-search-method-00) on.
>> > In my opinion, `query-result` would entirely be an abuse of the
>> > preference mechanism.
>> >
>> >> On Fri, Sep 11, 2015 at 8:56 AM, Phil Hunt <phil.hunt@oracle.com> wrote:
>> >> This is difficult. Two conventions are in collision.  The definition of post to create a resource and the expectation that a query returns a result.
>> >>
>> >> I would maybe tip the scales in favor of what most Oracle apis would need as a default.
>> >>
>> >> Would it be true that clients want to create stored searches by default?
>> >>
>> >> Phil
>> >>
>> >>> On Sep 10, 2015, at 14:49, Ning Dong <ning.dong@oracle.com> wrote:
>> >>>
>> >>> Hi,
>> >>>   Could you please review the request of adding a new value for return prefer header?
>> >>>
>> >>>   The new value is "query-result", which is used when creating a query definition resource with POST or PUT request.
>> >>>   The client would like the server to create the query definition resource, but also execute the query and return the query result.
>> >>>   For example,
>> >>>   POST /employees/searches HTTP/1.1
>> >>>   Host: example.org
>> >>>   Content-Type: application/json
>> >>>   Prefer: return=query-result
>> >>>
>> >>>   {
>> >>>       "q": "name eq foo",
>> >>>       "fields": ["name","age","startdate"],
>> >>>       "orderBy": ["name","age:desc"]
>> >>>   }
>> >>>
>> >>>   This above resource defines a query (equivalent to select name, age, startdate from employees where employees.name='foo' order by name, age desc).
>> >>>   Without the Prefer: return=query-result header, the server would just create a new resource and return a 201 response.
>> >>>   If server honors the prefer header, then the server will not only create a new resource, but also execute the query based on the query definition.
>> >>>   The response body will contain the result of the query execution, such as:
>> >>>   201 Created
>> >>>   Preference-Applied: return=query-result
>> >>>   Location: http://example.com/employees/searches/q1
>> >>>   Content-Location: http://example.com/employees/searches/q1/result
>> >>>
>> >>>   {
>> >>>     "items": [
>> >>>       {"name": "foo",
>> >>>        "age": 35,
>> >>>        "startdate": "2008-02-15"}
>> >>>     ]
>> >>>   }
>> >>>
>> >>> o  Preference: return
>> >>>
>> >>> o  Value: query-result
>> >>>
>> >>> o  Optional Parameters: n/a
>> >>>
>> >>> o  Description: It is used to indicate that result of the query execution is preferred in the response.
>> >>>
>> >>> o  Reference: Oracle will add a new sub type (type=query-def) in application/vnd.oracle.resource+json media type. This new sub type uses return=query-result prefer header.
>> >>>    The application/vnd.oracle.resource+json media type is defined at:
>> >>>    http://www.oracle.com/webfolder/technetwork/tutorials/appdevinfo/New%20REST%20Media%20Type.pdf
>> >>>
>> >>> o  Notes: It is related to another request to add "transient" prefer header.
>> >>>
>> >>>
>> >>>   Thanks and appreciate your review.
>> >>>
>> >>>
>> >>> Ning
>> >