<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="2"?>
<?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-ahuang-netconf-notif-yang-04"
     ipr="trust200902"
     updates="RFC5277">
  <front>
    <title abbrev="NETCONF Event Notification YANG">YANG model
    for NETCONF Event Notifications</title>

    <author fullname="Alex Huang Feng" initials="A." surname="Huang Feng">
      <organization>INSA-Lyon</organization>

      <address>
        <postal>
          <street/>

          <city>Lyon</city>

          <region/>

          <code/>

          <country>France</country>
        </postal>

        <phone/>

        <facsimile/>

        <email>alex.huang-feng@insa-lyon.fr</email>

        <uri/>
      </address>
    </author>

    <author fullname="Pierre Francois" initials="P." surname="Francois">
      <organization>INSA-Lyon</organization>

      <address>
        <postal>
          <street/>

          <city>Lyon</city>

          <region/>

          <code/>

          <country>France</country>
        </postal>

        <phone/>

        <facsimile/>

        <email>pierre.francois@insa-lyon.fr</email>

        <uri/>
      </address>
    </author>

    <author fullname="Thomas Graf" initials="T" surname="Graf">
      <organization>Swisscom</organization>

      <address>
        <postal>
          <street>Binzring 17</street>

          <city>Zurich</city>

          <code>8045</code>

          <country>Switzerland</country>
        </postal>

        <email>thomas.graf@swisscom.com</email>
      </address>
    </author>

    <author fullname="Benoit Claise" initials="B" surname="Claise">
      <organization>Huawei</organization>

      <address>
        <email>benoit.claise@huawei.com</email>
      </address>
    </author>

    <date day="22" month="January" year="2024"/>

    <abstract>
      <t>This document defines the YANG model for NETCONF Event Notifications.
      The definition of this YANG model allows the encoding of NETCONF Event
      Notifications in YANG compatible encodings such as YANG-JSON and YANG-CBOR.</t>
    </abstract>

    <note title="Requirements Language">
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
      "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
      "OPTIONAL" in this document are to be interpreted as described in BCP 14
      <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when,
      they appear in all capitals, as shown here.</t>
    </note>
  </front>

  <middle>
    <section anchor="introduction" title="Introduction">
      <t>This document defines a YANG <xref target="RFC7950"/> data model for NETCONF
      Event Notifications <xref target="RFC5277"/>. The notification structure defined
      in <xref target="RFC5277"/> uses a XML Schema <xref target="W3C.REC-xml-20001006"/>
      allowing to encode and validate the message in XML. Nevertheless,
      when the notification message is encoded using other encodings such as
      YANG-JSON <xref target="RFC7951"/> or YANG-CBOR <xref target="RFC9254"/>, a YANG model 
      to validate or encode the message is necessary. This document extends 
      <xref target="RFC5277"/>, defining the NETCONF Event Notification structure in a YANG module.
      </t>
    </section>

    <section title="Differences to draft-ietf-netconf-notification-messages">
      <t><xref target="I-D.ietf-netconf-notification-messages"/> proposes a
      structure to send multiple notifications in a single message. Unlike 
      <xref target="I-D.ietf-netconf-notification-messages"/>, this document defines 
      a YANG module to encode NETCONF Notifications with encodings other than XML, which is currently
      not existing. The structure for NETCONF notifications is defined in <xref target="RFC5277"/> using
      a XSD, but there is no YANG module defining the structure of the notification message sent by a server 
      when the message is encoded in YANG-JSON <xref target="RFC7951"/> or YANG-CBOR <xref target="RFC9254"/>. 
      </t>
    </section>

    <section anchor="yang-model" title="YANG Module">
    
      <section anchor="yang-tree" title="YANG Tree Diagram">
        <t>This YANG module adds a structure with one leaf for the datetime as defined in 
        section 2.2.1 of <xref target="RFC5277"/>. The name of the leaf matches the 
        definition of the XSD element name defined in Section 4 of <xref target="RFC5277"/>.
        </t>

          <sourcecode type="yangtree"><![CDATA[
module: ietf-notification

  structure notification:
    +-- eventTime    yang:date-and-time
]]></sourcecode>
      </section>

      <section anchor="yang-module" title="YANG Module">
      <t>The YANG module uses the same namespace from the XML Schema
      defined in Section 4 of <xref target="RFC5277"/> allowing to use this YANG module 
      to also validate already implemented XML encoded NETCONF Event Notifications.</t>

      <sourcecode type="yang" markers="true" name="ietf-notification@2024-01-22.yang"><![CDATA[
module ietf-notification {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:netconf:notification:1.0";
  prefix inotif;
  import ietf-yang-types {
    prefix yang;
    reference
      "RFC 6991: Common YANG Data Types";
  }
  import ietf-yang-structure-ext {
    prefix sx;
    reference
      "RFC 8791: YANG Data Structure Extensions";
  }

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

     Authors:  Alex Huang Feng
               <mailto:alex.huang-feng@insa-lyon.fr>
               Pierre Francois
               <mailto:pierre.francois@insa-lyon.fr>
               Thomas Graf
               <mailto:thomas.graf@swisscom.com>
               Benoit Claise
               <mailto:benoit.claise@huawei.com>";

  description
    "Defines NETCONF Event Notification structure as defined in RFC5277.
    This YANG module uses the same namespace from the XML schema defined
    in Section 4 of RFC5277 to be able to validate already implemented 
    XML encoded messages.

    Copyright (c) 2023 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 Revised 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 2024-01-22 {
    description
      "First revision";
    reference
      "RFC XXXX: NETCONF Event Notification YANG";
  }

  sx:structure notification {
    leaf eventTime {
      type yang:date-and-time;
      mandatory true;
      description
        "The date and time the event was generated by the event source.
        This parameter is of type dateTime and compliant to [RFC3339].
        Implementations must support time zones.
        The leaf name in camel case matches the name of the XSD element
        defined in Section 4 of RFC5277.";
    }
  }
}
]]></sourcecode>
      </section>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>The security considerations for the NETCONF Event notifications
      are described in <xref target="RFC5277"/>. This documents adds
      no additional security considerations.</t>
    </section>

    <section anchor="IANA_Considerations" title="IANA Considerations">

      <t>This document describes the URI used for the IETF XML Registry and
      registers a new YANG module name.</t>

      <section title="URI">
      <t>IANA is requested to add this document as a reference in the following
      URI in the <xref target="RFC3688">IETF XML Registry</xref>.</t>

      <artwork align="left"><![CDATA[
URI: urn:ietf:params:xml:ns:netconf:notification:1.0
Registrant Contact: The IESG.
XML: N/A; the requested URI is an XML namespace.
Reference: RFC5277; RFC-to-be]]></artwork>
      </section>

      <section title="YANG module name">

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

        <artwork align="left"><![CDATA[
name: ietf-notification
namespace: urn:ietf:params:xml:ns:netconf:notification:1.0
prefix: inotif
reference: RFC-to-be]]></artwork>
      </section>

      <section title="YANG SID-file" anchor="iana-sid">
        <t>IANA is requested to register a new ".sid" file in the <xref
        target="I-D.ietf-core-sid">"IETF YANG SID Registry"</xref>:</t>

        <artwork align="left"><![CDATA[
SID range entry point: TBD
SID range size: 50
YANG module name: ietf-notification
reference: RFC-to-be]]></artwork>

        <t>A ".sid" file is proposed in <xref target="sid_appendix"/>.</t>
      </section>
    </section>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>The authors would like to thank Andy Bierman, Carsten Bormann, Tom Petch and
      Jason Sterne for their review and valuable comments.</t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="https://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?>
      <?rfc include="https://xml.resource.org/public/rfc/bibxml/reference.RFC.3339.xml"?>
      <?rfc include="https://xml.resource.org/public/rfc/bibxml/reference.RFC.3688.xml"?>
      <?rfc include="https://xml.resource.org/public/rfc/bibxml/reference.RFC.5277.xml"?>
      <?rfc include="https://xml.resource.org/public/rfc/bibxml/reference.RFC.6020.xml"?>
      <?rfc include="https://xml.resource.org/public/rfc/bibxml/reference.RFC.6991.xml"?>
      <?rfc include="https://xml.resource.org/public/rfc/bibxml/reference.RFC.7950.xml"?>
      <?rfc include="https://xml.resource.org/public/rfc/bibxml/reference.RFC.7951.xml"?>
      <?rfc include="https://xml.resource.org/public/rfc/bibxml/reference.RFC.8174.xml"?>
      <?rfc include="https://xml.resource.org/public/rfc/bibxml/reference.RFC.8791.xml"?>

      <reference anchor="W3C.REC-xml-20001006"
                 derivedAnchor="W3C.REC-xml-20001006" quoteTitle="true"
                 target="https://www.w3.org/TR/2000/REC-xml-20001006">
        <front>
          <title>Extensible Markup Language (XML) 1.0 (Second Edition)</title>

          <author fullname="Tim Bray" initials="T." surname="Bray">
            <organization showOnFrontPage="true"/>
          </author>

          <author fullname="Jean Paoli" initials="J." surname="Paoli">
            <organization showOnFrontPage="true"/>
          </author>

          <author fullname="Michael Sperberg-McQueen" initials="M."
                  surname="Sperberg-McQueen">
            <organization showOnFrontPage="true"/>
          </author>

          <author fullname="Eve Maler" initials="E." surname="Maler">
            <organization showOnFrontPage="true"/>
          </author>

          <date month="October" year="2000"/>
        </front>

        <refcontent>W3C</refcontent>
      </reference>
      
      <?rfc include="https://bib.ietf.org/public/rfc/bibxml-ids/reference.I-D.ietf-core-sid.xml"?>

    </references>

    <references title="Informative References">
      <?rfc include="https://xml.resource.org/public/rfc/bibxml/reference.RFC.8340.xml"?>
      <?rfc include="https://xml.resource.org/public/rfc/bibxml/reference.RFC.9254.xml"?>
      <?rfc include="https://datatracker.ietf.org/doc/bibxml3/draft-ietf-netconf-notification-messages-08.xml"?>
    </references>

    <section anchor="example" title="Examples">
      <t>This non-normative section shows examples of how XML, YANG-JSON and YANG-CBOR are encoded.</t>
      <section anchor="xml-example" title="XML encoded message">
        <t>This is an example of a XML-encoded notification as defined in <xref target="RFC5277"/>.</t>

        <figure anchor="fig_xml"
              title="XML-encoded notification">
              <sourcecode type="xml"><![CDATA[
<notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
  <eventTime>2022-09-02T10:59:55.32Z</eventTime>
  <push-update xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-push">
    <id>1011</id>
    <datastore-contents>
      <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
        <interface>
          <name>eth0</name>
          <oper-status>up</oper-status>
        </interface>
      </interfaces>
    </datastore-contents>
  </push-update>
</notification>
    ]]></sourcecode>
            </figure>
      </section>
      
      <section anchor="json-example" title="YANG-JSON encoded message">
        <t>This is an example of a YANG-JSON encoded notification.</t>

        <figure anchor="fig_json"
              title="JSON-encoded notification">
              <sourcecode type="json"><![CDATA[
{
    "ietf-notification:notification": {
        "eventTime": "2023-02-10T08:00:11.22Z",
        "ietf-yang-push:push-update": {
            "id": 1011,
            "datastore-contents": {
                "ietf-interfaces:interfaces": [
                    {
                        "interface": {
                            "name": "eth0",
                            "oper-status": "up"
                        }
                    }
                ]
            }
        }
    }
}
    ]]></sourcecode>
            </figure>
      </section>

      <section anchor="cbor-example" title="YANG-CBOR encoded message">
        <t>This is an example of YANG-CBOR encoded notification. 
        The figure <xref target="fig_cbor"/> shows the message using the CBOR
        diagnostic notation as defined in section 3.1 of <xref target="RFC9254"/>.</t>

        <figure anchor="fig_cbor"
              title="CBOR-encoded notification using diagnostic notation">
              <sourcecode type="cbor-diag"><![CDATA[
{
    "ietf-notification:notification": {
        "eventTime": "2023-02-10T08:00:11.22Z",
        "ietf-yang-push:push-update": {
            "id": 1011,
            "datastore-contents": {
                "ietf-interfaces:interfaces": [
                    {
                        "interface": {
                            "name": "eth0",
                            "oper-status": "up"
                        }
                    }
                ]
            }
        }
    }
}
    ]]></sourcecode>
        </figure>
      </section>

      <section anchor="cbor-sid-example" title="YANG-CBOR encoded message using SIDs">
        <t>This is an example of YANG-CBOR encoded notification using YANG SIDs <xref
        target="I-D.ietf-core-sid"/>. The figure <xref target="fig_cbor_sid"/> shows
        the message using the CBOR diagnostic notation as defined in section 3.1 of
        <xref target="RFC9254"/>.</t>

        <figure anchor="fig_cbor_sid"
              title="CBOR-encoded notification using YANG SIDs in CBOR diagnostic notation">
              <sourcecode type="cbor-diag"><![CDATA[
{
    2551: {
        1: "2023-02-10T08:00:11.22Z",
        "ietf-yang-push:push-update": {
            "id": 1011,
            "datastore-contents": {
                "ietf-interfaces:interfaces": [
                    {
                        "interface": {
                            "name": "eth0",
                            "oper-status": "up"
                        }
                    }
                ]
            }
        }
    }
}
    ]]></sourcecode>
        </figure>
      </section>
    </section>
    <section title=".sid file" anchor="sid_appendix">
      <t>Note to the RFC-Editor: Please remove this section before publishing.</t>

      <t>For CBOR encoding using YANG-SIDs identifiers, a ".sid" file is requested
      to IANA in <xref target="iana-sid"/>.</t>

      <figure anchor="fig_sid_file"
            title='.sid file for "ietf-notification" module'>
        <sourcecode type="yang-sid" markers="true" name="ietf-notification@2024-01-22.sid"><![CDATA[
{
  "ietf-sid-file:sid-file": {
    "module-name": "ietf-notification",
    "module-revision": "2024-01-22",
    "description": "NETCONF Event Notification structure",
    "dependency-revision": [
      {
        "module-name": "ietf-yang-types",
        "module-revision": "2013-07-15"
      },
      {
        "module-name": "ietf-yang-structure-ext",
        "module-revision": "2020-06-17"
      }
    ],
    "assignment-range": [
      {
        "entry-point": "2550",
        "size": "50"
      }
    ],
    "item": [
      {
        "namespace": "module",
        "identifier": "ietf-notification",
        "sid": "2550"
      },
      {
        "namespace": "data",
        "identifier": "/ietf-notification:notification",
        "sid": "2551"
      },
      {
        "namespace": "data",
        "identifier": "/ietf-notification:notification/eventTime",
        "sid": "2552"
      }
    ]
  }
}
    ]]></sourcecode>
      </figure>
    </section>
  </back>
</rfc>
