One document matched: draft-shelby-core-interfaces-01.xml


<?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 RFC0792 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.0792.xml">
<!ENTITY RFC2045 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2045.xml">
<!ENTITY RFC2046 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2046.xml">
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC2616 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2616.xml">
<!ENTITY RFC3986 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml">
<!ENTITY RFC4288 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4288.xml">
<!ENTITY RFC4346 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4346.xml">
<!ENTITY RFC4347 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4347.xml">
<!ENTITY RFC4944 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4944.xml">
<!ENTITY RFC5234 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5234.xml">
<!ENTITY RFC5785 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5785.xml">
<!ENTITY RFC5988 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5988.xml">
<!ENTITY I-D.ietf-core-coap SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-core-coap.xml">
<!ENTITY I-D.ietf-core-link-format SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-core-link-format.xml">
<!ENTITY I-D.ietf-core-observe SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-core-observe.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="std" ipr="trust200902" docName="draft-shelby-core-interfaces-01">

<?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>CoRE Interfaces</title>

        <author initials="Z" surname="Shelby" fullname="Zach Shelby">
          <organization>
             Sensinode
          </organization>
          <address>
            <postal>
             <street>Kidekuja 2</street>
             <city>Vuokatti</city>
             <code>88600</code>
             <country>FINLAND</country>
            </postal>
            <phone>+358407796297</phone>
            <email>zach@sensinode.com</email>
          </address>
        </author>

  <date year="2012"/>

  <area>Internet</area>

  <workgroup>CoRE</workgroup>
  <keyword>CoRE, Web Linking, Resource Discovery</keyword>

    <abstract>
    <t>
	This document defines well-known REST interface descriptions for Batch, Sensor, Parameter and Actuator types for use in contrained web servers using the CoRE Link Format. A short reference is provided for each type that can be efficiently included in the interface description attribute of the CoRE Link Format. These descriptions are intended to be for general use in resource designs or for inclusion in more specific interface profiles.
	</t> 
    
    </abstract>
    </front>

    <middle>


  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <section anchor='introduction' title="Introduction">

  <t>
  The Constrained RESTful Environments (CoRE) working group aims at realizing the REST architecture in a suitable form for the most constrained nodes (e.g. 8-bit microcontrollers with limited RAM and ROM) and networks (e.g. 6LoWPAN). CoRE is aimed at machine-to-machine (M2M) applications such as smart energy and building automation.
  </t>
  <t>
  The discovery of resources offered by a constrained server is very important in machine-to-machine applications where there are no humans in the loop and static interfaces result in fragility. The discovery of resources provided by an HTTP Web Server is typically called Web Linking <xref target="RFC5988"/>. The use of Web Linking for the description and discovery of resources hosted by constrained web servers is specified by the CoRE Link Format <xref target="I-D.ietf-core-link-format"/> and can be used by CoAP <xref target="I-D.ietf-core-coap"/> or HTTP servers. The CoRE Link Format defines an attribute that can be used to describe the REST interface of a resource, and may include a link to a description document. This document defines well-known interface descriptions for Batch, Sensor, Parameter, Read-only Parameter and Actuator types for use in contrained web servers. A short reference is provided for each type that can be efficiently included in the interface description (if=) attribute of the CoRE Link Format. 
  </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="I-D.ietf-core-link-format"/>. </t>

  </section>
  

  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->

  <section anchor="interfaces" title="Interface Descriptions">

  <t>This section defines REST interfaces for Batch, Sensor, Parameter and Actuator resources. Each type is described along with its Interface Description attribute value, recommended path pattern and valid methods. These are defined for each interface in the table below. These interfaces can support plain text and/or SenML Media types. </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 these interface descriptions are intended to be used with the CoRE Link Format, they are applicable for use in any REST interface definition. </t>
  
  <t>The Path column defines an example path pattern that a resource of this type might use for simple end-points. These interfaces are expected to also be used in other path patterns. In any case, resource paths SHOULD be discoverable as described in <xref target="I-D.ietf-core-link-format"/>.      
  </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">Path Example</ttcol>
      <ttcol align="left">Methods</ttcol>
      
      <c>Batch</c> <c>core#b</c> <c>/s,/p,/a</c> <c>GET, PUT, POST (where applicable)</c>
      <c>Sensor</c> <c>core#s</c> <c>/s/{name}</c> <c>GET</c>
      <c>Parameter</c> <c>core#p</c> <c>/p/{name}</c> <c>GET, PUT</c>
      <c>Read-only Parameter</c> <c>core#rp</c> <c>/p/{name}</c> <c>GET</c>
      <c>Actuator</c> <c>core#a</c> <c>/a/{name}</c> <c>GET, PUT, POST</c>     
    </texttable>
  
  <t>The following is an example of links in the CoRE Link Format using these interface descriptions. These links are used in the subsequent examples below.</t>
 
 	<figure>
    <artwork align="left"><![CDATA[

Req: GET /.well-known/core
Res: 2.05 Content (application/link-format)
</s>;if="core#b",
</s/light>;if="core#s",
</s/temp>;if="core#s";obs,
</s/humidity>;if="core#s",
</p/name>;if="core#p",
</p/model>;if="core#rp",
</a>;if="core#b",
</a/led1>;if="core#a",
</a/led2>;if="core#a"
  	]]></artwork>
    </figure>
 
    <section anchor="batch" title="Batch">
    
    <t>The Batch interface is used to manipulate a collection of sub-resources at the same time. The Batch interface type supports the same methods as its sub-resources, and can be used to read (GET) or set (PUT) or toggle (POST) the values of those sub-resource with a single resource representation. The sub-resources of a Batch MAY be heterogeneous, a method used on the Batch only applies to sub-resources that support it. For example Sensor interfaces do not support PUT, and thus a PUT request to a Sensor member of that Batch would be ignored. A batch requires the use of SenML Media types in order to support multiple sub-resources. </t>
    
    <t>The following example interacts with a Batch /s with Sensor sub-resources /s/light, /s/temp and /s/humidity. </t>
    
	<figure>
    <artwork align="left"><![CDATA[

Req: GET /s
Res: 2.05 Content (application/senml+json)
{"e":[
    { "n": "light", "v": 123, "u": "lx" },
    { "n": "temp", "v": 27.2, "u": "degC" },
    { "n": "humidity", "v": 80, "u": "%RH" }],
}

  	]]></artwork>
    </figure>  
    
    </section>

    <section anchor="sensor" title="Sensor">
    
    <t>The Sensor interface allows the value of a sensor resource to be read (GET). The Media type of the resource can be either plain text or SenML. Plain text MAY be used for a single measurement that does not require meta-data. For a measurement with meta-data such as a unit or time stamp, SenML SHOULD be used. A resource with this interface MAY use SenML to return multiple measurements in the same representation, for example a list of recent measurements.</t>

    <t>The following are examples of Sensor interface requests in both text/plain and application/senml+json.</t>
    
	<figure>
    <artwork align="left"><![CDATA[

Req: GET /s/humidity (Accept: text/plain)
Res: 2.05 Content (text/plain)
80

Req: GET /s/humidity (Accept: application/senml+json)
Res: 2.05 Content (application/senml+json)
{"e":[
    { "n": "humidity", "v": 80, "u": "%RH" }],
}

  	]]></artwork>
    </figure>      
    
    </section>  

    <section anchor="parameter" title="Parameter">
    
    <t>The Parameter interface allows configurable parameters and other information to be modeled as a resource. The value of the parameter can be read (GET) or set (PUT). Plain text or SenML Media types MAY be returned from this type of interface.</t>

    <t>The following example shows request for reading and setting a parameter.</t>

	<figure>
    <artwork align="left"><![CDATA[

Req: GET /p/name
Res: 2.05 Content (text/plain)
node5

Req: PUT /p/name (text/plain)
outdoor
Res: 2.04 Changed 

  	]]></artwork>
    </figure> 
    
    </section>

    <section anchor="readonly-parameter" title="Read-only Parameter">
    
    <t>The Read-only Parameter interface allows configuration parameters to be read (GET) but not set. Plain text or SenML Media types MAY be returned from this type of interface.</t>

    <t>The following example shows request for reading such a parameter.</t>

	<figure>
    <artwork align="left"><![CDATA[

Req: GET /p/model
Res: 2.05 Content (text/plain)
SuperNode200

  	]]></artwork>
    </figure> 
    
    </section>


    <section anchor="actuator" title="Actuator">
    
    <t>The Actuator interface is used by resources that model different kinds of actuators (changing its value has an effect on its environment). Examples of actuators include for example LEDs, relays, motor controllers and light dimmers. The current value of the actuator can be read (GET) or a new actuator value set (PUT). In addition, this interface defines the use of POST (with no body) to toggle an actuator between its possible values. Plain text or SenML Media types MAY be returned from this type of interface. A resource with this interface MAY use SenML to include multiple measurements in the same representation, for example a list of recent actuator values or a list of values to set.</t>
 
    <t>The following example shows request for reading, setting and toggling an actuator (turning on a led).</t>

	<figure>
    <artwork align="left"><![CDATA[

Req: GET /a/led1
Res: 2.05 Content (text/plain)
0

Req: PUT /a/led1 (text/plain)
1
Res: 2.04 Changed 

Req: POST /a/led1 (text/plain)
Res: 2.04 Changed 

Req: GET /a/led1
Res: 2.05 Content (text/plain)
0

  	]]></artwork>
    </figure>
 
    </section>

    <section anchor="observation" title="Resource Observation">
    
      <t>When resource interfaces following this specification are made available over CoAP, the CoAP Observation mechanism <xref target="I-D.ietf-core-observe"/> 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 request how often a client is interested in receiving notifications and how much a resource 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>
      
    <texttable>
      <ttcol align="left">Query</ttcol>
      <ttcol align="left">Parameter</ttcol>
      <ttcol align="left">Value</ttcol>

      <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>
    
    </texttable>	
	  
	<t>
	  <list style="hanging">
	  	<t hangText="Minimum Period:">When present, the minimum period indicates the minimum time in seconds the server SHOULD wait between sending notifications. In the absence of this parameter, the minimum period is up to the server.</t>
	  	<t hangText="Maximum Period:">When present, the maximum period indicated the maximum time in seconds the server SHOULD wait between sending notifications (regardless if it has changed). In the absence of this parameter, the maximum period is up to the server. The maximum period MUST be great 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>
	  </list>
	</t> 
    
    <t>The following example shows an Observation request using these query parameters. Here the value of Observe indicates the number of seconds since the observation was made to show the time.</t>

	<figure>
    <artwork align="left"><![CDATA[

Req: GET Observe /s/temp?pmin=10&pmax=60&st=1
Res: 2.05 Content Observe:0 (text/plain)
23.2

Res: 2.05 Content Observe:60 (text/plain)
23.0

Res: 2.05 Content Observe:80 (text/plain)
22.2

Res: 2.05 Content Observe:140 (text/plain)
21.8

  	]]></artwork>
    </figure>     
    
    </section>

    <section anchor="future" title="Future Interfaces">
	
	  <t>It is expected that further interface descriptions will be defined in this and other specifications. Potential interfaces to be considered for this specifications include:
	  
	  <list style="hanging">
	  	<t hangText="Batch of Links:">This resource would contain a list of links, pointing to resources that will be manipulated by requesting
	  	a method on that resource.</t>
	  	
	  	<t hangText="Collection:">This resource would be a container that allows sub-resources to be added or removed.</t>
	  </list>
	  </t>
	  
    </section>
   
    <section anchor="wadl" title="WADL Description">
    
    <t>This section defines the formal Web Application Description Langauge (WADL) definition of these CoRE interface descriptions.</t>
    
	<figure>
    <artwork align="left"><![CDATA[

<?xml version="1.0" standalone="yes"?>

<application xmlns="http://research.sun.com/wadl/2006/10"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<grammars>
<include href="http://tools.ietf.org/html/draft-jennings-senml"/>
</grammars>
             
<doc title="CoRE Interfaces"/>

<resource_type id="b">
 <doc title="Batch of sub-resources type. The method is applied 
 to each sub-resource of the requested resource that 
 supports it. Mixed sub-resource types can be supported."/>
 <method id="b_request" name="GET">
    <doc>Retrieve the representations of all resources under 
    this collection in a single request.</doc>
    <request>
    	<param name="pmin" style="query" type="xsd:integer"/>
    	<param name="pmax" style="query" type="xsd:integer"/>
    	<param name="st" style="query" type="xsd:decimal"/>
    </request>
    <response status="200">
      <representation mediaType="application/senml+exi"/>
      <representation mediaType="application/senml+xml"/>
      <representation mediaType="application/senml+json"/>
    </response>
 </method>
<method id="b_update" name="PUT">
    <doc>Update the representations of all resources under 
    this collection in a single request that support 
    PUT.</doc>
    <request>
       <representation mediaType="application/senml+exi"/>
       <representation mediaType="application/senml+xml"/>
       <representation mediaType="application/senml+json"/> 
    </request>
    <response status="204"/>
 </method>
 <method id="b_toggle" name="POST">
    <doc>Toggle the values of actuator resources that support
    POST in the collection.</doc>
    <request>
    </request>
    <response status="204"/>
 </method>
</resource_type>

<resource_type id="s">
 <doc title="Sensor resource type"/>
 <method id="s_request" name="GET">
    <doc>Retrieve the value of the sensor</doc>
    <request>
    	<param name="pmin" style="query" type="xsd:integer"/>
    	<param name="pmax" style="query" type="xsd:integer"/>
    	<param name="st" style="query" type="xsd:decimal"/>
    </request>
    <response status="200">
       <representation mediaType="text/plain"/>
       <representation mediaType="application/senml+exi"/>
       <representation mediaType="application/senml+xml"/>
       <representation mediaType="application/senml+json"/>         
    </response>
 </method>
</resource_type>     

<resource_type id="p">
 <doc title="Parameter resource type"/>
 <method id="p_request" name="GET">
    <doc>Retrieve the value of the parameter</doc>
    <request>
    	<param name="pmin" style="query" type="xsd:integer"/>
    	<param name="pmax" style="query" type="xsd:integer"/>
    	<param name="st" style="query" type="xsd:decimal"/>
    </request>
    <response status="200">
       <representation mediaType="text/plain"/>
       <representation mediaType="application/senml+exi"/>
       <representation mediaType="application/senml+xml"/>
       <representation mediaType="application/senml+json"/>         
    </response>
 </method>
 <method id="p_update" name="PUT">
    <doc>Update to the parameter value</doc>
    <request>
       <representation mediaType="text/plain"/>
       <representation mediaType="application/senml+exi"/>
       <representation mediaType="application/senml+xml"/>
       <representation mediaType="application/senml+json"/> 
    </request>
    <response status="204"/>
 </method>
</resource_type>           

<resource_type id="rp">
 <doc title="Read-only Parameter resource type"/>
 <method id="p_request" name="GET">
    <doc>Retrieve the value of the parameter</doc>
    <request>
    	<param name="pmin" style="query" type="xsd:integer"/>
    	<param name="pmax" style="query" type="xsd:integer"/>
    	<param name="st" style="query" type="xsd:decimal"/>
    </request>
    <response status="200">
       <representation mediaType="text/plain"/>
       <representation mediaType="application/senml+exi"/>
       <representation mediaType="application/senml+xml"/>
       <representation mediaType="application/senml+json"/>         
    </response>
 </method>
</resource_type> 

<resource_type id="a">
 <doc title="Actuator resource type"/>
 <method id="a_request" name="GET">
    <doc>Retrieve the value of the actuator</doc>
    <request>
    	<param name="pmin" style="query" type="xsd:integer"/>
    	<param name="pmax" style="query" type="xsd:integer"/>
    	<param name="st" style="query" type="xsd:decimal"/>
    </request>
    <response status="200">
       <representation mediaType="text/plain"/>
       <representation mediaType="application/senml+exi"/>
       <representation mediaType="application/senml+xml"/>
       <representation mediaType="application/senml+json"/>    
    </response>
 </method>
 <method id="a_actuate" name="PUT">
    <doc>Control the actuator with a new value or command</doc>
    <request>
       <representation mediaType="text/plain"/>
       <representation mediaType="application/senml+exi"/>
       <representation mediaType="application/senml+xml"/>
       <representation mediaType="application/senml+json"/>  
    </request>
    <response status="204"/>
 </method>
 <method id="a_toggle" name="POST">
    <doc>Toggle the value of the actuator</doc>
    <request> 
    </request>
    <response status="204"/>
 </method>
</resource_type>     
     
</application>

	]]></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>
	To be determined if a registry of interface descriptions should be created for CoRE, allowing other interface descriptions to be registered by other specifications (and if this document is the place to create such a registry). 
	</t>
     
  </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 conept, 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>

<t>Special thanks to Matthieu Vial for helping develop ideas for the batch, link batch and collection resources and for providing useful comments and the document.  </t>

</section>

  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->
  <!-- **************************************************************** -->

  <section title="Changelog">

  </section>

    </middle>

    <back>
    <references title='Normative References'>
       &I-D.ietf-core-link-format;
       &RFC2119;
       &RFC5988;
       
    </references>

    <references title='Informative References'>
		&I-D.ietf-core-coap;
		&I-D.ietf-core-observe;
       
    </references>
    </back>

</rfc>

PAFTECH AB 2003-20262026-04-23 14:17:43