<?xml version="1.0" encoding="US-ASCII"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
     which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2119 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC3986 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3986.xml">
<!ENTITY RFC5988 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5988.xml">
<!ENTITY RFC6690 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6690.xml">
<!ENTITY RFC6763 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6763.xml">
<!ENTITY RFC7252 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7252.xml">
<!ENTITY RFC7396 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7396.xml">
<!ENTITY RFC7641 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7641.xml">

]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs),
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
     (Here they are set differently than their defaults in xml2rfc v1.32) -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="3"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->
<rfc category="info" ipr="trust200902" docName="draft-groves-core-dynlink-00">

<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>

<?rfc toc="yes" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes"?>
<?rfc iprnotified="no" ?>
<?rfc strict="yes" ?>

    <front>
        <title abbrev="Dynamic Resource Linking for CoRE">Dynamic Resource Linking for Constrained RESTful Environments</title>

        <author initials="Z" surname="Shelby" fullname="Zach Shelby">
          <organization>
             ARM
          </organization>
          <address>
            <postal>
             <street>150 Rose Orchard</street>
             <city>San Jose</city>
             <code>95134</code>
             <country>FINLAND</country>
            </postal>
            <phone>+1-408-203-9434</phone>
            <email>zach.shelby@arm.com</email>
          </address>
        </author>
        
        <author fullname="Matthieu Vial" initials="M.V."
                surname="Vial">
          <organization>Schneider-Electric</organization>
          <address>
            <postal>
              <street></street>
              <city>Grenoble</city>
              <region></region>
              <code></code>
              <country>FRANCE</country>
            </postal>
            <phone>+33 (0)47657 6522</phone>
            <email>matthieu.vial@schneider-electric.com</email>
          </address>
        </author>

        <author initials="M" surname="Koster" fullname="Michael Koster">
          <organization>
             SmartThings
          </organization>
          <address>
            <postal>
             <street>665 Clyde Avenue</street>
             <city>Mountain View</city>
             <code>94043</code>
             <country>USA</country>
            </postal>
            <phone>	</phone>
            <email>michael.koster@smartthings.com</email>
          </address>
        </author>
		
		<author initials="C" surname="Groves" fullname="Christian Groves">
          <organization>
             Huawei
          </organization>
          <address>
            <postal>
             <street></street>
             <city></city>
             <code></code>
             <country>Australia</country>
            </postal>
            <phone>	</phone>
            <email>Christian.Groves@nteczone.com</email>
          </address>
        </author>
  <date year="2016"/>

  <area>Applications and Real-Time Area</area>

  <workgroup>CoRE</workgroup>
  <keyword>CoRE, CoAP, Link Binding, Observe</keyword>

    <abstract>
    <t>
  For CoAP <xref target="RFC7252"/> Dynamic linking of state updates between resources, either on an endpoint or between endpoints, is defined with the concept of Link Bindings. This document defines conditional observation attributes that work with Link Bindings or with simple CoAP Observe <xref target="RFC7641"/>.
    </t> 
    </abstract>
    </front>

    <middle>


  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <section anchor="introduction" title="Introduction">

  <t>
  IETF Standards for machine to machine communication in constrained environments describe a REST protocol and a set of related information standards that may be used to represent machine data and machine metadata in REST interfaces. CoRE Link-format is a standard for doing Web Linking <xref target="RFC5988"/> in constrained environments. 
  </t>

  <t>
  This document introduces the concept of a Link Binding, which defines a new link relation type to create a dynamic link between resources over which to exchange state updates. Specifically, a Link Binding is a link for binding the state of 2 resources together such that updates to one are sent over the link to the other. CoRE Link Format representations are used to configure, inspect, and maintain Link Bindings. This document additionally defines a set of conditional Observe Attributes for use with Link Bindings and with the standalone CoRE Observe <xref target="RFC7641"/> method.
  </t>
  <t>Editor's note: This initial version is based on the text of I.D.ietf-core-interfaces-04. Further work is needed around link bindings and extending the obeserve attributes with another use
