<?xml version="1.0" encoding="UTF-8"?>
<!-- 
:folding=sidekick:
-->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="4"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="std" ipr="trust200902" docName="draft-ietf-netmod-yang-instance-file-format-16">
  <front>
    <title abbrev="YANG Instance Data">YANG Instance Data File Format</title>
    <author initials="B." surname="Lengyel" fullname="Balazs Lengyel">
      <organization abbrev="Ericsson"> Ericsson </organization>
      <address>
        <email>balazs.lengyel@ericsson.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/>
    <area>OPS</area>
    <workgroup>Netmod</workgroup>
    <abstract>
      <t> 
        There is a need to document data defined in YANG models at design time, 
        implementation time or when a live server is unavailable. 
        This document specifies a standard
        file format for YANG instance data, which follows the syntax and semantics 
        of existing YANG models, and annotates it with metadata.
      </t>
    </abstract>
  </front>

  <middle>
    <section anchor="intro" title="Introduction">
      <t>
        There is a need to document data defined in YANG models when a live server is unavailable. 
        Data is often needed at design, implementation time or  
        when a live running server is unavailable.  
        To facilitate this offline delivery of data, this document specifies a standard
        format for YANG instance data sets and YANG instance data files.
        The format of the instance data set is defined by the "ietf-yang-instance-data"
        YANG module, see <xref target="instance_data_yam"/>.
        The YANG data model in this document conforms to the Network
        Management Datastore Architecture (NMDA) defined in <xref target="RFC8342"/>
        </t>
        <t>The following is a list of already implemented and potential use cases.
        <list style="format UC%d">
          <t>Documentation of server capabilities</t>
          <t>Preloading default configuration data</t>
          <t>Documenting Factory Default Settings</t>
          <t>Storing the configuration of a device, e.g., for backup, archive or 
            audit purposes</t>
          <t>Storing diagnostics data</t>
          <t>Allowing YANG instance data to potentially be carried within other IPC message formats</t>
          <t>Default instance data used as part of a templating solution</t>
          <t>Providing data examples in RFCs or internet drafts</t>
        </list>
      </t>
      <t>In <xref target="detailed_use_cases"/> describes the first three use 
        cases in detail. 
      </t><t>
        There are  many and varied use cases where YANG instance data 
        could be used. This document does not limit future uses of instance data 
        sets, so specifying how and when to use YANG instance data 
        is out of scope for this document. It is anticipated that other
        documents will define specific use cases. Use cases are listed 
        only as examples.
      </t>      
      <section title="Terminology" anchor="terminology">
        <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>
        <t>Instance Data: A collection of instantiated data nodes.</t>
        <t>Instance Data Set:  A named set of data items annotated with metadata 
          that can be used as instance data in a YANG data tree.</t>
        <t>Instance Data File:  A file containing an instance data set formatted 
          according to the rules described in this document.</t>
        <t>Content-schema: A set of YANG modules with their revision, supported 
          features, and deviations for which the instance data set contains instance data.</t>
        <t>Content defining YANG module: an individual YANG module that is part of the content-schema.</t>
        <t>The term "server" is used as defined in <xref target="RFC8342"/>.</t>
      </section>   
      <section title="Principles">
        <t>The following is a list of the basic principles of the instance data format:
          <list style="format P%d">
            <t>Two standard formats shall be defined based on the XML and 
              JSON encodings.</t>
            <t>Instance data shall reuse existing encoding rules for
              YANG defined data.
            </t>
            <t>Metadata about the instance data set 
              (<xref target="instance_data_set_metadata"/>) shall be defined.</t>
            <t>A YANG instance data set shall be allowed to contain data 
              for multiple YANG modules.</t>
            <t>Instance data shall be allowed to contain configuration data, 
              state data, or a mix of the two.</t>
            <t>Partial data sets shall be allowed.</t>
            <t>The YANG instance data format shall be usable for any data for which   
              YANG module(s) are defined and available to the reader, independent 
              of whether the module is implemented by a server.</t>
            <t>It shall be possible to report the identity of the datastore with which the
            instance data set is associated.</t>
          </list>
        </t>
      </section>
      <section title="Delivery of Instance Data">
        <t>Instance data sets that are produced as 
            a result of some sort of specification or design effort
            may be available without the need for a live 
            server e.g., via download from the vendor's website, or in any other 
            way that product documentation is distributed.</t>
            <t>Other instance data sets may be read from or produced by the YANG 
            server itself e.g., UC5 documenting diagnostic data.</t>
      </section>      
      <section title="Data Life cycle">
          <t>
              A YANG instance data set is created at a specific  
              point of time. If the data changes afterwards, this is not
              represented in the instance data set anymore. The current values may be
              retrieved at run-time via NETCONF/RESTCONF or 
              received e.g., in YANG-Push notifications.               
          </t>
          <t>
              Whether the instance data changes and if so, when and how,
              should be described either in the instance data set's description
              statement or in some other implementation specific manner.
          </t>
      </section>
    </section>

    <section anchor="instance_data_file_format" title="Instance Data File Format">
      <t>
        A YANG instance data file MUST contain a single instance data set and no
        additional data.
      </t>
      <t>The format of the instance data set is defined  by the 
        "ietf-yang-instance-data" YANG module.
        It is made up of a header part and content-data. 
        The header part carries metadata for the instance data set. 
        The content-data, defined as an anydata data node, carries
        the instance data that the user wants to document/provide. 
        The syntax and semantics of content-data is defined by the content-schema.    
      </t>
      <t>Two formats are specified based on the XML and JSON YANG encodings.  
        Later, as other YANG encodings (e.g., CBOR) are defined, further 
        instance data formats may be specified.
      </t>
      <t>The content-data part MUST conform to the content-schema, while allowing for the 
        exceptions listed below. The content-data part SHALL follow the 
        encoding rules defined in  <xref target="RFC7950"/> for XML and 
        <xref target="RFC7951"/> for JSON and MUST use UTF-8 character encoding.
        Content-data MAY include:
        <list style="symbols">
          <t>metadata, as defined by <xref target="RFC7952"/>.</t>
          <t>origin metadata, as specified in 
          <xref target="RFC8526"/> and <xref target="RFC8527"/></t>
          <t>implementation specific metadata relevant to individual 
            data nodes. Unknown metadata MUST be ignored by users of 
            instance data, allowing it to be used 
            later for other purposes.</t>
        </list>
      </t>
      <t>An instance data set MAY contain data for any number of 
        YANG modules; if needed it MAY carry the complete configuration and state
        data for a server.
        Default values should be excluded where they do not provide 
        additional useful data.
        </t><t>
        Configuration ("config true") and operational state data ("config false") 
        MAY be mixed in the instance data file.        
        </t><t>
        Instance data files MAY contain partial data sets. This means "mandatory", 
        "min-elements", "require-instance true", "must" and "when" constrains MAY be violated.      
      </t>
      <t>The name of the instance data file SHOULD be of the form:
        <figure align="center" anchor="filename" suppress-title="true">
          <artwork align="left" name="filename-abnf">
