Bug 8523: Add support for parsing restconf:yang-data extension
[yangtools.git] / yang / yang-parser-impl / src / test / resources / yang-data-extension-test / ietf-restconf.yang
1 module ietf-restconf {
2   yang-version 1.1;
3   namespace "urn:ietf:params:xml:ns:yang:ietf-restconf";
4   prefix "rc";
5
6   organization
7     "IETF NETCONF (Network Configuration) Working Group";
8
9   contact
10     "WG Web:   <https://datatracker.ietf.org/wg/netconf/>
11      WG List:  <mailto:netconf@ietf.org>
12      Author:   Andy Bierman
13                <mailto:andy@yumaworks.com>
14      Author:   Martin Bjorklund
15                <mailto:mbj@tail-f.com>
16      Author:   Kent Watsen
17                <mailto:kwatsen@juniper.net>";
18
19   description
20     "This module contains conceptual YANG specifications
21      for basic RESTCONF media type definitions used in
22      RESTCONF protocol messages.
23      Note that the YANG definitions within this module do not
24      represent configuration data of any kind.
25      The 'restconf-media-type' YANG extension statement
26      provides a normative syntax for XML and JSON
27      message-encoding purposes.
28      Copyright (c) 2017 IETF Trust and the persons identified as
29      authors of the code.  All rights reserved.
30      Redistribution and use in source and binary forms, with or
31      without modification, is permitted pursuant to, and subject
32      to the license terms contained in, the Simplified BSD License
33      set forth in Section 4.c of the IETF Trust's Legal Provisions
34      Relating to IETF Documents
35      (http://trustee.ietf.org/license-info).
36      This version of this YANG module is part of RFC 8040; see
37      the RFC itself for full legal notices.";
38
39   revision 2017-01-26 {
40     description
41       "Initial revision.";
42     reference
43       "RFC 8040: RESTCONF Protocol.";
44   }
45
46   extension yang-data {
47     argument name {
48       yin-element true;
49     }
50     description
51       "This extension is used to specify a YANG data template that
52        represents conceptual data defined in YANG.  It is
53        intended to describe hierarchical data independent of
54        protocol context or specific message-encoding format.
55        Data definition statements within a yang-data extension
56        specify the generic syntax for the specific YANG data
57        template, whose name is the argument of the 'yang-data'
58        extension statement.
59        Note that this extension does not define a media type.
60        A specification using this extension MUST specify the
61        message-encoding rules, including the content media type.
62        The mandatory 'name' parameter value identifies the YANG
63        data template that is being defined.  It contains the
64        template name.
65        This extension is ignored unless it appears as a top-level
66        statement.  It MUST contain data definition statements
67        that result in exactly one container data node definition.
68        An instance of a YANG data template can thus be translated
69        into an XML instance document, whose top-level element
70        corresponds to the top-level container.
71        The module name and namespace values for the YANG module using
72        the extension statement are assigned to instance document data
73        conforming to the data definition statements within
74        this extension.
75        The substatements of this extension MUST follow the
76        'data-def-stmt' rule in the YANG ABNF.
77        The XPath document root is the extension statement itself,
78        such that the child nodes of the document root are
79        represented by the data-def-stmt substatements within
80        this extension.  This conceptual document is the context
81        for the following YANG statements:
82          - must-stmt
83          - when-stmt
84          - path-stmt
85          - min-elements-stmt
86          - max-elements-stmt
87          - mandatory-stmt
88          - unique-stmt
89          - ordered-by
90          - instance-identifier data type
91        The following data-def-stmt substatements are constrained
92        when used within a 'yang-data' extension statement.
93          - The list-stmt is not required to have a key-stmt defined.
94          - The if-feature-stmt is ignored if present.
95          - The config-stmt is ignored if present.
96          - The available identity values for any 'identityref'
97            leaf or leaf-list nodes are limited to the module
98            containing this extension statement and the modules
99            imported into that module.
100       ";
101   }
102
103   rc:yang-data yang-errors {
104     uses errors;
105   }
106
107   rc:yang-data yang-api {
108     uses restconf;
109   }
110
111   grouping errors {
112     description
113       "A grouping that contains a YANG container
114        representing the syntax and semantics of a
115        YANG Patch error report within a response message.";
116
117     container errors {
118       description
119         "Represents an error report returned by the server if
120          a request results in an error.";
121
122       list error {
123         description
124           "An entry containing information about one
125            specific error that occurred while processing
126            a RESTCONF request.";
127         reference
128           "RFC 6241, Section 4.3.";
129
130         leaf error-type {
131           type enumeration {
132             enum transport {
133               description
134                 "The transport layer.";
135             }
136             enum rpc {
137               description
138                 "The rpc or notification layer.";
139             }
140             enum protocol {
141               description
142                 "The protocol operation layer.";
143             }
144             enum application {
145               description
146                 "The server application layer.";
147             }
148           }
149           mandatory true;
150           description
151             "The protocol layer where the error occurred.";
152         }
153
154         leaf error-tag {
155           type string;
156           mandatory true;
157           description
158             "The enumerated error-tag.";
159         }
160
161         leaf error-app-tag {
162           type string;
163           description
164             "The application-specific error-tag.";
165         }
166
167         leaf error-path {
168           type instance-identifier;
169           description
170             "The YANG instance identifier associated
171              with the error node.";
172         }
173
174         leaf error-message {
175           type string;
176           description
177             "A message describing the error.";
178         }
179
180         anydata error-info {
181            description
182              "This anydata value MUST represent a container with
183               zero or more data nodes representing additional
184               error information.";
185         }
186       }
187     }
188   }
189
190   grouping restconf {
191     description
192       "Conceptual grouping representing the RESTCONF
193        root resource.";
194
195     container restconf {
196       description
197         "Conceptual container representing the RESTCONF
198          root resource.";
199
200       container data {
201         description
202           "Container representing the datastore resource.
203            Represents the conceptual root of all state data
204            and configuration data supported by the server.
205            The child nodes of this container can be any data
206            resources that are defined as top-level data nodes
207            from the YANG modules advertised by the server in
208            the 'ietf-yang-library' module.";
209       }
210
211       container operations {
212         description
213           "Container for all operation resources.
214            Each resource is represented as an empty leaf with the
215            name of the RPC operation from the YANG 'rpc' statement.
216            For example, the 'system-restart' RPC operation defined
217            in the 'ietf-system' module would be represented as
218            an empty leaf in the 'ietf-system' namespace.  This is
219            a conceptual leaf and will not actually be found in
220            the module:
221               module ietf-system {
222                 leaf system-reset {
223                   type empty;
224                 }
225               }
226            To invoke the 'system-restart' RPC operation:
227               POST /restconf/operations/ietf-system:system-restart
228            To discover the RPC operations supported by the server:
229               GET /restconf/operations
230            In XML, the YANG module namespace identifies the module:
231              <system-restart
232                 xmlns='urn:ietf:params:xml:ns:yang:ietf-system'/>
233            In JSON, the YANG module name identifies the module:
234              { 'ietf-system:system-restart' : [null] }
235           ";
236       }
237
238       leaf yang-library-version {
239         type string {
240           pattern '\d{4}-\d{2}-\d{2}';
241         }
242         config false;
243         mandatory true;
244         description
245           "Identifies the revision date of the 'ietf-yang-library'
246            module that is implemented by this RESTCONF server.
247            Indicates the year, month, and day in YYYY-MM-DD
248            numeric format.";
249       }
250     }
251   }
252
253 }