case that requires 3 new optional attributes.</t>
  
  </section>
  
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** --> 
  <section anchor="terminology" title="Terminology">
  <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
  "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
  document are to be interpreted as described in <xref
  target="RFC2119"/>.</t>

  <t>This specification requires readers to be familiar with all the terms
  and concepts that are discussed in <xref target="RFC5988"/> and <xref target="RFC6690"/>. This specification makes use of the following additional terminology:</t>
  
  <t>
    <list style="hanging">
      <t hangText="Link Binding:">A unidirectional logical link between a source resource and a destination resource, over which state information is synchronized. </t>
    </list>
  </t> 

  </section>
  

  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  
  <section anchor="bindings" title="Link Bindings and Observe Attributes">
    <t>In a M2M RESTful environment, endpoints may directly exchange the content of their resources to operate the distributed system. For example, a light switch may supply on-off control information that may be sent directly to a light resource for on-off control. Beforehand, a configuration phase is necessary to determine how the resources of the different endpoints are related to each other. This can be done either automatically using discovery mechanisms or by means of human intervention and a so-called commissioning tool. In this document the abstract relationship between two resources is called a link Binding. The configuration phase necessitates the exchange of binding information so a format recognized by all CoRE endpoints is essential. This document defines a format based on the CoRE Link-Format to represent binding information along with the rules to define a binding method which is a specialized relationship between two resources. The purpose of a binding is to synchronize the content between a source resource and a destination resource. The destination resource MAY be a group resource if the authority component of the destination URI contains a group address (either a multicast address or a name that resolves to a multicast address). Since a binding is unidirectional, the binding entry defining a relationship is present only on one endpoint. The binding entry may be located either on the source or the destination endpoint depending on the binding method. The following table gives a summary of the binding methods described in more detail in <xref target="binding_methods"/>.
    </t>

    <texttable>
      <ttcol align="left">Name</ttcol>
      <ttcol align="left">Identifier</ttcol>
      <ttcol align="left">Location</ttcol>
      <ttcol align="left">Method</ttcol>

      <c>Polling</c> <c>poll</c> <c>Destination</c> <c>GET</c>
      <c>Observe</c> <c>obs</c> <c>Destination</c> <c>GET + Observe</c>
      <c>Push</c> <c>push</c> <c>Source</c> <c>PUT</c>
    </texttable>  
  
    <section anchor="binding_format" title="Format">
      <t>Since Binding involves the creation of a link between two resources, Web Linking and the CoRE Link-Format are a natural way to represent binding information. This involves the creation of a new relation type, purposely named &quot;boundto&quot;. In a Web link with this relation type, the target URI contains the location of the source resource and the context URI points to the destination resource. The Web link attributes allow a fine-grained control of the type of synchronization exchange along with the conditions that trigger an update. This specification defines the attributes below:
      </t>
        
      <texttable>
        <ttcol align="left">Attribute</ttcol>
        <ttcol align="left">Parameter</ttcol>
        <ttcol align="left">Value</ttcol>

        <c>Binding method</c> <c>bind</c> <c>xsd:string</c>
        <c>Minimum Period (s)</c> <c>pmin</c> <c>xsd:integer (>0)</c>
        <c>Maximum Period (s)</c> <c>pmax</c> <c>xsd:integer (>0)</c>
        <c>Change Step</c> <c>st</c> <c>xsd:decimal (>0)</c>    
        <c>Greater Than</c> <c>gt</c> <c>xsd:decimal</c>    
        <c>Less Than</c> <c>lt</c> <c>xsd:decimal</c>    
      </texttable>  
    
      <t>
        <list style="hanging">
          <t hangText="Bind Method:">This is the identifier of a binding method which defines the rules to synchronize the destination resource. This attribute is mandatory.</t>
          <t hangText="Minimum Period:">When present, the minimum period indicates the minimum time to wait (in seconds) before sending a new synchronization message (even if it has changed). In the absence of this parameter, the minimum period is up to the notifier.</t>
          <t hangText="Maximum Period:">When present, the maximum period indicates the maximum time in seconds between two consecutive state synchronization messages (regardless if it has changed). In the absence of this parameter, the maximum period is up to the notifier. The maximum period MUST be greater than the minimum period parameter (if present).</t>
          <t hangText="Change Step:">When present, the change step indicates how much the value of a resource SHOULD change before sending a new notification (compared to the value of the last notification). This parameter has lower priority than the period parameters, thus even if the change step has been fulfilled, the time since the last notification SHOULD be between pmin and pmax. </t>
          <t hangText="Greater Than:">When present, Greater Than indicates the upper limit value the resource value SHOULD cross before sending a new notification. This parameter has lower priority than the period parameters, thus even if the Greater Than limit has been crossed, the time since the last notification SHOULD be between pmin and pmax. </t>
          <t hangText="Less Than:">When present, Less Than indicates the lower limit value the resource value SHOULD cross before sending a new notification. This parameter has lower priority than the period parameters, thus even if the Less Than limit has been crossed, the time since the last notification SHOULD be between pmin and pmax. </t>
        </list>
      </t>
    </section>

    <section anchor="binding_methods" title="Binding methods">
    
      <t>A binding method defines the rules to generate the web-transfer exchanges that will effectively send content from the source resource to the destination resource. The description of a binding method must define the following aspects:
      </t>
        
      <t>
        <list style="hanging">
          <t hangText="Identifier:">This is value of the &quot;bind&quot; attribute used to identify the method.</t>
          <t hangText="Location:">This information indicates whether the binding entry is stored on the source or on the destination endpoint.</t>
          <t hangText="REST Method:">This is the REST method used in the Request/Response exchanges.</t>
          <t hangText="Conditions:">A binding method definition must state how the condition attributes of the abstract binding definition are actually used in this specialized binding.</t>
        </list>               
      </t>
            
      <t>This specification supports 3 binding methods described below.
      </t>
      
      <t>
        <list style="hanging">
          <t hangText="Polling:">The Polling method consists of sending periodic GET requests from the destination endpoint to the source resource and copying the content to the destination resource. The binding entry for this method MUST be stored on the destination endpoint. The destination endpoint MUST ensure that the polling frequency does not exceed the limits defined by the pmin and pmax attributes of the binding entry. The copying process MAY filter out content from the GET requests using value-based conditions (e.g Change Step, Less Than, Greater Than).</t>
          
          <t hangText="Observe:">The Observe method creates an observation relationship between the destination endpoint and the source resource. On each notification the content from the source resource is copied to the destination resource. The creation of the observation relationship requires the CoAP Observation mechanism <xref target="RFC7641"/> hence this method is only permitted when the resources are made available over CoAP. The binding entry for this method MUST be stored on the destination endpoint. The binding conditions are mapped as query string parameters (see <xref target="observation"/>).</t>

          <t hangText="Push:">When the Push method is assigned to a binding, the source endpoint sends PUT requests to the destination resource when the binding condition attributes are satisfied for the source resource. The source endpoint MUST only send a notification request if the binding conditions are met. The binding entry for this method MUST be stored on the source endpoint.</t>
        </list>               
      </t>
    </section>

    <section anchor="binding_table" title="Binding table">
      <t>The binding table is a special resource that gives access to the bindings on a endpoint. A binding table resource MUST support the Binding interface defined in <xref target="binding_interface"/>. A profile SHOULD allow only one resource table per endpoint.
      </t>
    </section>
    
    <section anchor="observation" title="Resource Observation Attributes">
    
      <t>When resource interfaces following this specification are made available over CoAP, the CoAP Observation mechanism <xref target="RFC7641"/> MAY be used to observe any changes in a resource, and receive asynchronous notifications as a result. In addition, a set of query string parameters are defined here to allow a client to control how often a client is interested in receiving notifications and how much a resource value should change for the new representation to be interesting. These query parameters are described in the following table. A resource using an interface description defined in this specification and marked as Observable in its link description SHOULD support these observation parameters. The Change Step parameter can only be supported on resources with an atomic numeric value.
      </t>
      <t>These query parameters MUST be treated as resources that are read using GET and updated using PUT, and MUST NOT be included in the Observe request. Multiple parameters MAY be updated at the same time by including the values in the query string of a PUT. Before being updated, these parameters have no default value.
      </t>
      
    <texttable>
      <ttcol align="left">Resource</ttcol>
      <ttcol align="left">Parameter</ttcol>
      <ttcol align="left">Data Format</ttcol>

      <c>Minimum Period</c> <c>/{resource}?pmin</c> <c>xsd:integer (>0)</c>
      <c>Maximum Period</c> <c>/{resource}?pmax</c> <c>xsd:integer (>0)</c>
      <c>Change Step</c> <c>/{resource}?st</c> <c>xsd:decimal (>0)</c>
      <c>Less Than</c> <c>/{resource}?lt</c> <c>xsd:decimal</c>
      <c>Greater Than</c> <c>/{resource}?gt</c> <c>xsd:decimal</c>
    
    </texttable>  
    
  <t>
    <list style="hanging">
          <t hangText="Minimum Period:">When present, the minimum period indicates the minimum time to wait (in seconds) before sending a new synchronization message (even if it has changed). In the absence of this parameter, the minimum period is up to the notifier.</t>
          <t hangText="Maximum Period:">When present, the maximum period indicates the maximum time in seconds between two consecutive state synchronization messages (regardless if it has changed). In the absence of this parameter, the maximum period is up to the notifier. The maximum period MUST be greater than the minimum period parameter (if present).</t>
          <t hangText="Change Step:">When present, the change step indicates how much the value of a resource SHOULD change before sending a new notification (compared to the value of the last notification). This parameter has lower priority than the period parameters, thus even if the change step has been fulfilled, the time since the last notification SHOULD be between pmin and pmax. </t>
          <t hangText="Greater Than:">When present, Greater Than indicates the upper limit value the resource value SHOULD cross before sending a new notification. This parameter has lower priority than the period parameters, thus even if the Greater Than limit has been crossed, the time since the last notification SHOULD be between pmin and pmax. </t>
          <t hangText="Less Than:">When present, Less Than indicates the lower limit value the resource value SHOULD cross before sending a new notification. This parameter has lower priority than the period parameters, thus even if the Less Than limit has been crossed, the time since the last notification SHOULD be between pmin and pmax. </t>
    </list>
  </t>    
    
    </section>
    
  </section>
  
  <section anchor="interfaces" title="Interface Descriptions">

  <t>This section defines REST interfaces for Binding table resources. The interface supports the link-format type. </t>
  
  <t>The if= column defines the Interface Description (if=) attribute value to be used in the CoRE Link Format for a resource conforming to that interface. When this value appears in the if= attribute of a link, the resource MUST support the corresponding REST interface described in this section. The resource MAY support additional functionality, which is out of scope for this specification. Although this interface descriptions is intended to be used with the CoRE Link Format, it is applicable for use in any REST interface definition. </t>
  
  <t>The Methods column defines the methods supported by that interface, which are described in more detail below. 
  </t>

    <texttable>
      <ttcol align="right">Interface</ttcol>
      <ttcol align="left">if=</ttcol>
      <ttcol align="left">Methods</ttcol>
      <ttcol align="left">Content-Formats</ttcol>
 
      <c>Binding</c> <c>core.bnd</c> <c>GET, POST, DELETE</c> <c>link-format</c>    
    </texttable>
  
    <section anchor="binding_interface" title="Binding">
    
    <t>The Binding interface is used to manipulate a binding table. A request with a POST method and a content format of application/link-format simply appends new bindings to the table. All links in the payload MUST have a relation type &quot;boundTo&quot;. A GET request simply returns the current state of a binding table whereas a DELETE request empties the table.</t>
 
    <t>The following example shows requests for adding, retrieving and deleting bindings in a binding table.</t>

  <figure>
    <artwork align="left"><![CDATA[

Req: POST /bnd/ (Content-Format: application/link-format)
<coap://sensor.example.com/s/light>;
  rel="boundto";anchor="/a/light";bind="obs";pmin="10";pmax="60"
Res: 2.04 Changed 

Req: GET /bnd/
Res: 2.05 Content (application/link-format)
<coap://sensor.example.com/s/light>;
  rel="boundto";anchor="/a/light";bind="obs";pmin="10";pmax="60"

Req: DELETE /bnd/
Res: 2.04 Changed

    ]]></artwork>
    </figure>
 
    </section>
     
 
   
  </section>


  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->

  <section anchor="security" title="Security Considerations">
  <t> 
  An implementation of a client needs to be prepared to deal with responses to a request that differ from what is specified in this document. A server implementing what the client thinks is a resource with one of these interface descriptions could return malformed representations and response codes either by accident or maliciously. A server sending maliciously malformed responses could attempt to take advantage of a poorly implemented client for example to crash the node or perform denial of service.  
    </t>

  </section>

  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->

  <section title="IANA Considerations">

  <t>
  The "binding" interface description types requires registration.
  </t>

  <t>
  The new link relations type "boundto" requires registration.
  </t>
  
  <!-- We need a registry for binding methods? -->
     
  </section>

<!-- **************************************************************** -->
<!--  SECTION: ACKNOWLEDGMENTS          -->
<!-- **************************************************************** -->

<section title="Acknowledgments">

<t>Acknowledgement is given to colleagues from the SENSEI project who were critical in the initial development of the well-known REST interface concept, to members of the IPSO Alliance where further requirements for interface types have been discussed, and to Szymon Sasin, Cedric Chauvenet, Daniel Gavelle and Carsten Bormann who have provided useful discussion and input to the concepts in this document. </t>

</section>

  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->

  <section title="Changelog">
  
  <t>Initial Version 00
  <list style="symbols">
  	<t>This initial version is based on the text regarding the dynamic linking functionality in I.D.ietf-core-interfaces-05. </t>
	<t>The WADL description has been dropped in favour of a thorough textual description of the REST API.</t>
	
  </list>
  </t>


  </section>
  
    </middle>

    <back>
    <references title='Normative References'>
    &RFC2119;
    &RFC5988;
	&RFC6690;

       
    </references>

    <references title='Informative References'>
    &RFC7252;
    &RFC7641;
       
    </references>
  
  </back>

</rfc>