<![CDATA[   instance-data-set-name ['@' ( revision-date / timestamp ) ] 
                  ( '.xml' / '.json' )
                  
      E.g., acme-router-modules.xml
      E.g., acme-router-modules@2018-01-25.xml
      E.g., acme-router-modules@2018-01-25T15_06_34_3+01_00.json
]]>
          </artwork>
        </figure>
        If the leaf "name" is present in the instance data header, 
        its value SHOULD be used for the "instance-data-set-name".
        
        If the "revision-date" is present in the filename it MUST conform to 
        the format of the revision-date leaf in the YANG model. 
        If the "revision-date" is present in both the filename and in the
        instance data header, the revision date in the file name MUST be
        set to the latest revision date inside the instance data set.
        
        If the "timestamp" is present in the filename it MUST conform to 
        the format of the timestamp leaf in the YANG model except for 
        replacing colons as described below. 
        If the "timestamp" is present both in the filename and in the
        instance data header, the timestamp in the file name SHOULD be
        set to the timestamp inside the instance data set; any colons, 
        if present, shall be replaced by underscores.
      </t>
      <t anchor="instance_data_set_metadata">Metadata, information about the data set itself  
      SHOULD be included in the instance data set. Some metadata items are 
      defined in the YANG module "ietf-yang-instance-data", but other items MAY 
      be used.</t><t> 
      Metadata MUST include:
        <list><t><list style="symbols">
          <t>Version of the YANG Instance Data format</t>
        </list></t></list>
      Metadata SHOULD include:
        <list><t><list style="symbols">
          <t>Name of the data set</t>
          <t>Content schema specification (i.e., the "content-schema” node)</t>
          <t>Description of the instance data set. The description SHOULD 
            contain information whether and how the data can change during 
            the lifetime of the server
          </t>
          <t>An indication whether default values are included. 
            The default handling uses the concepts defined in <xref target="RFC6243"/>,
            however as only concepts are re-used, users of instance data sets, 
            do not need to support RFC 6243.
          </t>
        </list></t></list>
        </t>
      <section title="Specifying the Content Schema"> 
        <t>To properly understand and use an instance data set, the user needs to 
          know the content-schema. One of the following methods SHOULD be used:
          <list>
           <t>Simplified-Inline method: Include the needed information as part of 
            the instance data set; short specification.</t>
           <t>Inline method: Include the needed information as part of the 
            instance data set.</t>
           <t>URI method: Include a URI that references another YANG instance 
            data file. This instance data file will use the same content-schema
            as the referenced YANG instance data file. 
            (if you don't want to repeat the info again and again)</t>
           <t>External Method: Do not include the "content-schema" node; the 
            user needs to obtain the information through external documents.</t>
          </list>
          Additional methods e.g., a YANG-package based solution may be added later.
        </t>
        <t>Note, the specified content-schema only indicates the set of 
          modules that were used to define this YANG instance data set. 
          Sometimes instance data may be used for a server supporting a 
          different YANG module set (e.g., for the "Preloading default 
          configuration data" use-case, UC2 in <xref target="intro"/>, the instance 
          data set may not be updated every time the YANG modules on the 
          server are updated).
          Whether an instance data set originally defined using a specific 
          content-schema is usable with a different other schema   
          depends on many factors including the amount of differences and the 
          compatibility between the original and the 
          other schema, considering modules, revisions, features, 
          deviations, the scope of the instance data, etc.  
        </t>
        <section title="Inline Method">
          <t>The inline-yang-library anydata data node carries instance data (conforming to 
            ietf-yang-library@2019-01-04) that specifies the content 
            defining YANG modules including revision, 
            supported features, deviations and any relevant additional data.   
            An example of the "inline" method is provided in <xref target="acme-router-modules"/>.
          </t>          
        </section>
        <section title="Simplified-Inline Method">
          <t>The instance data set contains a list of content defining YANG 
             modules including the revision date for each. 
             Usage of this method implies that the modules are 
             used without any deviations and with all features 
             supported. YANG modules that are only required to satisfy 
             import-only dependencies MAY be excluded from the leaf-list.  
             If they are excluded then the consumer of the instance data 
             set has to apply the YANG language rules to resolve the imports.
             An example of the "simplified-inline" method is provided in <xref target="read-only-acm-rules"/>.
          </t>          
        </section>
        <section title="URI Method">
          <t>The "same-schema-as-file" leaf SHALL contain a URI that references another YANG 
            instance data file. The current instance data file will use the same  
            content schema as the referenced file. 
          </t><t>
            The referenced instance data file MAY have no content-data if it is 
            used solely for specifying the content-schema.  
          </t><t>
            If a referenced instance data file is unavailable, content-schema 
            is unknown.
          </t><t>
            The URI method is advantageous when the user wants to avoid the 
            overhead of specifying the content-schema in each instance data 
            file: E.g., In UC6, when the system creates a diagnostic file  
            every minute to document the state of the server.  
        </t>
        <t>An example of the "URI" method is provided in <xref target="acme-router-netconf-diagnostics"/>.</t>

        </section>
      </section>
      <section title="Examples"  anchor="examples">
        <section title="Documentation of server capabilities" anchor="acme-router-modules-example">
          <t>The example file acme-router-modules@2021-07-07.xml reflects UC1 in <xref target="intro"/>. 
            It provides a list of supported YANG modules and NETCONF capabilities for a server. 
            It uses the "inline" method to specify the content-schema.</t>
          <t>The example uses artwork folding <xref target="RFC8792"/>.</t>
          <figure align="center" anchor="acme-router-modules">
            <artwork align="left" name="acme-router-modules@2021-07-07.xml">
<![CDATA[========== NOTE: '\' line wrapping per RFC 8792 ===========

<?xml version="1.0" encoding="UTF-8"?>
<instance-data-set xmlns=\
    "urn:ietf:params:xml:ns:yang:ietf-yang-instance-data">
  <name>acme-router-modules</name>
  <content-schema>
    <inline-yang-library>
      <modules-state \
        xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library">
        <module>
          <name>ietf-yang-library</name>
          <revision>2019-01-04</revision>
        </module>
        <module>
          <name>ietf-netconf-monitoring</name>
          <revision>2010-10-04</revision>
        </module>
      </modules-state>
    </inline-yang-library>
  </content-schema>
  <revision>
    <date>1956-10-23</date>
    <description>Initial version</description>
  </revision>
  <description>Defines the minimal set of modules that any \
      acme-router will contain.</description>
  <contact>info@acme.com</contact>
  <content-data>
    <modules-state \
        xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library">
      <module>
        <name>ietf-yang-library</name>
        <revision>2019-01-04</revision>
        <namespace>\
          urn:ietf:params:xml:ns:yang:ietf-yang-library\
        </namespace>
        <conformance-type>implement</conformance-type>
      </module>
      <module>
        <name>ietf-system</name>
        <revision>2014-08-06</revision>
        <namespace>urn:ietf:params:xml:ns:yang:ietf-system</namespace>
        <feature>sys:authentication</feature>
        <feature>sys:local-users</feature>
        <deviation>
          <name>acme-system-ext</name>
          <revision>2018-08-06</revision>
        </deviation>
        <conformance-type>implement</conformance-type>
      </module>
      <module>
        <name>ietf-netconf-monitoring</name>
        <revision>2010-10-04</revision>
        <namespace>\
          urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\
        </namespace>
        <conformance-type>implement</conformance-type>
      </module>
      <module>
        <name>ietf-yang-types</name>
        <revision>2013-07-15</revision>
        <namespace>urn:ietf:params:xml:ns:yang:ietf-yang-types\
          </namespace>
        <conformance-type>import</conformance-type>
      </module>
      <module>
        <name>acme-system-ext</name>
        <revision>2018-08-06</revision>
        <namespace>urn:rdns:acme.com:oammodel:acme-system-ext\
          </namespace>
        <conformance-type>implement</conformance-type>
      </module>
    </modules-state>
    <netconf-state \
        xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
      <capabilities>
        <capability>\
          urn:ietf:params:netconf:capability:validate:1.1\
        </capability>
      </capabilities>
    </netconf-state>
  </content-data>
</instance-data-set>
]]></artwork>
          </figure>        
        </section>
        <section title="Preloading default configuration data"  anchor="read-only-acm-rules-example">
          <t>The example file read-only-acm-rules@2021-07-07.xml reflects UC2 in <xref target="intro"/>. 
            It provides a default rule set for a read-only operator role. 
            It uses the "simplified-inline" method for specifying the content-schema.</t>
          <figure align="center" anchor="read-only-acm-rules">
            <artwork align="left" name="read-only-acm-rules@2021-07-07.xml"><![CDATA[ 
<?xml version="1.0" encoding="UTF-8"?>
<instance-data-set 
    xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-instance-data">
  <name>read-only-acm-rules</name>
  <content-schema>
    <module>ietf-netconf-acm@2018-02-14</module>
  </content-schema>
  <revision>
    <date>1776-07-04</date>
    <description>Initial version</description>
  </revision>
  <description>Access control rules for a read-only role.</description>
  <content-data>
    <nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
      <enable-nacm>true</enable-nacm>
      <read-default>deny</read-default>
      <exec-default>deny</exec-default>
      <rule-list>
        <name>read-only-role</name>
        <group>read-only-group</group>
        <rule>
          <name>read-all</name>
          <module-name>*</module-name>
          <access-operation>read</access-operation>
          <action>permit</action>
        </rule>
      </rule-list>
    </nacm>
  </content-data>
</instance-data-set>
]]></artwork>
          </figure>
        </section>
        <section title="Storing diagnostics data"  anchor="acme-router-netconf-diagnostics-example">
          <t>The example file acme-router-netconf-diagnostics@2018-01-25T17_00_38Z.json 
            reflects UC5 in <xref target="intro"/>. 
            An instance data set is produced by the server every 15 minutes that contains 
            statistics about the NETCONF server. As a new set is produced periodically many times a day a revision-date 
            would be useless; instead a timestamp is included.</t>      
          <figure align="center" anchor="acme-router-netconf-diagnostics">
          <artwork align="left" name="acme-router-netconf-diagnostics@2018-01-25T17_00_38Z.json"><![CDATA[ 
{
  "ietf-yang-instance-data:instance-data-set": {
    "name": "acme-router-netconf-diagnostics", 
    "content-schema": {
      "same-schema-as-file": "file:///acme-diagnostics-schema.json"
    },
    "timestamp": "2018-01-25T17:00:38Z",
    "description":  ["NETCONF statistics"], 
    "content-data": {
      "ietf-netconf-monitoring:netconf-state": {
        "statistics": {
          "netconf-start-time ": "2018-12-05T17:45:00Z",
          "in-bad-hellos ": "32",
          "in-sessions ": "397",
          "dropped-sessions ": "87",
          "in-rpcs ": "8711",
          "in-bad-rpcs ": "408",
          "out-rpc-errors ": "408",
          "out-notifications": "39007"
        }
      } 
    }   
  }  
}
]]></artwork>
      </figure>
        </section>
    </section>
    </section>
    <section anchor="instance_data_yam" title="YANG Instance Data Model">      
      <section title="Tree Diagram">
        <t>
          The following tree diagram <xref target="RFC8340"/>
          provides an overview of the data model.
        </t>
        <t>
            <figure>
              <artwork><![CDATA[
module: ietf-yang-instance-data

  structure instance-data-set:
    +-- name?                string
    +-- format-version?      string
    +-- includes-defaults?   enumeration
    +-- content-schema
    |  +-- (content-schema-spec)?
    |     +--:(simplified-inline)
    |     |  +-- module*                module-with-revision-date
    |     +--:(inline)
    |     |  +-- inline-yang-library    <anydata>
    |     +--:(uri)
    |        +-- same-schema-as-file?   inet:uri
    +-- description*         string
    +-- contact?             string
    +-- organization?        string
    +-- datastore?           ds:datastore-ref
    +-- revision* [date]
    |  +-- date           string
    |  +-- description?   string
    +-- timestamp?           yang:date-and-time
    +-- content-data?        <anydata>
]]></artwork>
            </figure>
        </t>
      </section>          
      <section title="YANG Model" anchor="yang-model">
          <t>
             This YANG module imports typedefs from <xref target="RFC6991"/>, 
             identities from <xref target="RFC8342"/> and 
             the "structure" extension from <xref target="RFC8791"/>.
             It also references <xref target="RFC8525"/> and <xref target="RFC6243"/>.
          </t><t>
              <figure>
                  <artwork align="left" name="ietf-yang-instance-data@2021-07-07.yang"><![CDATA[
<CODE BEGINS> file "ietf-yang-instance-data@2021-07-07.yang"
// RFC Ed.: replace the date above if the module gets changed in
//anyway during reviews or RFC editor process and remove this note
module ietf-yang-instance-data {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-yang-instance-data";
  prefix yid;

  import ietf-yang-structure-ext {
    prefix sx;
    reference
      "YANG Data Structure Extensions:
       draft-ietf-netmod-yang-data-ext-05";
  }
  import ietf-datastores {
    prefix ds;
    reference
      "RFC 8342: Network Management Datastore Architecture (NMDA)";
  }
  import ietf-inet-types {
    prefix inet;
    reference
      "RFC 6991: Common YANG Data Types";
  }
  import ietf-yang-types {
    prefix yang;
    reference
      "RFC 6991: Common YANG Data Types";
  }

  organization
    "IETF NETMOD Working Group";
  contact
    "WG Web:   <https://datatracker.ietf.org/wg/netmodf/>
     WG List:  <mailto:netmod@ietf.org>

     Author:  Balazs Lengyel
        <mailto:balazs.lengyel@ericsson.com>

     Author:  Benoit Claise
        <mailto:benoit.claise@huawei.com>";
  description
    "The module defines the structure and content of YANG
     instance data sets.

     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 (RFC 2119)
     (RFC 8174) when, and only when, they appear in all
     capitals, as shown here.

     Copyright (c) 2021 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
     (http://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC XXXX; see
     the RFC itself for full legal notices.";
  // RFC Ed.: replace XXXX with RFC number and remove this note

  revision 2021-07-07 {
    // RFC Ed.: replace the date above if the module gets changed in
    // anyway during reviews or RFC editor process and remove
    //this note
    description
      "Initial revision.";
    reference
      "RFC XXXX: YANG Instance Data Format";
    // RFC Ed.: replace XXXX with RFC number and remove this note
  }

  typedef module-with-revision-date {
    type string {
      pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*'
            + '(@\d{4}-(1[0-2]|0[1-9])-(0[1-9]|[1|2][0-9]|3[0-1]))?';
      pattern '.|..|[^xX].*|.[^mM].*|..[^lL].*';
    }
    description
      "A type defining a module name and an optional revision
       date, e.g. ietf-yang-library@2019-01-04";
  }

  sx:structure "instance-data-set" {
    description
      "A data structure to define a format for YANG instance
       data. The majority of the YANG nodes provide meta-data
       about the instance data; the instance data itself is
       is contained only in the 'content-data' node.";
    leaf name {
      type string;
      description
        "An arbitrary name for the YANG instance data set.  This
         value is primarily used for descriptive purposes.  However,
         when the instance data set is saved to a file, then the
         filename MUST encode the name's value, per Section 3
         of RFC XXXX.";
      // RFC Ed.: replace XXXX with RFC number and remove this note
    }
    leaf format-version {
      type string {
        pattern '\d{4}-(1[0-2]|0[1-9])-(0[1-9]|[1|2][0-9]|3[0-1])';
      }
      default "2021-07-07";
      // RFC Ed.: replace the date above if the module gets changed
      // in anyway during reviews or RFC editor process and remove
      // this note
      description
        "The 'revision' of the 'ietf-yang-instance-data' module
         used to encode this 'instance-data-set'.";
    }
    leaf includes-defaults {
      type enumeration {
        enum report-all {
          value 1;
          description
            "All data nodes SHOULD be included independent of
              any default values.";
        }
        enum trim {
          value 2;
          description
            "Data nodes that have a default defined and where
              the actual value is the default value SHOULD
              NOT be included.";
        }
        enum explicit {
          value 3;
          description
            "Data nodes that have a default defined and where
              the actual value is the default value SHOULD NOT be
              included. However, if the actual value was set by
              a NETCONF client or other management application
              by the way of an explicit management operation the
              data node SHOULD be included.";
        }
      }
      default trim;
      description
        "As instance-data-sets MAY contain incomplete data sets,
          thus any data node MAY be absent.

          Providing the instance-data-set intends to contain a
          full data set, this leaf specifies whether the data set
          includes data nodes that have a default defined and
          where the actual value is the same as the default value.

          Data nodes that have no default values should always
          be included.
          Data nodes that have a default value, but the actual
          value is not equal to the schema defined default
          should always be included.";
      reference
        "RFC 6243: With-defaults Capability for NETCONF";
    }
    container content-schema {
      description
        "The content schema (i.e., YANG modules) used to create
         the instance data set.
         If not present the user needs to obtain the information
         through external documents.";
      choice content-schema-spec {
        description
          "Specification of the content-schema.";
        case simplified-inline {
          leaf-list module {
            type module-with-revision-date;
            min-elements 1;
            description
              "The list of content defining YANG modules.

               The value SHALL start with the module name.
               If the module contains a revision statement the
               revision date SHALL be included in the leaf-list
               entry.

               E.g., ietf-yang-library@2019-01-04

               Usage of this leaf-list implies the modules are
               used without any deviations and with all features
               supported. Multiple revisions of the same module
               MUST NOT be specified.";
          }
        }
        case inline {
          anydata inline-yang-library {
            mandatory true;
            description
              "Instance data corresponding to the
               ietf-yang-library@2019-01-04 defining
               the set of content defining YANG modules for
               this instance-data-set.";
          }
        }
        case uri {
          leaf same-schema-as-file {
            type inet:uri;
            description
              "A reference to another YANG instance data file.
               This instance data file uses the same
               content schema as the referenced file.

               Referenced files using the 'inline' or the
               'simplified-inline' methods MUST be supported.
               Referenced files using the 'URI Method' MAY be
               supported.

               The URL schemes 'file://' and 'https://' MUST
               be supported, other schemes MAY also be
               supported.";
          }
        }
      }
    }
    leaf-list description {
      type string;
      description
        "Description of the instance data set.";
    }
    leaf contact {
      type string;
      description
        "Contact information for the person or
         organization to whom queries concerning this
         instance data set should be sent.";
    }
    leaf organization {
      type string;
      description
        "Organization responsible for the instance
         data set.";
    }
    leaf datastore {
      type ds:datastore-ref;
      description
        "The identity of the datastore with which the
         instance data set is associated, e.g., the datastore from
         where the data was read or the datastore into which the data
         may be loaded or the datastore which is being documented.
         If a single specific datastore cannot be specified, the
         leaf MUST be absent.

         If this leaf is absent, then the datastore to which the
         instance data belongs is unspecified.";
    }
    list revision {
      key "date";
      description
        "Instance data sets that are produced as
         a result of some sort of specification or design effort
         SHOULD have at least one revision entry.  For every
         published editorial change, a new unique revision SHOULD
         be added in front of the revisions sequence so that all
         revisions are in reverse chronological order.

         In case of instance data sets that are read from
         or produced by a server or otherwise subject to
         frequent updates or changes, revision
         SHOULD NOT be present";
      leaf date {
        type string {
          pattern '\d{4}-(1[0-2]|0[1-9])-(0[1-9]|[1|2][0-9]|3[0-1])';
        }
        description
          "Specifies the date the instance data set
           was last modified. Formatted as YYYY-MM-DD";
      }
      leaf description {
        type string;
        description
          "Description of this revision of the instance data set.";
      }
    }
    leaf timestamp {
      type yang:date-and-time;
      description
        "The date and time when the instance data set
         was last modified.

         In case of instance data sets that are read from or
         produced by a server or otherwise subject to frequent
         updates or changes, timestamp SHOULD be present.

         If both a revision list entry and timestamp are present
         the timestamp SHOULD contain the same date as the
         latest revision statement.";
    }
    anydata content-data {
      description
        "Contains the real instance data.
         The data MUST conform to the relevant YANG modules
         specified either in the content-schema or in some other
         implementation specific manner.";
    }
  }
}
<CODE ENDS>
]]></artwork>
              </figure>
          </t>
      </section>
    </section>
                    
    <section anchor="security" title="Security Considerations">
      <t>The YANG module defined in this document only defines a wrapper structure
        specifying a format and a metadata header for YANG 
        instance data defined by the content-schema. Because of this  
        the security considerations template for YANG models in 
        section 3.7.1 in <xref target="RFC8407"/> is not followed.        
        The instance data is designed to be accessed as a stored file or 
        over any file access method or protocol.
      </t>
      <t>The document does not specify any method to influence the 
        behavior of a server.</t>
      <t>Instance data files may contain sensitive data.</t>
      <t>
        The header part is not security sensitive with one possible exception. 
        If the URI method is used for specification of the content schema and 
        the URI includes a username and/or a password, the instance data file 
        needs to be handled in a secure way as mentioned below.
      </t>
      <t>The security sensitivity of the instance data in the content 
        part is completely dependent on the content schema.
        Depending on the nature of the instance data, instance data 
        files MAY need to be handled securely. The same kind of 
        handling should be applied, that would be needed for the result 
        of a read operation returning the same data.
      </t>
      <t>Instance data files should be protected against modification or 
        unauthorized access using normal file handling mechanisms. 
        Care should be taken, when copying the original files or 
        providing file access for additional users, not to reveal 
        information unintentionally.
     </t>
    </section>
    <section anchor="iana" title="IANA Considerations">
      <t>This document registers one URI and one YANG module.</t>
      <section title="URI Registration">
        <t>This document registers one URI in the <xref target="RFC3688">
          IETF XML registry </xref>. Following the format in RFC 3688, the 
          following registration is requested to be made:</t>
        <t><figure><artwork>
URI: urn:ietf:params:xml:ns:yang:ietf-yang-instance-data
Registrant Contact: The IESG.
XML: N/A, the requested URI is an XML namespace.
        </artwork></figure></t>
      </section>
      <section title="YANG Module Name Registration">
        <t>This document registers one YANG module in the YANG Module Names
          registry <xref target="RFC6020"/>. Following the format in [RFC6020], 
          the following registrations are requested:
        </t>
        <t><figure><artwork>
name: ietf-yang-instance-data
namespace: urn:ietf:params:xml:ns:yang:ietf-yang-instance-data
prefix: yid
reference: RFC XXXX
// RFC Ed.: replace XXXX with RFC number and remove this note
        </artwork></figure></t>
      </section>
    </section> 
    <section title="Acknowledgments">
        <t>For their valuable comments, discussions, and feedback, we wish to 
        acknowledge Andy Bierman, Juergen Schoenwaelder, Rob Wilton, Joe Clarke, Kent Watsen
        Martin Bjorklund, Ladislav Lhotka, Qin Wu and other members of the Netmod WG.</t>
    </section>
  </middle>
  <?rfc needLines="20"?>
  <back>
    <references title="Normative References">
      <?rfc include='reference.RFC.7950'?>
      <?rfc include='reference.RFC.7951'?>
      <?rfc include='reference.RFC.7952'?>
      <?rfc include='reference.RFC.8526'?>
      <?rfc include='reference.RFC.8527'?>
      <?rfc include='reference.RFC.6243'?>
      <?rfc include="reference.RFC.8342"?>
      <?rfc include='reference.RFC.2119'?>
      <?rfc include='reference.RFC.8174'?>
      <?rfc include='reference.RFC.6991'?>
      <?rfc include='reference.RFC.8525'?>
      <?rfc include='reference.RFC.8791'?>
      <?rfc include='reference.RFC.6020'?>
    </references>
    <references title="Informative References">
      <?rfc include='reference.RFC.8641'?>
      <?rfc include='reference.RFC.8632'?>      
      <?rfc include='reference.RFC.3688'?>
      <?rfc include="reference.RFC.8340"?>
      <?rfc include="reference.RFC.8407"?>
      <?rfc include='reference.RFC.8792'?>      
      <?rfc include='reference.RFC.8808'?>      
    </references>
    <?rfc needLines="100"?>

    <section title="Changes between revisions">
      <t>RFC Ed.: Remove section "Changes between revisions"</t>
      <t>v15 - v16
        <list style="symbols">
          <t>Editorial changes</t>
        </list>
      </t>
      <t>v14 - v15
        <list style="symbols">
          <t>Removed reference to revision-label</t>
          <t>For the inline method made the usage of 
            ietf-yang-library@2019-01-04 mandatory. 
            Simplified the case "inline" in the YANG module.</t>
          <t>Removed the "inline-module" leaf as it does not carry 
            useful information anymore.</t>
          <t>Removed YANG feature</t>
        </list>
      </t>
      <t>v13 - v14
        <list style="symbols">
          <t>Added leaf includes-defaults</t>
          <t>Many small changes based on AD review</t>
        </list>
      </t>
      <t>v09 - v13
        <list style="symbols">
          <t>Editorial updates</t>
        </list>
      </t>
      <t>v08 - v09
        <list style="symbols">
          <t>Removed reference to similar to get reply</t>
          <t>Introduced artwork folding in the examples</t>          
        </list>
      </t>
      <t>v07 - v08
        <list style="symbols">
          <t>Moved compatibility into appendix</t>
          <t>Renamed yid-version to format-version. 
            Changed format to date of the YANG module</t>
          <t>Made support of ietf-yang-library mandatory if 
          inline-content-schema is supported</t>
          <t>Many small changes based on WGLC</t>
        </list>
      </t>
      <t>v06 - v07
        <list style="symbols">
          <t>Updated terminology, use-cases</t>
          <t>Many small changes based on WGLC</t>
        </list>
      </t>
      <t>v05 - v06
        <list style="symbols">
          <t>Modified module name format, removed .yin or .yang extension</t>
          <t>Removed pattern for module and inline-module. The 
            usage of revision-label should also be allowed.
          </t>
        </list>
      </t>
      <t>v04 - v05
        <list style="symbols">
          <t>Updated according to YANG-Doctor review</t>
          <t>Updated security considerations</t>
          <t>Added a wrapping container for the schema, and renamed the data 
            nodes in the inline and uri cases.
          </t>
          <t>Allowed .yin for simplified-inline schema naming. 
            Made date optional if it is unavailable in the YANG module.</t>
          <t>Added a mandatory yid-version to the header metadata to allow 
            later updates of the module.</t>
        </list>
      </t>
      <t>v03 - v04
        <list style="symbols">
          <t>removed entity-tag and last-modified timestamp</t>
          <t>Added simplified-inline method of content-schema specification</t>
        </list>
      </t>
      <t>v02 - v03
        <list style="symbols">
          <t>target renamed to "content-schema" and "content defining YANG 
            module(s)"</t>
          <t>Made name of instance data set optional</t>
          <t>Updated according to draft-ietf-netmod-yang-data-ext-03</t>
          <t>Clarified that entity-tag and last-modified timestamp are encoded 
          as metadata. While they contain useful data, the HTTP-header based 
          encoding from Restconf is not suitable.</t>
        </list>
      </t>
      <t>v01 - v02
        <list style="symbols">
          <t>Removed design time from terminology</t>
          <t>Defined the format of the content-data part by referencing various 
          RFCs and drafts instead of the result of the get-data and get operations.</t>
          <t>Changed target-ptr to a choice</t>
          <t>Inline target-ptr may include augmenting modules and alternatives to ietf-yang-library</t>
          <t>Moved list of target modules into a separate &lt;target-modules> element.</t>
          <t>Added backwards compatibility considerations</t>
        </list>
      </t>
      <t>v00 - v01
        <list style="symbols">
          <t>Added the target-ptr metadata with 3 methods</t>
          <t>Added timestamp metadata</t>
          <t>Removed usage of dedicated .yid file extension</t>
          <t>Added list of use cases</t>
          <t>Added list of principles</t>
          <t>Updated examples</t>
          <t>Moved detailed use case descriptions to appendix</t>
        </list>
      </t>
    </section>    

    <section title="Backwards Compatibility">
      <t>The concept of backwards compatibility and what changes are backwards 
      compatible are not defined for "instance data sets" as it is highly 
      dependent on the specific use case and the content-schema. 
      </t><t>
      In case of "instance data sets" that are the result of design or specification 
      activity, some changes that may be good to avoid are listed below. 
      </t><t>
      YANG uses the concept of managed entities identified by key 
      values; if the connection between the represented entity and the key 
      value is not preserved during an update, this may lead to the following problems.      
        <list style="symbols">
          <t>If the key value of a list entry that represents the same 
            managed entity as before is changed, the user may mistakenly 
            identify the list entry as new.</t>
          <t>If the meaning of a list entry is changed, but the key values 
            are not (e.g., redefining an alarm-type but not changing its 
            alarm-type-id) the change may not be noticed.</t>
          <t>If the key value of a previously removed list entry is reused 
            for a different entity, the change may be misinterpreted as 
            reintroducing the previous entity.</t>
        </list>
      </t>
    </section>

    <section title="Detailed Use Cases" anchor="detailed_use_cases">
      <t>This section is non-normative.</t>
      <section title="Use Case 1: Early Documentation of Server Capabilities">
        <t> A server has a number of server-capabilities that are defined 
          in YANG modules and can be retrieved from the server
          using protocols like NETCONF or RESTCONF. Server capabilities include:   
          <list style="symbols">
            <t> data defined in "ietf-yang-library": YANG modules, submodules, 
              features, deviations, schema-mounts, and datastores 
              supported (<xref target="RFC8525"/>)</t>
            <t>alarms supported (<xref target="RFC8632"/>)</t>
            <t>data nodes and subtrees that support or do not support on-change 
            notifications (<xref target="RFC8641"/>)</t>
            <t>netconf-capabilities in ietf-netconf-monitoring.</t>
          </list>
          While it is good practice to allow a client to query these capabilities 
          from the live server, that is often not possible. 
        </t>
        <t>
          Often when a network node is released, an associated NMS
          (network management system) is also released with it. The NMS depends on the capabilities of the server.          
          During NMS implementation, information about server capabilities is needed.
          If the information is unavailable early in some offline  
          document, but only as instance data from the live network node, the NMS implementation will be
          delayed, because it has to wait until the network node is ready. Also assuming
          that all NMS implementors will have a correctly configured network nodes 
          from which data can be retrieved, is a very expensive proposition. (An NMS may handle dozens
          of node types.)
        </t>  
          <t>
          Network operators often build their own home-grown NMS systems that 
          need to be integrated with a vendor's network node.  The operator
          needs to know the network node's server capabilities in order to do 
          this. Moreover, the network operator's decision to buy a vendor's 
          product may even be influenced by the network node's OAM feature set 
          documented as the server's capabilities.
        </t>  
        <t>
          Beside NMS implementors, system integrators and many others also need the same
          information early.  Examples could be model driven testing, generating documentation, etc.
          </t>
        <t>
          Most server-capabilities are relatively stable and change only during 
          upgrade or due to licensing or the addition or removal of hardware. They are 
          usually defined by a vendor at design time, before the product is released.
          It is feasible and advantageous to define/document them early 
          e.g., in a YANG instance data File.     
        </t>  
        <t>It is anticipated that a separate IETF document will define in
          detail how and which set of server capabilities should be documented.
        </t>
      </section>
      <section title="Use Case 2: Preloading Data">
        <t>
          There are parts of the configuration that must be fully configurable 
          by the operator. However, often a simple default configuration will
          be sufficient.
        </t><t>
          One example is access control groups/roles and related rules. 
          While a sophisticated operator may define dozens of different groups, 
          often a basic (read-only operator, read-write system administrator, 
          security-administrator) triplet will be enough.
          Vendors will often provide such default configuration data to make 
          device configuration easier for an operator.
        </t> <t>
          Defining access control data is a complex task.  To help, the device 
          vendor predefines a set of default groups (/nacm:nacm/groups) and rules 
          for these groups to access specific parts of common models (/nacm:nacm/rule-list/rule).
        </t>
        <t>
          YANG instance data files are used to document and/or preload the 
          default configuration.                             
        </t>
      </section>
      <section title="Use Case 3: Documenting Factory Default Settings">
        <t>
          Nearly every server has a factory default configuration. If the 
          system is really badly misconfigured or if the current configuration 
          is to be abandoned, the system can be reset the default factory 
          configuration.
        </t><t>
          The operator currently needs to know what the
          default configuration actually contains. 
          YANG instance data can be used to document the factory default
          configuration. See <xref target="RFC8808"></xref>.               
        </t>
      </section>
    </section>
    
  </back>
</rfc>
<!-- Local Variables: -->
<!-- fill-column:72 -->
<!-- End: -->
