<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="3"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="std" docName="draft-ietf-netconf-restconf-notif-09"
     ipr="trust200902">

  <front>
    <title abbrev="RESTCONF-Notif">Dynamic subscription to YANG Events and Datastores over RESTCONF</title>

    <author fullname="Eric Voit" initials="E." surname="Voit">
      <organization>Cisco Systems</organization>

      <address>
        <email>evoit@cisco.com</email>
      </address>
    </author>

        <author fullname="Reshad Rahman" initials="R"
            surname="Rahman">
      <organization>Cisco Systems</organization>
      <address>
         <email>rrahman@cisco.com</email>
      </address>
    </author>
 
    <author fullname="Einar Nilsen-Nygaard" initials="E"
            surname="Nilsen-Nygaard">
      <organization>Cisco Systems</organization>
      <address>
         <email>einarnn@cisco.com</email>
      </address>
    </author>

    <author fullname="Alexander Clemm" initials="A" surname="Clemm">
        <organization>Huawei</organization>
        <address>
            <email>ludwig@clemm.org</email>
        </address>
    </author>

    <author fullname="Andy Bierman" initials="A"
            surname="Bierman">
      <organization>YumaWorks</organization>
      <address>
         <email>andy@yumaworks.com</email>
      </address>
    </author>

    <date day="19" month="October" year="2018"/>

    <area>Operations &amp; Management</area>

    <workgroup>NETCONF</workgroup>

    <keyword>Draft</keyword>

    <abstract>
        <t>This document provides a RESTCONF binding to the dynamic subscription capability of both subscribed notifications and YANG-Push.</t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>Mechanisms to support event subscription and push are defined in <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/>. Enhancements to <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/> which enable YANG datastore subscription and push are defined in <xref target="I-D.ietf-netconf-yang-push"/>. This document provides a transport specification for dynamic subscriptions over RESTCONF <xref target="RFC8040"/>.  Driving these requirements is <xref target="RFC7923"/>.</t>

      <t>The streaming of notifications encapsulating the resulting information push is done via the mechanism described in section 6.3 of <xref target="RFC8040"/>.  </t>

    </section>

    <section 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">RFC 2119</xref>.</t>

      <t>The following terms use the definitions from <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/>: dynamic subscription, event stream, notification message, publisher, receiver, subscriber, and subscription.</t>

      <t>Other terms reused include datastore, which is defined in <xref target="RFC8342"/>, and HTTP2 stream which maps to the definition of "stream" within <xref target="RFC7540"/>, Section 2.</t>

      <t>[ note to the RFC Editor - please replace XXXX within this document with the number of this document ]</t>


    </section>


    <section anchor="dyn-subs" title="Dynamic Subscriptions">

      <t>This section provides specifics on how to establish and maintain dynamic subscriptions over RESTCONF <xref target="RFC8040"/>. Subscribing to event streams is accomplished in this way via RPCs defined within <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/> Section 2.4, the RPCs are done via RESTCONF POSTs. YANG datastore subscription is accomplished via augmentations to <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/> as described within <xref target="I-D.ietf-netconf-yang-push"/> Section 4.4.</t>

      <t>As described in <xref target="RFC8040"/> Section 6.3, a GET needs to be made against a specific URI on the publisher. Subscribers cannot pre-determine the URI against which a subscription might exist on a publisher, as the URI will only exist after the "establish-subscription" RPC has been accepted. Therefore, the POST for the "establish-subscription" RPC replaces the GET request for the "location" leaf which is used in <xref target="RFC8040"/> to obtain the URI. The subscription URI will be determined and sent as part of the response to the "establish-subscription" RPC, and a subsequent GET to this URI will be done in order to start the flow of notification messages back to the subscriber.  A subscription does not move to the active state as per Section 2.4.1. of <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/> until the GET is received. </t>

      <section title="Transport Connectivity">

        <t>For a dynamic subscription, where a RESTCONF session doesn't already exist, a new RESTCONF session is initiated from the subscriber.</t>

        <t>As stated in Section 2.1 of <xref target="RFC8040"/>, a subscriber MUST establish the HTTP session over TLS <xref target="RFC5246"/> in order to secure the content in transit.</t>

        <t>Without the involvement of additional protocols, HTTP sessions by themselves do not allow for a quick recognition of when the communication path has been lost with the publisher.  Where quick recognition of the loss of a publisher is required, a subscriber SHOULD use a TLS heartbeat <xref target="RFC6520"/>, just from receiver to publisher, to track HTTP session continuity.</t>
        <t>Loss of the heartbeat MUST result in any subscription related TCP sessions between those endpoints being torn down.  A subscriber can then attempt to re-establish the dynamic subscription by using the procedure described in <xref target="dyn-subs"/>.</t>

      </section>

      <section title="Discovery">

        <t>Subscribers can learn what event streams a RESTCONF server supports by querying the "streams" container of ietf-subscribed-notification.yang in <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/>. Support for the "streams" container of ietf-restconf-monitoring.yang in <xref target="RFC8040"/> is not required.</t>
        <t>Subscribers can learn what datastores a RESTCONF server supports by following <xref target="I-D.draft-ietf-netconf-nmda-restconf"/>. </t>

      </section>

      <section title="RESTCONF RPCs and HTTP Status Codes">

        <t>Specific HTTP responses codes as defined in <xref target="RFC7231"/> section 6 will indicate the result of RESTCONF RPC requests with publisher.  An HTTP status code of 200 is the proper response to any successful RPC defined within <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/> or <xref target="I-D.ietf-netconf-yang-push"/>.</t>

        <t>If a publisher fails to serve the RPC request for one of the reasons indicated in <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/> Section 2.4.6 or <xref target="I-D.ietf-netconf-yang-push"/> Appendix A, this will be indicated by "406" status code transported in the HTTP response.</t>

        <t>When a "406" status code is returned, the RPC reply MUST include an "rpc-error" element per <xref target="RFC8040"/> Section 7.1 with the following parameter values:
        <list style="symbols">
          <t>an "error-type" node of "application".</t>

          <t>an "error-tag" node of "operation-failed".</t>

          <t>an "error-app-tag" node with the value being a string that corresponds to an identity associated with the error, as defined in <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/> section 2.4.6 for general subscriptions, and <xref target="I-D.ietf-netconf-yang-push"/> Appendix A.1, for datastore subscriptions. The tag to use depends on the RPC for which the error occurred.  Viable errors for different RPCs are as follows:</t>

        </list></t>

        <figure align="left">
            <artwork><![CDATA[
         RPC                     select an identity with a base
         ----------------------  ------------------------------
         establish-subscription  establish-subscription-error
         modify-subscription     modify-subscription-error
         delete-subscription     delete-subscription-error
         kill-subscription       kill-subscription-error
         resynch-subscription    resynch-subscription-error
              ]]></artwork>
        </figure>

        <t>Each error identity will be inserted as the "error-app-tag" using JSON encoding following the form &lt;modulename&gt;:&lt;identityname&gt;.  An example of such as valid encoding would be "ietf-subscribed-notifications:no-such-subscription".</t>

        <t>In case of error responses to an "establish-subscription" or "modify-subscription" request there is the option of including an "error-info" node.  This node may contain hints for parameter settings that might lead to successful RPC requests in the future.   Following are the yang-data structures which may be returned:</t>

        <figure align="left">
          <artwork><![CDATA[
      establish-subscription returns hints in yang-data structure
      ---------------------- ------------------------------------
      target: event stream   establish-subscription-stream-error-info
      target: datastore      establish-subscription-datastore-error-info

      modify-subscription    returns hints in yang-data structure
      ---------------------- ------------------------------------
      target: event stream   modify-subscription-stream-error-info
      target: datastore      modify-subscription-datastore-error-info

      The yang-data included within "error-info" SHOULD NOT include the
      optional leaf "error-reason", as such a leaf would be redundant
      with information that is already placed within the
      "error-app-tag".

      In case of an rpc error as a result of a "delete-subscription", a
      "kill-subscription", or a "resynch-subscription" request, no
      "error-info" needs to be included, as the "subscription-id" is
      the only RPC input parameter and no hints regarding this RPC input
      parameters need to be provided.
            ]]></artwork>
        </figure>

        <t>Note that "error-path" <xref target="RFC8040"/> does not need to be included with the "rpc-error" element, as subscription errors are generally associated with the choice of RPC input parameters. </t>

      </section>

      <section title="Call Flow for Server-Sent Events (SSE)">
        <t>The call flow is defined in <xref target="dyn-sse"/>.  The logical connections denoted by (a) and (b) can be a TCP connection or an HTTP2 stream (multiple HTTP2 streams can be carried in one TCP connection). Requests to <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/> or <xref target="I-D.ietf-netconf-yang-push"/> augmented RPCs are sent on a connection indicated by (a).  A successful "establish-subscription" will result in an RPC response returned with both a subscription identifier which uniquely identifies a subscription, as well as a URI which uniquely identifies the location of subscription on the publisher (b). This URI is defined via the "uri" leaf the Data Model in <xref target="YANG-module"/>. </t>

        <t>An HTTP GET is then sent on a separate logical connection (b) to the URI on the publisher.  This initiates the publisher to initiate the flow of notification messages which are sent in SSE <xref target="W3C-20150203"/> as a response to the GET.</t>

        <figure title="Dynamic with server-sent events"
                anchor="dyn-sse"
                align="center">
          <artwork height="29" xml:space="preserve"><![CDATA[
+--------------+                             +--------------+
|  Subscriber  |                             |   Publisher  |
|              |                             |              |
|    Logical   |                             |     Logical  |
|  Connection  |                             |   Connection |
|  (a)  (b)    |                             |    (a)  (b)  |
+--------------+                             +--------------+
    | RESTCONF POST (RPC:establish-subscription)   |
    |--------------------------------------------->|
    |                          HTTP 200 OK (ID,URI)|
    |<---------------------------------------------|
    |    |HTTP GET (URI)                                |
    |    |--------------------------------------------->|
    |    |                                   HTTP 200 OK|
    |    |<---------------------------------------------|
    |    |                           SSE (notif-message)|
    |    |<---------------------------------------------|
    | RESTCONF POST (RPC:modify-subscription)      |    |
    |--------------------------------------------->|    |
    |    |                              HTTP 200 OK|    |
    |<---------------------------------------------|    |
    |    |                   SSE (subscription-modified)|
    |    |<------------------------------------------(c)|
    |    |                           SSE (notif-message)|
    |    |<---------------------------------------------|
    | RESTCONF POST (RPC:delete-subscription)      |    |
    |--------------------------------------------->|    |
    |    |                              HTTP 200 OK|    |
    |<---------------------------------------------|    |
    |    |                                              |
    |    |]]></artwork>
        </figure>

        <t>Additional requirements for dynamic subscriptions over SSE include:</t>
        <t><list style="symbols">
          <t>All subscription state notifications from a publisher MUST be returned in a separate SSE message used by the subscription to which the state change refers.</t>
          <t>Subscription RPCs MUST NOT use the connection currently providing notification messages for that subscription.</t>
          <t>In addition to an RPC response for a "modify-subscription" RPC traveling over (a), a "subscription-modified" state change notification must be sent within (b).  This allows the receiver to know exactly when the new terms of the subscription have been applied to the notification messages.  See arrow (c).</t>
        </list></t>
        <t>A publisher MUST terminate a subscription in the following cases:</t>
        <t><list style="symbols">
          <t>Receipt of a "delete-subscription" or a "kill-subscription" RPC for that subscription.</t>
          <t>Loss of TLS heartbeat</t>
        </list></t>
        <t>A publisher MAY terminate a subscription at any time as stated in <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/> Section 1.3 </t>
      </section>

    </section>

    <section title="QoS Treatment">

      <t>To meet subscription quality of service promises, the publisher MUST take any existing subscription "dscp" and apply it to the DSCP marking in the IP header.</t>

      <t>In addition, where HTTP2 transport is available to a notification message queued for transport to a receiver, the publisher MUST:</t>

      <t><list style="symbols">
        <t>take any existing subscription "priority", as specified by the "dscp" leaf node in <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/>, and copy it into the HTTP2 stream priority, <xref target="RFC7540"/> section 5.3, and </t>

        <t>take any existing subscription "dependency", as specified by the "dependency" leaf node in <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/>,  and use the HTTP2 stream for the parent subscription as the HTTP2 stream dependency, <xref target="RFC7540"/> section 5.3.1, of the dependent subscription.</t>

      </list></t>

    </section>

    <section title="Notification Messages">
      <t>Notification messages transported over RESTCONF will be encoded according to <xref target="RFC8040"/>, section 6.4.</t>
    </section>

    <section title="YANG Tree" anchor="YANG-tree" >

      <t> The YANG model defined in <xref target="YANG-module"/> has one leaf augmented into four places of <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/>, plus two identities.  As the resulting full tree is large, it will only be inserted at later stages of this document.</t>

    </section>

    <section title="YANG module" anchor="YANG-module" >

      <t>This module references <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/>.</t>

      <figure>
         <artwork><![CDATA[
<CODE BEGINS> file "ietf-restconf-subscribed-notifications@2018-10-19.yang"
module ietf-restconf-subscribed-notifications {
  yang-version 1.1;
  namespace
    "urn:ietf:params:xml:ns:yang:ietf-restconf-subscribed-notifications";

  prefix rsn;

  import ietf-subscribed-notifications {
    prefix sn;
  }
  import ietf-inet-types {
    prefix inet;
  }

  organization "IETF NETCONF (Network Configuration) Working Group";
  contact
    "WG Web:   <http:/tools.ietf.org/wg/netconf/>
     WG List:  <mailto:netconf@ietf.org>

     Editor:   Eric Voit
               <mailto:evoit@cisco.com>

     Editor:   Alexander Clemm
               <mailto:ludwig@clemm.org>

     Editor:   Reshad Rahman
               <mailto:rrahman@cisco.com>";

  description
    "Defines RESTCONF as a supported transport for subscribed
    event notifications.

    Copyright (c) 2018 IETF Trust and the persons identified as authors
    of the code.  All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, is permitted pursuant to, and subject to the license
    terms contained in, the Simplified BSD License set forth in Section
    4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
    (https://trustee.ietf.org/license-info).

    This version of this YANG module is part of RFC XXXX; see the RFC
    itself for full legal notices.";

  revision 2018-10-19 {
    description
      "Initial version";
    reference
      "RFC XXXX: RESTCONF Transport for Event Notifications";
  }
  
  grouping uri {
    description
      "Provides a reusable description of a URI.";
    leaf uri {
      type inet:uri;
      config false;
      description
        "Location of a subscription specific URI on the publisher.";
    }
  }

  augment "/sn:establish-subscription/sn:output" {
    description
      "This augmentation allows RESTCONF specific parameters for a
       response to a publisher's subscription request.";
    uses uri;
  }

  augment "/sn:subscriptions/sn:subscription" {
    description
      "This augmentation allows RESTCONF specific parameters to be
       exposed for a subscription.";
    uses uri;
  }

  augment "/sn:subscription-modified" {
    description
      "This augmentation allows RESTCONF specific parameters to be included
       part of the notification that a subscription has been modified.";
    uses uri;
  }
}
<CODE ENDS>
              ]]></artwork>
          </figure>
    </section>

    <section title="IANA Considerations">
      <t>
      This document registers the following namespace URI in the "IETF XML Registry" <xref target="RFC3688"/>:
      </t>

      <t>
      URI:
      urn:ietf:params:xml:ns:yang:ietf-restconf-subscribed-notifications
      <vspace/>
      Registrant Contact: The IESG.
      <vspace/>
      XML: N/A; the requested URI is an XML namespace.
      </t>

      <t>
      This document registers the following YANG module in the "YANG Module Names" registry <xref target="RFC6020"/>:
      </t>

      <t>
      Name:         ietf-restconf-subscribed-notifications
      <vspace/>
      Namespace:
      urn:ietf:params:xml:ns:yang:ietf-restconf-subscribed-notifications
      <vspace/>
      Prefix:       rsn
      <vspace/>
      Reference: RFC XXXX: RESTCONF Transport for Event Notifications
      </t>
    </section>

    <section title="Security Considerations">

      <t>The YANG module specified in this document defines a schema for data that is designed to be accessed via network management transports such as NETCONF <xref target="RFC6241"/> or RESTCONF <xref target="RFC8040"/>.  The lowest NETCONF layer is the secure transport layer, and the mandatory-to-implement secure transport is Secure Shell (SSH) <xref target="RFC6242"/>.  The lowest RESTCONF layer is HTTPS, and the mandatory-to-implement secure transport is TLS <xref target="RFC5246"/>.</t>

      <t>The one new data node introduced in this YANG module may be considered sensitive or vulnerable in some network environments.  It is thus important to control read access (e.g., via get, get-config, or notification) to this data nodes.  These are the subtrees and data nodes and their sensitivity/vulnerability:</t>

      <t>Container: "/subscriptions"</t>
      <t><list style="symbols">
        <t>"uri": leaf will show where subscribed resources might be located on a publisher.  Access control must be set so that only someone with proper access permissions, and perhaps even HTTP session has the ability to access this resource.</t>
      </list></t>
    </section>

    <section title="Acknowledgments">
      <t>We wish to acknowledge the helpful contributions, comments, and suggestions that were received from: Ambika Prasad Tripathy, Alberto Gonzalez Prieto, Susan Hares, Tim Jenkins, Balazs Lengyel, Kent Watsen, Michael Scharf, Guangying Zheng, Martin Bjorklund and Qin Wu.</t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119"?>
      <?rfc include="reference.RFC.3688"?>
      <?rfc include="reference.RFC.5246"?>
      <?rfc include="reference.RFC.5277"?>
      <?rfc include="reference.RFC.6020"?>
      <?rfc include="reference.RFC.6241"?>
      <?rfc include="reference.RFC.6242"?>
      <?rfc include="reference.RFC.6520"?>
      <?rfc include="reference.RFC.7230"?>
      <?rfc include="reference.RFC.7540"?>
      <?rfc include="reference.RFC.8040"?>
      <?rfc include="reference.RFC.8342"?>

      <reference anchor="I-D.draft-ietf-netconf-subscribed-notifications">
        <front>
          <title>Custom Subscription to Event Streams</title>
          <author fullname="Eric Voit" initials="E" surname="Voit">
            <organization/>
          </author>
          <author fullname="Alexander Clemm" initials="A" surname="Clemm">
            <organization/>
          </author>
          <author fullname="Alberto Gonzalez Prieto" initials="A"
                  surname="Gonzalez Prieto">
            <organization/>
          </author>
          <author fullname="Ambika Prasad Tripathy" initials="A"
                  surname="Tripathy">
            <organization/>
          </author>
          <author fullname="Einar Nilsen-Nygaard" initials="E"
                  surname="Nilsen-Nygaard">
            <organization/>
          </author>
          <date month="April" year="2018"/>
        </front>
        <seriesInfo name="Internet-Draft" value="draft-ietf-netconf-subscribed-notifications-13"/>
        <format target="https://datatracker.ietf.org/doc/draft-ietf-netconf-subscribed-notifications/"
                type="TXT"/>
      </reference>

      <reference anchor="I-D.ietf-netconf-yang-push"
                 target="https://datatracker.ietf.org/doc/draft-ietf-netconf-yang-push/">
        <front>
          <title>Subscribing to YANG datastore push updates</title>

          <author fullname="Alexander Clemm" initials="A" surname="Clemm">
            <organization>Huawei</organization>
          </author>

          <author fullname="Eric Voit" initials="E" surname="Voit">
            <organization>Cisco</organization>
          </author>

          <author fullname="Alberto Gonzalez Prieto" initials="A"
                  surname="Gonzalez Prieto">
            <organization>VMWare</organization>
          </author>

          <author fullname="Ambika Prasad Tripathy" initials="A"
                  surname="Prasad Tripathy">
            <organization>Cisco</organization>
          </author>

          <author fullname="Einar Nilsen-Nygaard" initials="E"
                  surname="Nilsen-Nygaard">
            <organization>Cisco</organization>
          </author>

          <author fullname="Andy Bierman" initials="A"
                  surname="Bierman">
            <organization>YumaWorks</organization>
          </author>

          <author fullname="B Lengyel" initials="B"
                  surname="Lengyel">
            <organization>Ericsson</organization>
          </author>

          <date day="1" month="March" year="2017"/>
        </front>
      </reference>


      <reference anchor="W3C-20150203"
                 target="https://www.w3.org/TR/2015/REC-eventsource-20150203/">
        <front>
          <title>Server-Sent Events, World Wide Web Consortium CR
          CR-eventsource-20121211</title>

          <author fullname="I Hickson">
            <organization/>
          </author>

          <date month="February" year="2015"/>
        </front>
      </reference>

    </references>

    <references title="Informative References">

      <?rfc include="reference.RFC.7231"?>
      <?rfc include="reference.RFC.7923"?>
      <?rfc include="reference.RFC.8347"?>
      <reference anchor="I-D.draft-ietf-netconf-nmda-restconf"
                 target="https://datatracker.ietf.org/doc/draft-ietf-netconf-nmda-restconf/">
        <front>
          <title>RESTCONF Extensions to Support the Network Management Datastore Architecture</title>

          <author fullname="Martin Bjorklund" initials="M" surname="Bjorklund"></author>
          <author fullname="Juergen Schoenwaelder" initials="J" surname="Schoenwaelder"></author>
          <author fullname="Phil Shafer" initials="P" surname="Shafer"></author>
          <author fullname="Kent Watsen" initials="K" surname="Watsen"></author>
          <author fullname="Rob Wilton" initials="R" surname="Wilton"></author>

          <date month="April" year="2018"/>
        </front>
      </reference>

      <reference anchor="I-D.draft-ietf-netconf-netconf-event-notifications"
                 target="https://datatracker.ietf.org/doc/draft-ietf-netconf-netconf-event-notifications/">
        <front>
          <title>NETCONF support for event notifications</title>
          <author fullname="A Clemm" initials="Alexander" surname="Clemm"></author>
          <author fullname="E Voit" initials="Eric" surname="Voit"></author>
          <author fullname="A Gonzalez Prieto" initials="Alberto" surname="Gonzalez Prieto"></author>
          <author fullname="Einar Nilsen-Nygaard" initials="E" surname="Nilsen-Nygaard"></author>
          <author fullname="Ambika Prasad Tripathy" initials="A" surname="Tripathy"></author>
          <date month="May" year="2018"/>
        </front>
      </reference>
      <reference anchor="XPATH"
                 target="http://www.w3.org/TR/1999/REC-xpath-19991116">
        <front>
          <title>XML Path Language (XPath) Version 1.0</title>
          <author fullname="J Clark" initials="J" surname="Clark"></author>
          <author fullname="S DeRose" initials="S" surname="DeRose"></author>
          <date month="November" year="1999"/>
        </front>
      </reference> 

    </references>

    <section title="Examples">

      <t>This section is non-normative.  To allow easy comparison, this section mirrors the functional examples shown with NETCONF over XML within <xref target="I-D.draft-ietf-netconf-netconf-event-notifications"/>.  In addition, HTTP2 vs HTTP1.1 headers are not shown as the contents of the JSON encoded objects are identical within.</t>

      <section title="Dynamic Subscriptions">


        <section title="Establishing Dynamic Subscriptions">

          <t>The following figure shows two successful "establish-subscription" RPC requests as per <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/>.  The first request is given a subscription identifier of 22, the second, an identifier of 23.</t>

          <figure anchor = "mess-flow-establishment"
          title="Multiple subscriptions over RESTCONF/HTTP">
            <artwork><![CDATA[
   +------------+                  +-----------+
   | Subscriber |                  | Publisher |
   +------------+                  +-----------+
         |                               |
         |establish-subscription         |
         |------------------------------>|  (a)
         |     HTTP 200 OK, id#22, URI#1 |
         |<------------------------------|  (b)
         |GET (URI#1)                    |
         |------------------------------>|  (c)
         | HTTP 200 OK,notif-mesg (id#22)|
         |<------------------------------|
         |                               |
         |                               |
         |establish-subscription         |
         |------------------------------>|
         |      HTTP 200 OK, id#23, URI#2|
         |<------------------------------|
         |GET (URI#2)                    |
         |------------------------------>|
         |                               |
         |                               |
         |             notif-mesg (id#22)|
         |<------------------------------|
         | HTTP 200 OK,notif-mesg (id#23)|
         |<------------------------------|
         |                               |
            ]]></artwork>
          </figure>

          <t>To provide examples of the information being transported, example messages for interactions in  <xref target="mess-flow-establishment"/> are detailed below:</t>

          <figure align="center" anchor="establish-subs" title="establish-subscription request (a)">
          <artwork><![CDATA[
POST /restconf/operations/ietf-subscribed-notifications:establish-subscription

{
   "ietf-subscribed-notifications:input": {
      "stream": "NETCONF",
      "stream-xpath-filter": "/example-module:foo/",
      "dscp": "10"
   }
}
              ]]></artwork>
          </figure>

          <t>As publisher was able to fully satisfy the request, the publisher sends the subscription identifier of the accepted subscription, and the URI:</t>

          <figure align="center" anchor="positive-establish-subs" title="establish-subscription success (b)">
            <artwork><![CDATA[
HTTP status code - 200

{
   "id": "22",
   "uri": "https://example.com/restconf/subscriptions/22"
}

             ]]></artwork>
          </figure>

          <t>Upon receipt of the successful response, the subscriber does a GET the provided URI to start the flow of notification messages.  When the publisher receives this, the subscription is moved to the active state (c).</t>

          <figure align="center" anchor="positive-establish-post" title="establish-subscription subsequent POST">
            <artwork><![CDATA[
GET /restconf/subscriptions/22

             ]]></artwork>
          </figure>

          <t>While not shown in <xref target="mess-flow-establishment"/>, if the publisher had not been able to fully satisfy the request, or subscriber has no authorization to establish the subscription, the publisher would have sent an RPC error response. For instance, if the "dscp" value of 10 asserted by the subscriber in <xref target="establish-subs"/> proved unacceptable, the publisher may have returned:</t>

          <figure align="center" anchor="negative-establish-subs" title="an unsuccessful establish subscription">
            <artwork><![CDATA[
      HTTP status code - 406

      { "ietf-restconf:errors" : {
          "error" : [
            {
              "error-type": "application",
              "error-tag": "operation-failed",
              "error-severity": "error",
              "error-app-tag":
                  "ietf-subscribed-notifications:dscp-unavailable"
            }
          ]
        }
      }

            ]]></artwork>
          </figure>

          <t>The subscriber can use this information in future attempts to establish a subscription.</t>

        </section>

        <section title="Modifying Dynamic Subscriptions">

          <t>An existing subscription may be modified.  The following exchange shows a negotiation of such a modification via several exchanges between a subscriber and a publisher.  This negotiation consists of a failed RPC modification request/response, followed by a successful one.</t>

          <figure anchor = "mess-flow-subs-modification"
                title="Interaction model for successful subscription modification">
            <artwork><![CDATA[
   +------------+                 +-----------+
   | Subscriber |                 | Publisher |
   +------------+                 +-----------+
         |                              |
         |  notification message (id#23)|
         |<-----------------------------|
         |                              |
         |modify-subscription (id#23)   |
         |----------------------------->|  (d)
         |    HTTP 406 error (with hint)|
         |<-----------------------------|  (e)
         |                              |
         |modify-subscription (id#23)   |
         |----------------------------->|
         |                  HTTP 200 OK |
         |<-----------------------------|
         |                              |
         |            notif-mesg (id#23)|
         |<-----------------------------|
         |                              |
            ]]></artwork>
          </figure>

          <t>If the subscription being modified in <xref target="mess-flow-subs-modification"/> is a datastore subscription as per <xref target="I-D.ietf-netconf-yang-push"/>, the modification request made in (d) may look like that shown in <xref target="simple-modify-subs"/>.  As can be seen, the modifications being attempted are the application of a new xpath filter as well as the setting of a new periodic time interval.</t>

          <figure align="center" anchor="simple-modify-subs" title="Subscription modification request (c)">
            <artwork><![CDATA[
POST /restconf/operations/ietf-subscribed-notifications:modify-subscription

{
 "ietf-subscribed-notifications:input": {
    "id": "23",
    "ietf-yang-push:datastore-xpath-filter": "/example-module:foo/example-module:bar",
    "ietf-yang-push:periodic": {
       "ietf-yang-push:period": "500"
    }
  }
}

            ]]></artwork>
          </figure>

          <t>If the publisher can satisfy both changes, the publisher sends a positive result for the RPC. If the publisher cannot satisfy either of the proposed changes, the publisher sends an RPC error response (e).  The following is an example RPC error response for (e) which includes a hint. This hint is an alternative time period value which might have resulted in a successful modification:</t>

          <figure align="center" anchor="negative-modify-subs" title="Modify subscription failure with Hint (e)">
            <artwork><![CDATA[
      HTTP status code - 406

      { "ietf-restconf:errors" : {
          "error" : [
            "error-type": "application",
            "error-tag": "operation-failed",
            "error-severity": "error",
            "error-app-tag": "ietf-yang-push:period-unsupported",
            "error-info": {
              "ietf-yang-push":
              "modify-subscription-datastore-error-info": {
                 "period-hint": "3000"
              }
            }
          ]
        }
      }
            ]]></artwork>
          </figure>

        </section>

        <section title="Deleting Dynamic Subscriptions">

          <t>The following demonstrates deleting a subscription.  This subscription may have been to either a stream or a datastore.</t>

          <figure align="center" anchor="simple-delete-subs" title="Delete subscription">
            <artwork><![CDATA[
POST /restconf/operations/ietf-subscribed-notifications:delete-subscription

{
 "delete-subscription": {
    "id": "22"
 }
}
            ]]></artwork>
          </figure>

          <t>If the publisher can satisfy the request, the publisher replies with success to the RPC request.</t>


          <t>If the publisher cannot satisfy the request, the publisher sends an error-rpc element indicating the modification didn't work. <xref target="negative-delete-subs"/> shows a valid response for existing valid subscription identifier, but that subscription identifier was created on a different transport session:</t>

        <figure align="center" anchor="negative-delete-subs" title="Unsuccessful delete subscription">
          <artwork><![CDATA[
      HTTP status code - 406

      {
        "ietf-restconf:errors" : {
          "error" : [
            "error-type": "application",
            "error-tag": "operation-failed",
            "error-severity": "error",
            "error-app-tag":
               "ietf-subscribed-notifications:no-such-subscription"
          ]
        }
      }
            ]]></artwork>
          </figure>

        </section>

      </section>

      <section title="Subscription State Notifications">

         <t>A publisher will send subscription state notifications according to the definitions within <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/>).</t>

        <section title="subscription-modified">
          <t>A "subscription-modified" encoded in JSON would look like:</t>

          <figure align="center" anchor="subscription-modified-ctrl-plane-notif"
                title="subscription-modified subscription state notification">
            <artwork><![CDATA[
{
  "ietf-restconf:notification" : {
    "eventTime": "2007-09-01T10:00:00Z",
    "ietf-subscribed-notifications:subscription-modified": {
      "id": "39",
      "uri": "https://example.com/restconf/subscriptions/22"
      "stream-xpath-filter": "/example-module:foo",
      "stream": {
         "ietf-netconf-subscribed-notifications" : "NETCONF"
      }
    }
  }
}
             ]]></artwork>
          </figure>
        </section>

        <section title="subscription-completed, subscription-resumed, and replay-complete">

          <t>A "subscription-completed" would look like:</t>

          <figure align="center"
                  anchor="subscription-completed"
                  title="subscription-completed notification in JSON">
            <artwork><![CDATA[

{
  "ietf-restconf:notification" : {
    "eventTime": "2007-09-01T10:00:00Z",
    "ietf-subscribed-notifications:subscription-completed": {
      "id": "39",
    }
  }
}
             ]]></artwork>
          </figure>

          <t>The "subscription-resumed" and "replay-complete" are virtually identical, with "subscription-completed" simply being replaced by "subscription-resumed" and "replay-complete".</t>

        </section>

        <section title="subscription-terminated and subscription-suspended">

          <t>A "subscription-terminated" would look like:</t>

          <figure align="center"
                  anchor="subscription-terminated"
                  title="subscription-terminated subscription state notification">
            <artwork><![CDATA[
{
  "ietf-restconf:notification" : {
    "eventTime": "2007-09-01T10:00:00Z",
    "ietf-subscribed-notifications:subscription-terminated": {
      "id": "39",
      "error-id": "suspension-timeout"
    }
  }
}
            ]]></artwork>
          </figure>

          <t>The "subscription-suspended" is virtually identical, with "subscription-terminated" simply being replaced by "subscription-suspended".</t>

        </section>
        
      </section>

    <section title="Filter Example">
    
      <t>This section provides an example which illustrate the method of filtering event record contents.  The example is based on the YANG notification "vrrp-protocol-error-event" as defined per the ietf-vrrp.yang module within <xref target="RFC8347"/>.  Event records based on this specification which are generated by the publisher might appear as:</t>

      <figure align="center" 
              anchor="VRRP-notification" 
              title="RFC 8347 (VRRP) - Example Notification">       
                  <artwork><![CDATA[
      data: {
      data:   "ietf-restconf:notification" : {
      data:     "eventTime" : "2018-09-14T08:22:33.44Z",
      data:     "ietf-vrrp:vrrp-protocol-error-event" : {
      data:       "protocol-error-reason" : "checksum-error"
      data:     }
      data:   }
      data: }
         ]]></artwork>
      </figure>

      <t>Suppose a subscriber wanted to establish a subscription which only passes instances of event records where there is a "checksum-error" as part of a VRRP protocol event.  Also assume the publisher places such event records into the NETCONF stream.  To get a continuous series of matching event records, the subscriber might request the application of an XPath filter against the NETCONF stream.  An "establish-subscription" RPC to meet this objective might be:</t>

      <figure align="center" 
              anchor="VRRP-XPATH" 
              title="Establishing a subscription error reason via XPath">       
                  <artwork><![CDATA[
POST /restconf/operations/ietf-subscribed-notifications:establish-subscription
{
   "ietf-subscribed-notifications:input": {
      "stream": "NETCONF",
      "stream-xpath-filter": "/ietf-vrrp:vrrp-protocol-error-event[protocol-error-reason='checksum-error']/",
   }
}
         ]]></artwork>
      </figure>

      <t>For more examples of XPath filters, see <xref target="XPATH"/>.</t>

      <t>Suppose the "establish-subscription" in <xref target="VRRP-XPATH"/> was accepted. And suppose later a subscriber decided they wanted to broaden this subscription cover to all VRRP protocol events (i.e., not just those with a "checksum error").  The subscriber might attempt to modify the subscription in a way which replaces the XPath filter with a subtree filter which sends all VRRP protocol events to a subscriber. Such a "modify-subscription" RPC might look like:</t>

      <figure align="center" 
              anchor="VRRP-Subtree" 
              title="">       
                  <artwork><![CDATA[ 
POST /restconf/operations/ietf-subscribed-notifications:modify-subscription
{
   "ietf-subscribed-notifications:input": {
      "stream": "NETCONF",
      "stream-subtree-filter": {
        "/ietf-vrrp:vrrp-protocol-error-event" : {}
      }
   }
}
         ]]></artwork>
      </figure>

      <t>For more examples of subtree filters, see <xref target="RFC6241"/>, section 6.4.</t>
     
    </section>   

    </section>

    <section title="Changes between revisions">
      <t>(To be removed by RFC editor prior to publication)</t>

      <t>v08 - v09</t>
          <t><list style="symbols">
            <t>Addressed comments received during WGLC.</t>
        </list>
      </t>

      <t>v07 - v08</t>
          <t><list style="symbols">
            <t>Aligned with RESTCONF mechanism.</t>
            <t>YANG model: removed augment of subscription-started, added restconf transport.</t>
            <t>Tweaked Appendix A.1 to match draft-ietf-netconf-netconf-event-notifications-13.</t>
            <t>Added Appendix A.3 for filter example.</t>
        </list>
      </t>
      
      <t>v06 - v07</t>
          <t><list style="symbols">
            <t>Removed configured subscriptions.</t>
            <t>Subscription identifier renamed to id.</t>
        </list>
      </t>
      
      <t>v05 - v06</t>
          <t><list style="symbols">
            <t>JSON examples updated by Reshad.</t>
        </list>
      </t>
      
      <t>v04 - v05</t>
          <t><list style="symbols">
            <t>Error mechanisms updated to match embedded RESTCONF mechanisms</t>
            <t>Restructured format and sections of document.</t>
            <t>Added a YANG data model for HTTP specific parameters.</t>
            <t>Mirrored the examples from the NETCONF transport draft to allow easy comparison.</t>
        </list>
      </t>

      <t>v03 - v04</t>
          <t><list style="symbols">
            <t>Draft not fully synched to new version of subscribed-notifications yet.</t>
            <t>References updated</t>
        </list>
      </t>


      <t>v02 - v03</t>
          <t><list style="symbols">
            <t>Event notification reframed to notification message.</t>
            <t>Tweaks to wording/capitalization/format.</t>
        </list>
      </t>

      <t>v01 - v02</t>
      <t><list style="symbols">
            <t>Removed sections now redundant with <xref target="I-D.draft-ietf-netconf-subscribed-notifications"/> and <xref target="I-D.ietf-netconf-yang-push"/> such as:  mechanisms for subscription maintenance, terminology definitions, stream discovery.</t>
            <t>3rd party subscriptions are out-of-scope.</t>
            <t>SSE only used with RESTCONF and HTTP1.1 dynamic subscriptions</t>
            <t>Timeframes for event tagging are self-defined.</t>
            <t>Clean-up of wording, references to terminology, section numbers.</t>
        </list>
      </t>

      <t>v00 - v01</t>
      <t><list style="symbols">
            <t>Removed the ability for more than one subscription to go to a single HTTP2 stream.</t>
            <t>Updated call flows.  Extensively.</t>
            <t>SSE only used with RESTCONF and HTTP1.1 dynamic subscriptions</t>
            <t>HTTP is not used to determine that a receiver has gone silent and is not Receiving Event Notifications</t>
            <t>Many clean-ups of wording and terminology</t>
        </list>
      </t>

    </section>
  </back>
</rfc>
