Add RFC8641 model
[netconf.git] / model / rfc8641 / src / main / yang / ietf-yang-push@2019-09-09.yang
1 module ietf-yang-push {
2   yang-version 1.1;
3   namespace "urn:ietf:params:xml:ns:yang:ietf-yang-push";
4   prefix yp;
5
6   import ietf-yang-types {
7     prefix yang;
8     reference
9       "RFC 6991: Common YANG Data Types";
10   }
11   import ietf-subscribed-notifications {
12     prefix sn;
13     reference
14       "RFC 8639: Subscription to YANG Notifications";
15   }
16   import ietf-datastores {
17     prefix ds;
18     reference
19       "RFC 8342: Network Management Datastore Architecture (NMDA)";
20   }
21   import ietf-restconf {
22     prefix rc;
23     reference
24       "RFC 8040: RESTCONF Protocol";
25   }
26   import ietf-yang-patch {
27     prefix ypatch;
28     reference
29       "RFC 8072: YANG Patch Media Type";
30   }
31
32   organization
33     "IETF NETCONF (Network Configuration) Working Group";
34   contact
35     "WG Web:  <https:/datatracker.ietf.org/wg/netconf/>
36      WG List: <mailto:netconf@ietf.org>
37
38      Author:  Alexander Clemm
39               <mailto:ludwig@clemm.org>
40
41      Author:  Eric Voit
42               <mailto:evoit@cisco.com>";
43
44   description
45     "This module contains YANG specifications for YANG-Push.
46
47      The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL
48      NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED',
49      'MAY', and 'OPTIONAL' in this document are to be interpreted as
50      described in BCP 14 (RFC 2119) (RFC 8174) when, and only when,
51      they appear in all capitals, as shown here.
52
53      Copyright (c) 2019 IETF Trust and the persons identified as
54      authors of the code.  All rights reserved.
55
56      Redistribution and use in source and binary forms, with or
57      without modification, is permitted pursuant to, and subject to
58      the license terms contained in, the Simplified BSD License set
59      forth in Section 4.c of the IETF Trust's Legal Provisions
60      Relating to IETF Documents
61      (https://trustee.ietf.org/license-info).
62
63      This version of this YANG module is part of RFC 8641; see the
64      RFC itself for full legal notices.";
65
66   revision 2019-09-09 {
67     description
68       "Initial revision.";
69     reference
70       "RFC 8641: Subscriptions to YANG Datastores";
71   }
72
73   /*
74    * FEATURES
75    */
76
77   feature on-change {
78     description
79       "This feature indicates that on-change triggered subscriptions
80        are supported.";
81   }
82
83   /*
84    * IDENTITIES
85    */
86
87   /* Error type identities for datastore subscription */
88
89   identity resync-subscription-error {
90     description
91       "Problem found while attempting to fulfill a
92        'resync-subscription' RPC request.";
93   }
94
95   identity cant-exclude {
96     base sn:establish-subscription-error;
97     description
98       "Unable to remove the set of 'excluded-change' parameters.
99        This means that the publisher is unable to restrict
100        'push-change-update' notifications to just the change types
101        requested for this subscription.";
102   }
103
104   identity datastore-not-subscribable {
105     base sn:establish-subscription-error;
106     base sn:subscription-terminated-reason;
107     description
108       "This is not a subscribable datastore.";
109   }
110
111   identity no-such-subscription-resync {
112     base resync-subscription-error;
113     description
114       "The referenced subscription doesn't exist.  This may be as a
115        result of a nonexistent subscription ID, an ID that belongs to
116        another subscriber, or an ID for a configured subscription.";
117   }
118
119   identity on-change-unsupported {
120     base sn:establish-subscription-error;
121     description
122       "On-change is not supported for any objects that are
123        selectable by this filter.";
124   }
125
126   identity on-change-sync-unsupported {
127     base sn:establish-subscription-error;
128     description
129       "Neither 'sync-on-start' nor resynchronization is supported for
130        this subscription.  This error will be used for two reasons:
131        (1) if an 'establish-subscription' RPC includes
132        'sync-on-start' but the publisher can't support sending a
133        'push-update' for this subscription for reasons other than
134        'on-change-unsupported' or 'sync-too-big'
135        (2) if the 'resync-subscription' RPC is invoked for either an
136        existing periodic subscription or an on-change subscription
137        that can't support resynchronization.";
138   }
139
140   identity period-unsupported {
141     base sn:establish-subscription-error;
142     base sn:modify-subscription-error;
143     base sn:subscription-suspended-reason;
144     description
145       "The requested time period or 'dampening-period' is too short.
146        This can be for both periodic and on-change subscriptions
147        (with or without dampening).  Hints suggesting alternative
148        periods may be returned as supplemental information.";
149   }
150
151   identity update-too-big {
152     base sn:establish-subscription-error;
153     base sn:modify-subscription-error;
154     base sn:subscription-suspended-reason;
155     description
156       "Periodic or on-change push update data trees exceed a maximum
157        size limit.  Hints on the estimated size of what was too big
158        may be returned as supplemental information.";
159   }
160
161   identity sync-too-big {
162     base sn:establish-subscription-error;
163     base sn:modify-subscription-error;
164     base resync-subscription-error;
165     base sn:subscription-suspended-reason;
166     description
167       "The 'sync-on-start' or resynchronization data tree exceeds a
168        maximum size limit.  Hints on the estimated size of what was
169        too big may be returned as supplemental information.";
170   }
171
172   identity unchanging-selection {
173     base sn:establish-subscription-error;
174     base sn:modify-subscription-error;
175     base sn:subscription-terminated-reason;
176     description
177       "The selection filter is unlikely to ever select data tree
178        nodes.  This means that based on the subscriber's current
179        access rights, the publisher recognizes that the selection
180        filter is unlikely to ever select data tree nodes that change.
181        Examples for this might be that the node or subtree doesn't
182        exist, read access is not permitted for a receiver, or static
183        objects that only change at reboot have been chosen.";
184   }
185
186   /*
187    * TYPE DEFINITIONS
188    */
189
190   typedef change-type {
191     type enumeration {
192       enum create {
193         description
194           "A change that refers to the creation of a new
195            datastore node.";
196       }
197       enum delete {
198         description
199           "A change that refers to the deletion of a
200            datastore node.";
201       }
202       enum insert {
203         description
204           "A change that refers to the insertion of a new
205            user-ordered datastore node.";
206       }
207       enum move {
208         description
209           "A change that refers to a reordering of the target
210            datastore node.";
211       }
212       enum replace {
213         description
214           "A change that refers to a replacement of the target
215            datastore node's value.";
216       }
217     }
218     description
219       "Specifies different types of datastore changes.
220
221        This type is based on the edit operations defined for
222        YANG Patch, with the difference that it is valid for a
223        receiver to process an update record that performs a
224        'create' operation on a datastore node the receiver believes
225        exists or to process a delete on a datastore node the
226        receiver believes is missing.";
227     reference
228       "RFC 8072: YANG Patch Media Type, Section 2.5";
229   }
230
231   typedef selection-filter-ref {
232     type leafref {
233       path "/sn:filters/yp:selection-filter/yp:filter-id";
234     }
235     description
236       "This type is used to reference a selection filter.";
237   }
238
239   typedef centiseconds {
240     type uint32;
241     description
242       "A period of time, measured in units of 0.01 seconds.";
243   }
244
245   /*
246    * GROUP DEFINITIONS
247    */
248
249   grouping datastore-criteria {
250     description
251       "A grouping to define criteria for which selected objects from
252        a targeted datastore should be included in push updates.";
253     leaf datastore {
254       type identityref {
255         base ds:datastore;
256       }
257       mandatory true;
258       description
259         "Datastore from which to retrieve data.";
260     }
261     uses selection-filter-objects;
262   }
263
264   grouping selection-filter-types {
265     description
266       "This grouping defines the types of selectors for objects
267        from a datastore.";
268     choice filter-spec {
269       description
270         "The content filter specification for this request.";
271       anydata datastore-subtree-filter {
272         if-feature "sn:subtree";
273         description
274           "This parameter identifies the portions of the
275            target datastore to retrieve.";
276         reference
277           "RFC 6241: Network Configuration Protocol (NETCONF),
278                      Section 6";
279       }
280       leaf datastore-xpath-filter {
281         if-feature "sn:xpath";
282         type yang:xpath1.0;
283         description
284           "This parameter contains an XPath expression identifying
285            the portions of the target datastore to retrieve.
286
287            If the expression returns a node set, all nodes in the
288            node set are selected by the filter.  Otherwise, if the
289            expression does not return a node set, the filter
290            doesn't select any nodes.
291
292            The expression is evaluated in the following XPath
293            context:
294
295            o  The set of namespace declarations is the set of prefix
296               and namespace pairs for all YANG modules implemented
297               by the server, where the prefix is the YANG module
298               name and the namespace is as defined by the
299               'namespace' statement in the YANG module.
300
301               If the leaf is encoded in XML, all namespace
302               declarations in scope on the 'stream-xpath-filter'
303               leaf element are added to the set of namespace
304               declarations.  If a prefix found in the XML is
305               already present in the set of namespace declarations,
306               the namespace in the XML is used.
307
308            o  The set of variable bindings is empty.
309
310            o  The function library is comprised of the core
311               function library and the XPath functions defined in
312               Section 10 in RFC 7950.
313
314            o  The context node is the root node of the target
315               datastore.";
316         reference
317           "XML Path Language (XPath) Version 1.0
318            (https://www.w3.org/TR/1999/REC-xpath-19991116)
319            RFC 7950: The YANG 1.1 Data Modeling Language,
320                      Section 10";
321       }
322     }
323   }
324
325   grouping selection-filter-objects {
326     description
327       "This grouping defines a selector for objects from a
328        datastore.";
329     choice selection-filter {
330       description
331         "The source of the selection filter applied to the
332          subscription.  This will either (1) come referenced from a
333          global list or (2) be provided in the subscription itself.";
334       case by-reference {
335         description
336           "Incorporates a filter that has been configured
337            separately.";
338         leaf selection-filter-ref {
339           type selection-filter-ref;
340           mandatory true;
341           description
342             "References an existing selection filter that is to be
343              applied to the subscription.";
344         }
345       }
346       case within-subscription {
347         description
348           "A local definition allows a filter to have the same
349            lifecycle as the subscription.";
350         uses selection-filter-types;
351       }
352     }
353   }
354
355   grouping update-policy-modifiable {
356     description
357       "This grouping describes the datastore-specific subscription
358        conditions that can be changed during the lifetime of the
359        subscription.";
360     choice update-trigger {
361       description
362         "Defines necessary conditions for sending an event record to
363          the subscriber.";
364       case periodic {
365         container periodic {
366           presence "indicates a periodic subscription";
367           description
368             "The publisher is requested to periodically notify the
369              receiver regarding the current values of the datastore
370              as defined by the selection filter.";
371           leaf period {
372             type centiseconds;
373             mandatory true;
374             description
375               "Duration of time that should occur between periodic
376                push updates, in units of 0.01 seconds.";
377           }
378           leaf anchor-time {
379             type yang:date-and-time;
380             description
381               "Designates a timestamp before or after which a series
382                of periodic push updates are determined.  The next
383                update will take place at a point in time that is a
384                multiple of a period from the 'anchor-time'.
385                For example, for an 'anchor-time' that is set for the
386                top of a particular minute and a period interval of a
387                minute, updates will be sent at the top of every
388                minute that this subscription is active.";
389           }
390         }
391       }
392       case on-change {
393         if-feature "on-change";
394         container on-change {
395           presence "indicates an on-change subscription";
396           description
397             "The publisher is requested to notify the receiver
398              regarding changes in values in the datastore subset as
399              defined by a selection filter.";
400           leaf dampening-period {
401             type centiseconds;
402             default "0";
403             description
404               "Specifies the minimum interval between the assembly of
405                successive update records for a single receiver of a
406                subscription.  Whenever subscribed objects change and
407                a dampening-period interval (which may be zero) has
408                elapsed since the previous update record creation for
409                a receiver, any subscribed objects and properties
410                that have changed since the previous update record
411                will have their current values marshalled and placed
412                in a new update record.";
413           }
414         }
415       }
416     }
417   }
418
419   grouping update-policy {
420     description
421       "This grouping describes the datastore-specific subscription
422        conditions of a subscription.";
423     uses update-policy-modifiable {
424       augment "update-trigger/on-change/on-change" {
425         description
426           "Includes objects that are not modifiable once a
427            subscription is established.";
428         leaf sync-on-start {
429           type boolean;
430           default "true";
431           description
432             "When this object is set to 'false', (1) it restricts an
433              on-change subscription from sending 'push-update'
434              notifications and (2) pushing a full selection per the
435              terms of the selection filter MUST NOT be done for
436              this subscription.  Only updates about changes
437              (i.e., only 'push-change-update' notifications)
438              are sent.  When set to 'true' (the default behavior),
439              in order to facilitate a receiver's synchronization,
440              a full update is sent, via a 'push-update' notification,
441              when the subscription starts.  After that,
442              'push-change-update' notifications are exclusively sent,
443              unless the publisher chooses to resync the subscription
444              via a new 'push-update' notification.";
445         }
446         leaf-list excluded-change {
447           type change-type;
448           description
449             "Used to restrict which changes trigger an update.  For
450              example, if a 'replace' operation is excluded, only the
451              creation and deletion of objects are reported.";
452         }
453       }
454     }
455   }
456
457   grouping hints {
458     description
459       "Parameters associated with an error for a subscription
460        made upon a datastore.";
461     leaf period-hint {
462       type centiseconds;
463       description
464         "Returned when the requested time period is too short.  This
465          hint can assert a viable period for either a periodic push
466          cadence or an on-change dampening interval.";
467     }
468     leaf filter-failure-hint {
469       type string;
470       description
471         "Information describing where and/or why a provided filter
472          was unsupportable for a subscription.";
473     }
474     leaf object-count-estimate {
475       type uint32;
476       description
477         "If there are too many objects that could potentially be
478          returned by the selection filter, this identifies the
479          estimate of the number of objects that the filter would
480          potentially pass.";
481     }
482     leaf object-count-limit {
483       type uint32;
484       description
485         "If there are too many objects that could be returned by
486          the selection filter, this identifies the upper limit of
487          the publisher's ability to service this subscription.";
488     }
489     leaf kilobytes-estimate {
490       type uint32;
491       description
492         "If the returned information could be beyond the capacity
493          of the publisher, this would identify the estimated
494          data size that could result from this selection filter.";
495     }
496     leaf kilobytes-limit {
497       type uint32;
498       description
499         "If the returned information would be beyond the capacity
500          of the publisher, this identifies the upper limit of the
501          publisher's ability to service this subscription.";
502     }
503   }
504
505   /*
506    * RPCs
507    */
508
509   rpc resync-subscription {
510     if-feature "on-change";
511     description
512       "This RPC allows a subscriber of an active on-change
513        subscription to request a full push of objects.
514
515        A successful invocation results in a 'push-update' of all
516        datastore nodes that the subscriber is permitted to access.
517        This RPC can only be invoked on the same session on which the
518        subscription is currently active.  In the case of an error, a
519        'resync-subscription-error' is sent as part of an error
520        response.";
521     input {
522       leaf id {
523         type sn:subscription-id;
524         mandatory true;
525         description
526           "Identifier of the subscription that is to be resynced.";
527       }
528     }
529   }
530
531   rc:yang-data resync-subscription-error {
532     container resync-subscription-error {
533       description
534         "If a 'resync-subscription' RPC fails, the subscription is
535          not resynced and the RPC error response MUST indicate the
536          reason for this failure.  This yang-data MAY be inserted as
537          structured data in a subscription's RPC error response
538          to indicate the reason for the failure.";
539       leaf reason {
540         type identityref {
541           base resync-subscription-error;
542         }
543         mandatory true;
544         description
545           "Indicates the reason why the publisher has declined a
546            request for subscription resynchronization.";
547       }
548       uses hints;
549     }
550   }
551
552   augment "/sn:establish-subscription/sn:input" {
553     description
554       "This augmentation adds additional subscription parameters
555        that apply specifically to datastore updates to RPC input.";
556     uses update-policy;
557   }
558
559   augment "/sn:establish-subscription/sn:input/sn:target" {
560     description
561       "This augmentation adds the datastore as a valid target
562        for the subscription to RPC input.";
563     case datastore {
564       description
565         "Information specifying the parameters of a request for a
566          datastore subscription.";
567       uses datastore-criteria;
568     }
569   }
570
571   rc:yang-data establish-subscription-datastore-error-info {
572     container establish-subscription-datastore-error-info {
573       description
574         "If any 'establish-subscription' RPC parameters are
575          unsupportable against the datastore, a subscription is not
576          created and the RPC error response MUST indicate the reason
577          why the subscription failed to be created.  This yang-data
578          MAY be inserted as structured data in a subscription's
579          RPC error response to indicate the reason for the failure.
580          This yang-data MUST be inserted if hints are to be provided
581          back to the subscriber.";
582       leaf reason {
583         type identityref {
584           base sn:establish-subscription-error;
585         }
586         description
587           "Indicates the reason why the subscription has failed to
588            be created to a targeted datastore.";
589       }
590       uses hints;
591     }
592   }
593
594   augment "/sn:modify-subscription/sn:input" {
595     description
596       "This augmentation adds additional subscription parameters
597        specific to datastore updates.";
598     uses update-policy-modifiable;
599   }
600
601   augment "/sn:modify-subscription/sn:input/sn:target" {
602     description
603       "This augmentation adds the datastore as a valid target
604        for the subscription to RPC input.";
605     case datastore {
606       description
607         "Information specifying the parameters of a request for a
608          datastore subscription.";
609       uses datastore-criteria;
610     }
611   }
612
613   rc:yang-data modify-subscription-datastore-error-info {
614     container modify-subscription-datastore-error-info {
615       description
616         "This yang-data MAY be provided as part of a subscription's
617          RPC error response when there is a failure of a
618          'modify-subscription' RPC that has been made against a
619          datastore.  This yang-data MUST be used if hints are to be
620          provided back to the subscriber.";
621       leaf reason {
622         type identityref {
623           base sn:modify-subscription-error;
624         }
625         description
626           "Indicates the reason why the subscription has failed to
627            be modified.";
628       }
629       uses hints;
630     }
631   }
632
633   /*
634    * NOTIFICATIONS
635    */
636
637   notification push-update {
638     description
639       "This notification contains a push update that in turn contains
640        data subscribed to via a subscription.  In the case of a
641        periodic subscription, this notification is sent for periodic
642        updates.  It can also be used for synchronization updates of
643        an on-change subscription.  This notification shall only be
644        sent to receivers of a subscription.  It does not constitute
645        a general-purpose notification that would be subscribable as
646        part of the NETCONF event stream by any receiver.";
647     leaf id {
648       type sn:subscription-id;
649       description
650         "This references the subscription that drove the
651          notification to be sent.";
652     }
653     anydata datastore-contents {
654       description
655         "This contains the updated data.  It constitutes a snapshot
656          at the time of update of the set of data that has been
657          subscribed to.  The snapshot corresponds to the same
658          snapshot that would be returned in a corresponding 'get'
659          operation with the same selection filter parameters
660          applied.";
661     }
662     leaf incomplete-update {
663       type empty;
664       description
665         "This is a flag that indicates that not all datastore
666          nodes subscribed to are included with this update.  In
667          other words, the publisher has failed to fulfill its full
668          subscription obligations and, despite its best efforts, is
669          providing an incomplete set of objects.";
670     }
671   }
672
673   notification push-change-update {
674     if-feature "on-change";
675     description
676       "This notification contains an on-change push update.  This
677        notification shall only be sent to the receivers of a
678        subscription.  It does not constitute a general-purpose
679        notification that would be subscribable as part of the
680        NETCONF event stream by any receiver.";
681     leaf id {
682       type sn:subscription-id;
683       description
684         "This references the subscription that drove the
685          notification to be sent.";
686     }
687     container datastore-changes {
688       description
689         "This contains the set of datastore changes of the target
690          datastore, starting at the time of the previous update, per
691          the terms of the subscription.";
692       uses ypatch:yang-patch;
693     }
694     leaf incomplete-update {
695       type empty;
696       description
697         "The presence of this object indicates that not all changes
698          that have occurred since the last update are included with
699          this update.  In other words, the publisher has failed to
700          fulfill its full subscription obligations -- for example,
701          in cases where it was not able to keep up with a burst of
702          changes.";
703     }
704   }
705
706   augment "/sn:subscription-started" {
707     description
708       "This augmentation adds datastore-specific objects to
709        the notification that a subscription has started.";
710     uses update-policy;
711   }
712
713   augment "/sn:subscription-started/sn:target" {
714     description
715       "This augmentation allows the datastore to be included as
716        part of the notification that a subscription has started.";
717     case datastore {
718       uses datastore-criteria {
719         refine "selection-filter/within-subscription" {
720           description
721             "Specifies the selection filter and where it originated
722              from.  If the 'selection-filter-ref' is populated, the
723              filter in the subscription came from the 'filters'
724              container.  Otherwise, it is populated in-line as part
725              of the subscription itself.";
726         }
727       }
728     }
729   }
730
731   augment "/sn:subscription-modified" {
732     description
733       "This augmentation adds datastore-specific objects to
734        the notification that a subscription has been modified.";
735     uses update-policy;
736   }
737
738   augment "/sn:subscription-modified/sn:target" {
739     description
740       "This augmentation allows the datastore to be included as
741        part of the notification that a subscription has been
742        modified.";
743     case datastore {
744       uses datastore-criteria {
745         refine "selection-filter/within-subscription" {
746           description
747             "Specifies the selection filter and where it originated
748              from.  If the 'selection-filter-ref' is populated, the
749              filter in the subscription came from the 'filters'
750              container.  Otherwise, it is populated in-line as part
751              of the subscription itself.";
752         }
753       }
754     }
755   }
756
757   /*
758    * DATA NODES
759    */
760
761   augment "/sn:filters" {
762     description
763       "This augmentation allows the datastore to be included as part
764        of the selection-filtering criteria for a subscription.";
765     list selection-filter {
766       key "filter-id";
767       description
768         "A list of preconfigured filters that can be applied
769          to datastore subscriptions.";
770       leaf filter-id {
771         type string;
772         description
773           "An identifier to differentiate between selection
774            filters.";
775       }
776       uses selection-filter-types;
777     }
778   }
779
780   augment "/sn:subscriptions/sn:subscription" {
781     when 'yp:datastore';
782     description
783       "This augmentation adds objects to a subscription that are
784        specific to a datastore subscription, i.e., a subscription to
785        a stream of datastore node updates.";
786     uses update-policy;
787   }
788
789   augment "/sn:subscriptions/sn:subscription/sn:target" {
790     description
791       "This augmentation allows the datastore to be included as
792        part of the selection-filtering criteria for a subscription.";
793     case datastore {
794       uses datastore-criteria;
795     }
796   }
797 }