idnits 2.17.1 draft-ietf-core-interfaces-05.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The abstract seems to contain references ([RFC6690]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (July 5, 2016) is 2852 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- == Missing Reference: 'REF' is mentioned on line 652, but not defined ** Obsolete normative reference: RFC 5988 (Obsoleted by RFC 8288) == Outdated reference: A later version (-28) exists of draft-ietf-core-resource-directory-07 == Outdated reference: A later version (-16) exists of draft-ietf-core-senml-00 Summary: 2 errors (**), 0 flaws (~~), 4 warnings (==), 1 comment (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 CoRE Z. Shelby 3 Internet-Draft ARM 4 Intended status: Informational M. Vial 5 Expires: January 6, 2017 Schneider-Electric 6 M. Koster 7 SmartThings 8 C. Groves 9 Huawei 10 July 5, 2016 12 Reusable Interface Definitions for Constrained RESTful Environments 13 draft-ietf-core-interfaces-05 15 Abstract 17 This document defines a set of reusable REST resource design patterns 18 suitable for use in constrained environments, based on IETF CoRE 19 standards for information representation and information exchange. 21 Interface types for Sensors, Actuators, Parameters, and resource 22 Collections are defined using the "if" link attribute defined by CoRE 23 Link Format [RFC6690]. Clients may use the "if" attribute to 24 determine how to consume resources. 26 Editor's note: This version removes the observe notify functionality. 27 Further work is needed on this draft to 29 1 Focus the interfaces draft exclusively on interfaces and 30 collections, and make it clear that this is not the IETF 31 officialy endorsed way to use REST. Build compatibility with OCF 32 collections to the most reasonable extent, otherwise, try to fnid 33 best practice guidance. 35 2 Tone down the formality of function set definition and remove the 36 perception that CoRE Interfaces defines REST function sets. 37 Instead, find some descriptive language that accomplishes the 38 same thing in RD, Pubsub, Interfaces, and other drafts that want 39 to define REST API profiles for mapping functions. 41 Status of This Memo 43 This Internet-Draft is submitted in full conformance with the 44 provisions of BCP 78 and BCP 79. 46 Internet-Drafts are working documents of the Internet Engineering 47 Task Force (IETF). Note that other groups may also distribute 48 working documents as Internet-Drafts. The list of current Internet- 49 Drafts is at http://datatracker.ietf.org/drafts/current/. 51 Internet-Drafts are draft documents valid for a maximum of six months 52 and may be updated, replaced, or obsoleted by other documents at any 53 time. It is inappropriate to use Internet-Drafts as reference 54 material or to cite them other than as "work in progress." 56 This Internet-Draft will expire on January 6, 2017. 58 Copyright Notice 60 Copyright (c) 2016 IETF Trust and the persons identified as the 61 document authors. All rights reserved. 63 This document is subject to BCP 78 and the IETF Trust's Legal 64 Provisions Relating to IETF Documents 65 (http://trustee.ietf.org/license-info) in effect on the date of 66 publication of this document. Please review these documents 67 carefully, as they describe your rights and restrictions with respect 68 to this document. Code Components extracted from this document must 69 include Simplified BSD License text as described in Section 4.e of 70 the Trust Legal Provisions and are provided without warranty as 71 described in the Simplified BSD License. 73 Table of Contents 75 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 76 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 4 77 3. Interface Types . . . . . . . . . . . . . . . . . . . . . . . 5 78 4. Collections . . . . . . . . . . . . . . . . . . . . . . . . . 5 79 4.1. Introduction to Collections . . . . . . . . . . . . . . . 5 80 4.2. Use Cases for Collections . . . . . . . . . . . . . . . . 6 81 4.3. Content-Formats for Collections . . . . . . . . . . . . . 6 82 4.4. Links and Items in Collections . . . . . . . . . . . . . 7 83 4.5. Queries on Collections . . . . . . . . . . . . . . . . . 8 84 4.6. Observing Collections . . . . . . . . . . . . . . . . . . 8 85 4.7. Collection Types . . . . . . . . . . . . . . . . . . . . 8 86 5. Interface Descriptions . . . . . . . . . . . . . . . . . . . 9 87 5.1. Link List . . . . . . . . . . . . . . . . . . . . . . . . 10 88 5.2. Batch . . . . . . . . . . . . . . . . . . . . . . . . . . 10 89 5.3. Linked Batch . . . . . . . . . . . . . . . . . . . . . . 11 90 5.4. Sensor . . . . . . . . . . . . . . . . . . . . . . . . . 12 91 5.5. Parameter . . . . . . . . . . . . . . . . . . . . . . . . 13 92 5.6. Read-only Parameter . . . . . . . . . . . . . . . . . . . 13 93 5.7. Actuator . . . . . . . . . . . . . . . . . . . . . . . . 14 94 5.8. Future Interfaces . . . . . . . . . . . . . . . . . . . . 14 95 6. Function Sets and Profiles . . . . . . . . . . . . . . . . . 14 96 6.1. Defining a Function Set . . . . . . . . . . . . . . . . . 15 97 6.1.1. Path template . . . . . . . . . . . . . . . . . . . . 15 98 6.1.2. Resource Type . . . . . . . . . . . . . . . . . . . . 15 99 6.1.3. Interface Description . . . . . . . . . . . . . . . . 16 100 6.1.4. Data type . . . . . . . . . . . . . . . . . . . . . . 16 101 6.2. Discovery . . . . . . . . . . . . . . . . . . . . . . . . 16 102 6.3. Versioning . . . . . . . . . . . . . . . . . . . . . . . 17 103 7. Security Considerations . . . . . . . . . . . . . . . . . . . 17 104 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 17 105 9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 17 106 10. Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . 17 107 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 19 108 11.1. Normative References . . . . . . . . . . . . . . . . . . 19 109 11.2. Informative References . . . . . . . . . . . . . . . . . 20 110 Appendix A. Profile example . . . . . . . . . . . . . . . . . . 20 111 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 21 113 1. Introduction 115 IETF Standards for machine to machine communication in constrained 116 environments describe a REST protocol and a set of related 117 information standards that may be used to represent machine data and 118 machine metadata in REST interfaces. CoRE Link-format is a standard 119 for doing Web Linking [RFC5988] in constrained environments. SenML 120 [I-D.ietf-core-senml] is a simple data model and representation 121 format for composite and complex structured resources. CoRE Link- 122 Format and SenML can be used by CoAP [RFC7252] or HTTP servers. 124 The discovery of resources offered by a constrained server is very 125 important in machine-to-machine applications where there are no 126 humans in the loop. Machine application clients must be able to 127 adapt to different resource organizations without advance knowledge 128 of the specific data structures hosted by each connected thing. The 129 use of Web Linking for the description and discovery of resources 130 hosted by constrained web servers is specified by CoRE Link Format 131 [RFC6690]. CoRE Link Format additionally defines a link attribute 132 for Interface Type ("if") that can be used to describe the REST 133 interface of a resource, and may include a link to a description 134 document. 136 This document defines a set of Link Format compatible Interface Types 137 for some common design patterns that enable the server side 138 composition and organization, and client side discovery and 139 consumption, of machine resources using Web Linking. An Interface 140 Type may describe a resource in terms of it's associated content 141 formats, data types, URI templates, REST methods, parameters, and 142 responses. Basic interface types are defined for sensors, actuators, 143 and properties. A set of collection types is defined for organizing 144 resources for discovery, and for various forms of bulk interaction 145 with resource sets using typed embedding links. 147 Interface Types may be used in the composition of Function Sets and 148 Profiles. Function Sets and Profiles are described and an example is 149 given of a sensor and actuator device profile using Function Sets 150 composed from the Interface Types described in this document. 152 This document describes a set of Interface Types which are referenced 153 by the "if" link attribute and used to implement reusable design 154 patterns and functional abstractions. A client discovering the "if" 155 link attribute will be able to consume resources based on its 156 knowledge of the expected interface types. In this sense the 157 Interface Type acts in a similar way as a Content-Format, but as a 158 selector for a high level functional abstraction. 160 2. Terminology 162 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 163 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 164 document are to be interpreted as described in [RFC2119]. 166 This specification requires readers to be familiar with all the terms 167 and concepts that are discussed in [RFC5988] and [RFC6690]. This 168 specification makes use of the following additional terminology: 170 Interface Type: A resource attribute which describes the interface 171 exposed by the resource in terms of content formats, REST methods, 172 parameters, and other related characteristics. 174 Collection: A resource which contains set of related resources, 175 referenced by a list of links and optionally consisting of 176 subresources. 178 Resource Discovery: The process allowing a web client to identify 179 resources being hosted on a web server. 181 Gradual Reveal: A REST design where resources are discovered 182 progressively using Web Linking. 184 Function Set: A group of well-known REST resources that provides a 185 particular service. 187 Profile: A group of well-known Function Sets defined by a 188 specification. 190 Device: An IP smart object running a web server that hosts a group 191 of Function Set instances from a profile. 193 Service Discovery: The process making it possible for a web client 194 to automatically detect devices and Function Sets offered by these 195 devices on a CoRE network. 197 3. Interface Types 199 An Interface Type definition may describe a resource in terms of it's 200 associated content formats, data types, URI templates, REST methods, 201 parameters, and responses. 203 4. Collections 205 4.1. Introduction to Collections 207 A Collection is a resource which represents one or more related 208 resources. Within this document, a collection refers to a collection 209 with characteristics defined in this document. A Collection 210 Interface Type consists of a set of links and a set of items pointed 211 to by the links which may be sub-resources of the collection 212 resource. The collection types described in this document are Link 213 List, Batch and Linked Batch. 215 The links in a collection are represented in CoRE Link-Format 216 Content-Formats including JSON and CBOR variants, and the items in 217 the collection may be represented by senml, including JSON and CBOR 218 variants. In general, a collection may support items of any 219 available Content-Format. 221 A particular resource item may be a member of more than one 222 collection at a time by being linked to, but may only be a 223 subresource of one collection. 225 Some collections may have pre-configured items and links, and some 226 collections may support dynamic creation and removal of items and 227 links. Likewise, modification of items in some collections may be 228 permitted, and not in others. 230 Collections may support link embedding, which is analogous to an 231 image tag (link) causing the image to display inline in a browser 232 window. Resources pointed to by embedded links in collections may be 233 interacted with using bulk operations on the collection resource. 234 For example, performing a GET on a collection resource may return a 235 single representation containing all of the linked resources. 237 Links in collections may be selected for processing by a particular 238 request by using Query Filtering as described in CoRE Link-Format 239 [RFC6690]. 241 4.2. Use Cases for Collections 243 Collections may be used to provide gradual reveal of resources on an 244 endpoint. There may be a small set of links at the .well-known/core 245 location, which may in turn point to other collections of resources 246 that represent device information, device configuration, device 247 management, and various functional clusters of resources on the 248 device. 250 A collection may provide resource encapsulation, where link embedding 251 may be used to provide a single resource with which a client may 252 interact to obtain a set of related resource values. For example, a 253 collection for manufacturer parameters may consist of manufacturer 254 name, date of manufacture, location of manufacture, and serial number 255 resources which can be read as a single senml data object. 257 A collection may be used to group a set of like resources for bulk 258 state update or actuation. For example, the brightness control 259 resources of a number of luminaries may be grouped by linking to them 260 in a collection. The collection type may support receiving a single 261 update form a client and sending that update to each resource item in 262 the collection. 264 Items may be sub-resources of the collection resource. This enables 265 updates to to multiple items in the collection to be processed 266 together within the context of the collection resource. 268 4.3. Content-Formats for Collections 270 The collection interfaces by default use CoRE Link-Format for the 271 link representations and SenML or text/plain for representations of 272 items. The examples given are for collections that expose resources 273 and links in these formats. In addition, a new "collection" Content- 274 Format is defined based on the SenML framework which represents both 275 links and items in the collection. 277 The choice of whether to return a representation of the links or of 278 the items or of the collection format is determined by the accepts 279 header option in the request. Likewise, the choice of updating link 280 metadata or item data or the collection resource itself is determined 281 by the Content-Format option in the header of the update request 282 operation. 284 The default Content-Formats for collection types described in this 285 document are: 287 Links: application/link-format, application/link-format+json 288 Items: application/senml+json, text/plain 290 4.4. Links and Items in Collections 292 Links use CoRE Link-Format representation by default and may point to 293 any resource reachable from the context of the collection. This 294 includes absolute links and links that point to other network 295 locations if the context of the collection allows. Links to sub- 296 resources in the collection MUST have a path-element starting with 297 the resource name, as per RFC3986 [RFC3986]. Links to resources in 298 the global context MUST start with a root path identifier [RFC5988]. 299 Links to other collections are formed per RFC3986. 301 Examples of links: 303 ;if="core.lb" : Link to the /sen/ collection describing it as 304 a core.lb type collection (Linked Batch) 306 ;rel="grp" : Link to the /sen/ collection indicating that 307 /sen/ is a member of a group in the collection in which the link 308 appears. 310 <"/sen/temp">;rt="temperature" : An absolute link to the resource at 311 the path /sen/temp 313 ;rt="temperature" : Link to the temp subresource of the 314 collection in which this link appears. 316 ;anchor="/sen/" : A link to the temp subresource of the 317 collection /sen/ which is assumed not to be a subresource of the 318 collection in which the link appears ,but is expected to be 319 identified in the collection by resource name. 321 Links in the collection MAY be Read, Updated, Added, or Removed using 322 the CoRE Link-Format or JSON Merge-Patch Content-Formats on the 323 collection resource. Reading links uses the GET method and returns 324 an array or list containing the link-values of all selected links. 325 Links may be added to the collection using POST or PATCH methods. 326 Updates to links MUST use the PATCH method and MAY use query 327 filtering to select links for updating. The PATCH method on links 328 MUST use the JSON Merge-Patch Content-Format (application/merge- 329 patch+json) specified in RFC7396 [RFC7396]. 331 Items in the collection SHOULD be represented using the SenML 332 (application/senml+json) or plain text (text/plain) Content-Formats, 333 depending on whether the representation is of a single data point or 334 multiple data points. Items MAY be represented using any supported 335 Content-Format. 337 Link Embedding enables the bulk processing of items in the collection 338 using a single operation targeting the collection resource. A subset 339 of resources in the collection may be selected for operation using 340 Query Filtering. Bulk Read operations using GET return a SenML 341 representation of all selected resources. Bulk item Update 342 operations using PUT or POST apply the payload document to all 343 selected resource items in the collection, using either a Batch or 344 Group update policy. A Batch update is performed by applying the 345 resource values in the payload document to all resources in the 346 collection that match any resource name in the payload document. 347 Group updates are performed by applying the payload document to each 348 item in the collection. Group updates are indicated by the link 349 relation type rel="grp" in the link. 351 4.5. Queries on Collections 353 Collections MAY support query filtering as defined in CoRE Link- 354 Format [RFC6690]. Operations targeting either the links or the items 355 MAY select a subset of links and items in the collection by using 356 query filtering. The Content-Format specified in the request header 357 selects whether links or items are targeted by the operation. 359 4.6. Observing Collections 361 Resource Observation I-D.ietf-core-dynlink using CoAP [RFC7252] MAY 362 be supported on items in a collection. A subset of the conditional 363 observe parameters MAY be specified to apply. In most cases pmin and 364 pmax are useful. Resource observation on a collection's items 365 resource MAY report any changes of resource state in any item in the 366 collection. Observation Responses, or notifications, SHOULD provide 367 representations of the resources that have changed in SenML Content- 368 Format. Notifications MAY include multiple observations of a 369 particular resource, with SenML time stamps indicating the 370 observation times. 372 4.7. Collection Types 374 There are three collection types defined in this document: 376 +-----------------+---------+--------------------+ 377 | Collection Type | if= | Content-Formats | 378 +-----------------+---------+--------------------+ 379 | Link List | core.ll | link-format | 380 | Batch | core.b | link-format, senml | 381 | Linked Batch | core.lb | link-format, senml | 382 +-----------------+---------+--------------------+ 384 Each collection type MAY support a subset of the methods and 385 functions described above. For the first three collection types, the 386 methods and functions are defined in the corresponding Interface 387 Description. 389 5. Interface Descriptions 391 This section defines REST interfaces for Link List, Batch, Sensor, 392 Parameter and Actuator resources. Variants such as Linked Batch or 393 Read-Only Parameter are also presented. Each type is described along 394 with its Interface Description attribute value and valid methods. 395 These are defined for each interface in the table below. These 396 interfaces can support plain text and/or SenML Media types. 398 The if= column defines the Interface Description (if=) attribute 399 value to be used in the CoRE Link Format for a resource conforming to 400 that interface. When this value appears in the if= attribute of a 401 link, the resource MUST support the corresponding REST interface 402 described in this section. The resource MAY support additional 403 functionality, which is out of scope for this specification. 404 Although these interface descriptions are intended to be used with 405 the CoRE Link Format, they are applicable for use in any REST 406 interface definition. 408 The Methods column defines the methods supported by that interface, 409 which are described in more detail below. 411 +-----------------+---------+------------------+--------------------+ 412 | Interface | if= | Methods | Content-Formats | 413 +-----------------+---------+------------------+--------------------+ 414 | Link List | core.ll | GET | link-format | 415 | Batch | core.b | GET, PUT, POST | link-format, senml | 416 | Linked Batch | core.lb | GET, PUT, POST, | link-format, senml | 417 | | | DELETE | | 418 | Sensor | core.s | GET | link-format, | 419 | | | | text/plain | 420 | Parameter | core.p | GET, PUT | link-format, | 421 | | | | text/plain | 422 | Read-only | core.rp | GET | link-format, | 423 | Parameter | | | text/plain | 424 | Actuator | core.a | GET, PUT, POST | link-format, | 425 | | | | text/plain | 426 +-----------------+---------+------------------+--------------------+ 428 The following is an example of links in the CoRE Link Format using 429 these interface descriptions. The resource hierarchy is based on a 430 simple profile defined in Appendix A. These links are used in the 431 subsequent examples below. 433 Req: GET /.well-known/core 434 Res: 2.05 Content (application/link-format) 435 ;rt="simple.sen";if="core.b", 436 ;rt="simple.sen.lt";if="core.s", 437 ;rt="simple.sen.tmp";if="core.s";obs, 438 ;rt="simple.sen.hum";if="core.s", 439 ;rt="simple.act";if="core.b", 440 ;rt="simple.act.led";if="core.a", 441 ;rt="simple.act.led";if="core.a", 442 ;rt="simple.dev";if="core.ll", 443 ;if="core.lb", 445 5.1. Link List 447 The Link List interface is used to retrieve (GET) a list of resources 448 on a web server. The GET request SHOULD contain an Accept option 449 with the application/link-format content format; however if the 450 resource does not support any other form of GET methods the Accept 451 option MAY be elided. The Accept option SHOULD only include the 452 application/link-format content format. The request returns a list 453 of URI references with absolute paths to the resources as defined in 454 CoRE Link Format. This interface is typically used with a parent 455 resource to enumerate sub-resources but may be used to reference any 456 resource on a web server. 458 Link List is the base interface to provide gradual reveal of 459 resources on a CoRE web server, hence the root resource of a Function 460 Set SHOULD implement this interface or an extension of this 461 interface. 463 The following example interacts with a Link List /d containing 464 Parameter sub-resources /d/name, /d/model. 466 Req: GET /d/ (Accept:application/link-format) 467 Res: 2.05 Content (application/link-format) 468 ;rt="simple.dev.n";if="core.p", 469 ;rt="simple.dev.mdl";if="core.rp" 471 5.2. Batch 473 The Batch interface is used to manipulate a collection of sub- 474 resources at the same time. The Batch interface type supports the 475 same methods as its sub-resources, and can be used to read (GET), 476 update (PUT) or apply (POST) the values of those sub-resource with a 477 single resource representation. The sub-resources of a Batch MAY be 478 heterogeneous, a method used on the Batch only applies to sub- 479 resources that support it. For example Sensor interfaces do not 480 support PUT, and thus a PUT request to a Sensor member of that Batch 481 would be ignored. A batch requires the use of SenML Media types in 482 order to support multiple sub-resources. 484 In addition, The Batch interface is an extension of the Link List 485 interface and in consequence MUST support the same methods. 487 The following example interacts with a Batch /s/ with Sensor sub- 488 resources /s/light, /s/temp and /s/humidity. 490 Req: GET /s/ 491 Res: 2.05 Content (application/senml+json) 492 {"e":[ 493 { "n": "light", "v": 123, "u": "lx" }, 494 { "n": "temp", "v": 27.2, "u": "degC" }, 495 { "n": "humidity", "v": 80, "u": "%RH" }], 496 } 498 5.3. Linked Batch 500 The Linked Batch interface is an extension of the Batch interface. 501 Contrary to the basic Batch which is a collection statically defined 502 by the web server, a Linked Batch is dynamically controlled by a web 503 client. A Linked Batch resource has no sub-resources. Instead the 504 resources forming the batch are referenced using Web Linking 505 [RFC5988] and the CoRE Link Format [RFC6690]. A request with a POST 506 method and a content format of application/link-format simply appends 507 new resource links to the collection. The links in the payload MUST 508 reference a resource on the web server with an absolute path. A 509 DELETE request removes the entire collection. All other requests 510 available for a basic Batch are still valid for a Linked Batch. 512 The following example interacts with a Linked Batch /l/ and creates a 513 collection containing /s/light, /s/temp and /s/humidity in 2 steps. 515 Req: POST /l/ (Content-Format: application/link-format) 516 , 517 Res: 2.04 Changed 519 Req: GET /l/ 520 Res: 2.05 Content (application/senml+json) 521 {"e":[ 522 { "n": "/s/light", "v": 123, "u": "lx" }, 523 { "n": "/s/temp", "v": 27.2, "u": "degC" }, 524 } 526 Req: POST /l/ (Content-Format: application/link-format) 527 528 Res: 2.04 Changed 530 Req: GET /l/ (Accept: application/link-format) 531 Res: 2.05 Content (application/link-format) 532 ,, 534 Req: GET /l/ 535 Res: 2.05 Content (application/senml+json) 536 {"e":[ 537 { "n": "/s/light", "v": 123, "u": "lx" }, 538 { "n": "/s/temp", "v": 27.2, "u": "degC" }, 539 { "n": "/s/humidity", "v": 80, "u": "%RH" }], 540 } 542 Req: DELETE /l/ 543 Res: 2.02 Deleted 545 5.4. Sensor 547 The Sensor interface allows the value of a sensor resource to be read 548 (GET). The Media type of the resource can be either plain text or 549 SenML. Plain text MAY be used for a single measurement that does not 550 require meta-data. For a measurement with meta-data such as a unit 551 or time stamp, SenML SHOULD be used. A resource with this interface 552 MAY use SenML to return multiple measurements in the same 553 representation, for example a list of recent measurements. 555 The following are examples of Sensor interface requests in both text/ 556 plain and application/senml+json. 558 Req: GET /s/humidity (Accept: text/plain) 559 Res: 2.05 Content (text/plain) 560 80 562 Req: GET /s/humidity (Accept: application/senml+json) 563 Res: 2.05 Content (application/senml+json) 564 {"e":[ 565 { "n": "humidity", "v": 80, "u": "%RH" }], 566 } 568 5.5. Parameter 570 The Parameter interface allows configurable parameters and other 571 information to be modeled as a resource. The value of the parameter 572 can be read (GET) or update (PUT). Plain text or SenML Media types 573 MAY be returned from this type of interface. 575 The following example shows request for reading and updating a 576 parameter. 578 Req: GET /d/name 579 Res: 2.05 Content (text/plain) 580 node5 582 Req: PUT /d/name (text/plain) 583 outdoor 584 Res: 2.04 Changed 586 5.6. Read-only Parameter 588 The Read-only Parameter interface allows configuration parameters to 589 be read (GET) but not updated. Plain text or SenML Media types MAY 590 be returned from this type of interface. 592 The following example shows request for reading such a parameter. 594 Req: GET /d/model 595 Res: 2.05 Content (text/plain) 596 SuperNode200 598 5.7. Actuator 600 The Actuator interface is used by resources that model different 601 kinds of actuators (changing its value has an effect on its 602 environment). Examples of actuators include for example LEDs, 603 relays, motor controllers and light dimmers. The current value of 604 the actuator can be read (GET) or the actuator value can be updated 605 (PUT). In addition, this interface allows the use of POST to change 606 the state of an actuator, for example to toggle between its possible 607 values. Plain text or SenML Media types MAY be returned from this 608 type of interface. A resource with this interface MAY use SenML to 609 include multiple measurements in the same representation, for example 610 a list of recent actuator values or a list of values to updated. 612 The following example shows requests for reading, setting and 613 toggling an actuator (turning on a led). 615 Req: GET /a/1/led 616 Res: 2.05 Content (text/plain) 617 0 619 Req: PUT /a/1/led (text/plain) 620 1 621 Res: 2.04 Changed 623 Req: POST /a/1/led (text/plain) 624 Res: 2.04 Changed 626 Req: GET /a/1/led 627 Res: 2.05 Content (text/plain) 628 0 630 5.8. Future Interfaces 632 It is expected that further interface descriptions will be defined in 633 this and other specifications. 635 6. Function Sets and Profiles 637 This section defines how a set of REST resources can be created 638 called a function set. A Function Set is similar to a function block 639 in the sense that it consists of input, output and parameter 640 resources and contains internal logic. A Function Set can have a 641 subset of mandatory inputs, outputs and parameters to provide minimum 642 interoperability. It can also be extended with manufacturer/user- 643 specific resources. A device is composed of one or more Function Set 644 instances. 646 An example of function sets can be found from the CoRE Resource 647 Directory specification that defines REST interfaces for 648 registration, group and lookup [I-D.ietf-core-resource-directory]. 649 The OMA Lightweight M2M standard [REF] also defines a function set 650 structure called an Objects that use integer path, instance and 651 resource URI segments. OMA Objects can be defined and then 652 registered with an OMA maintained registry [REF]. This section is 653 simply meant as a guideline for the definition of other such REST 654 interfaces, either custom or part of other specifications. 656 6.1. Defining a Function Set 658 In a Function Set, types of resources are defined. Each type 659 includes a human readable name, a path template, a Resource Type for 660 discovery, the Interface Definition and the data type and allowed 661 values. A Function Set definition may also include a field 662 indicating if a sub-resource is mandatory or optional. 664 6.1.1. Path template 666 A Function Set is a container resource under which its sub-resources 667 are organized. The profile defines the path to each resource of a 668 Function Set in a path template. The template can contain either 669 relative paths or absolute paths depending on the profile needs. An 670 absolute Function Set should be located at its recommended root path 671 on a web server, however it can be located under an alternative path 672 if necessary (for example multi-purpose devices, gateways etc.). A 673 relative Function Set can be instantiated as many times as needed on 674 a web server with an arbitrary root path. However some Function Sets 675 (e.g. device description) only make sense as singletons. 677 The path template includes a possible index {#} parameter, and 678 possible fixed path segments. The index {#} allows for multiple 679 instances of this type of resource, and can be any string. The root 680 path and the indexes are the only variable elements in a path 681 template. All other path segments should be fixed. 683 6.1.2. Resource Type 685 Each root resource of a Function Set is assigned a Resource Type 686 parameter, therefore making it possible to discover it. Each sub- 687 resource of a Function Set is also assigned a Resource Type 688 parameter. This Resource Type is used for resource discovery and is 689 usually necessary to discover optional resources supported on a 690 specific device. The Resource Type of a Function Set may also be 691 used for service discovery and can be exported to DNS-SD [RFC6763] 692 for example. 694 The Resource Type parameter defines the value that should be included 695 in the rt= field of the CoRE Link Format when describing a link to 696 this resource. The value SHOULD be in the form "namespace.type" for 697 root resources and "namespace.type.subtype" for sub-resources. This 698 naming convention facilitates resource type filtering with the 699 /.well-known/core resource. However a profile could allow mixing in 700 foreign namespace references within a Function Set to import external 701 references from other object models (e.g. SenML and UCUM). 703 6.1.3. Interface Description 705 The Interface Description parameter defines the REST interface for 706 that type of resource. Several base interfaces are defined in 707 Section 5 of this document. For a given profile, the Interface 708 Description may be inferred from the Resource Type. In that case the 709 Interface Description MAY be elided from link descriptions of 710 resource types defined in the profile, but should be included for 711 custom extensions to the profile. 713 The root resource of a Function Set should provide a list of links to 714 its sub-resources in order to offer gradual reveal of resources. The 715 CoRE Link List interface defined in Section 5.1 offers this 716 functionality so a root resource should support this interface or a 717 derived interface like CoRE Batch (See Section 5.2). 719 6.1.4. Data type 721 The Data Type field defines the type of value (and possible range) 722 that is returned in response to a GET for that resource or accepted 723 with a PUT. The interfaces defined in Section 5 make use of plain 724 text and SenML Media types for the actual format of this data. A 725 profile may restrict the list of supported content formats for the 726 CoRE interfaces or define new interfaces with new content types. 728 6.2. Discovery 730 A device conforming to a profile SHOULD make its resources 731 discoverable by providing links to the resources on the path /.well- 732 known/core as defined in [RFC6690]. All resources hosted on a device 733 SHOULD be discoverable either with a direct link in /.well-known/core 734 or by following successive links starting from /.well-known/core. 736 The root path of a Function Set instance SHOULD be directly 737 referenced in /.well-known/core in order to offer discovery at the 738 first discovery stage. A device with more than 10 individual 739 resources SHOULD only expose Function Set instances in /.well-known/ 740 core to limit the size of this resource. 742 In addition, a device MAY register its resources to a Resource 743 Directory using the registration interface defined in 744 [I-D.ietf-core-resource-directory] if such a directory is available. 746 6.3. Versioning 748 A profile should track Function Set changes to avoid incompatibility 749 issues. Evolutions in a Function Set SHOULD be backward compatible. 751 7. Security Considerations 753 An implementation of a client needs to be prepared to deal with 754 responses to a request that differ from what is specified in this 755 document. A server implementing what the client thinks is a resource 756 with one of these interface descriptions could return malformed 757 representations and response codes either by accident or maliciously. 758 A server sending maliciously malformed responses could attempt to 759 take advantage of a poorly implemented client for example to crash 760 the node or perform denial of service. 762 8. IANA Considerations 764 The interface description types defined require registration. 766 The new link relations type "grp" requires registration. 768 9. Acknowledgments 770 Acknowledgement is given to colleagues from the SENSEI project who 771 were critical in the initial development of the well-known REST 772 interface concept, to members of the IPSO Alliance where further 773 requirements for interface types have been discussed, and to Szymon 774 Sasin, Cedric Chauvenet, Daniel Gavelle and Carsten Bormann who have 775 provided useful discussion and input to the concepts in this 776 document. 778 10. Changelog 780 Changes from -04 to -05 782 o Removed Link Bindings and Observe attributes. This functionality 783 is now contained in I-D.ietf-core-dynlink. 785 o Hypermedia collections have been removed. This is covered in a 786 new T2TRG draft. 788 o The WADL description has been removed. 790 o Fixed minor typos. 792 o Updated references. 794 Changes from -03 to -04 796 o Fixed tickets #385 and #386. 798 o Changed abstract and into to better describe content. 800 o Focus on Interface and not function set/profiles in intro. 802 o Changed references from draft-core-observe to RFC7641. 804 o Moved Function sets and Profiles to section after Interfaces. 806 o Moved Observe Attributes to the Link Binding section. 808 o Add a Collection section to describe the collection types. 810 o Add the Hypermedia Collection Interface Description. 812 Changes from -02 to -03 814 o Added lt and gt to binding format section. 816 o Added pmin and pmax observe parameters to Observation Attributes. 818 o Changed the definition of lt and gt to limit crossing. 820 o Added definitions for getattr and setattr to WADL. 822 o Added getattr and setattr to observable interfaces. 824 o Removed query parameters from Observe definition. 826 o Added observe-cancel definition to WADL and to observable 827 interfaces. 829 Changes from -01 to -02 831 o Updated the date and version, fixed references. 833 o Removed pmin and pmax observe parameters [Ticket #336] 835 Changes from -00 to WG Document -01 836 o Improvements to the Function Set section. 838 Changes from -05 to WG Document -00 840 o Updated the date and version. 842 Changes from -04 to -05 844 o Made the Observation control parameters to be treated as resources 845 rather than Observe query parameters. Added Less Than and Greater 846 Than parameters. 848 Changes from -03 to -04 850 o Draft refresh 852 Changes from -02 to -03 854 o Added Bindings 856 o Updated all rt= and if= for the new Link Format IANA rules 858 Changes from -01 to -02 860 o Defined a Function Set and its guidelines. 862 o Added the Link List interface. 864 o Added the Linked Batch interface. 866 o Improved the WADL interface definition. 868 o Added a simple profile example. 870 11. References 872 11.1. Normative References 874 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 875 Requirement Levels", BCP 14, RFC 2119, 876 DOI 10.17487/RFC2119, March 1997, 877 . 879 [RFC5988] Nottingham, M., "Web Linking", RFC 5988, 880 DOI 10.17487/RFC5988, October 2010, 881 . 883 [RFC6690] Shelby, Z., "Constrained RESTful Environments (CoRE) Link 884 Format", RFC 6690, DOI 10.17487/RFC6690, August 2012, 885 . 887 11.2. Informative References 889 [I-D.ietf-core-resource-directory] 890 Shelby, Z., Koster, M., Bormann, C., and P. Stok, "CoRE 891 Resource Directory", draft-ietf-core-resource-directory-07 892 (work in progress), March 2016. 894 [I-D.ietf-core-senml] 895 Jennings, C., Shelby, Z., Arkko, J., and A. 896 KerĂ[currency units]nen, "Media Types for Sensor 897 Markup Language (SenML)", draft-ietf-core-senml-00 (work 898 in progress), April 2016. 900 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 901 Resource Identifier (URI): Generic Syntax", STD 66, 902 RFC 3986, DOI 10.17487/RFC3986, January 2005, 903 . 905 [RFC6763] Cheshire, S. and M. Krochmal, "DNS-Based Service 906 Discovery", RFC 6763, DOI 10.17487/RFC6763, February 2013, 907 . 909 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 910 Application Protocol (CoAP)", RFC 7252, 911 DOI 10.17487/RFC7252, June 2014, 912 . 914 [RFC7396] Hoffman, P. and J. Snell, "JSON Merge Patch", RFC 7396, 915 DOI 10.17487/RFC7396, October 2014, 916 . 918 Appendix A. Profile example 920 The following is a short definition of simple profile. This 921 simplistic profile is for use in the examples of this document. 923 +--------------------+-----------+------------+---------+ 924 | Function Set | Root Path | RT | IF | 925 +--------------------+-----------+------------+---------+ 926 | Device Description | /d | simple.dev | core.ll | 927 | Sensors | /s | simple.sen | core.b | 928 | Actuators | /a | simple.act | core.b | 929 +--------------------+-----------+------------+---------+ 931 List of Function Sets 933 +-------+----------+----------------+---------+------------+ 934 | Type | Path | RT | IF | Data Type | 935 +-------+----------+----------------+---------+------------+ 936 | Name | /d/name | simple.dev.n | core.p | xsd:string | 937 | Model | /d/model | simple.dev.mdl | core.rp | xsd:string | 938 +-------+----------+----------------+---------+------------+ 940 Device Description Function Set 942 +-------------+-------------+----------------+--------+-------------+ 943 | Type | Path | RT | IF | Data Type | 944 +-------------+-------------+----------------+--------+-------------+ 945 | Light | /s/light | simple.sen.lt | core.s | xsd:decimal | 946 | | | | | (lux) | 947 | Humidity | /s/humidity | simple.sen.hum | core.s | xsd:decimal | 948 | | | | | (%RH) | 949 | Temperature | /s/temp | simple.sen.tmp | core.s | xsd:decimal | 950 | | | | | (degC) | 951 +-------------+-------------+----------------+--------+-------------+ 953 Sensors Function Set 955 +------+------------+----------------+--------+-------------+ 956 | Type | Path | RT | IF | Data Type | 957 +------+------------+----------------+--------+-------------+ 958 | LED | /a/{#}/led | simple.act.led | core.a | xsd:boolean | 959 +------+------------+----------------+--------+-------------+ 961 Actuators Function Set 963 Authors' Addresses 964 Zach Shelby 965 ARM 966 150 Rose Orchard 967 San Jose 95134 968 FINLAND 970 Phone: +1-408-203-9434 971 Email: zach.shelby@arm.com 973 Matthieu Vial 974 Schneider-Electric 975 Grenoble 976 FRANCE 978 Phone: +33 (0)47657 6522 979 Email: matthieu.vial@schneider-electric.com 981 Michael Koster 982 SmartThings 983 665 Clyde Avenue 984 Mountain View 94043 985 USA 987 Email: michael.koster@smartthings.com 989 Christian Groves 990 Huawei 991 Australia 993 Email: Christian.Groves@nteczone.com