module ietf-netconf-system-notifications {

   namespace
     "urn:ietf:params:xml:ns:yang:ietf-netconf-system-notifications";

   prefix nc-sys-notif;

   import ietf-inet-types { prefix inet; }
   import ietf-netconf { prefix nc; }

   organization
    "IETF NETCONF (Network Configuration Protocol) Working Group";

   contact
    "WG Web:   <http://tools.ietf.org/wg/netconf/>
     WG List:  <mailto:netconf@ietf.org>

     WG Chair: Bert Wijnen
               <mailto:bertietf@bwijnen.net>

     WG Chair: Mehmet Ersue
               <mailto:mehmet.ersue@nsn.com>

     Editor: Andy Bierman
             <mailto:andy.bierman@brocade.com>";

   description
    "This module defines an YANG data model for use with the
     NETCONF protocol that allows the NETCONF client to
     receive common system events.

     Copyright (c) 2010 IETF Trust and the persons identified as
     the document authors.  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 actual RFC number and remove this note

   // RFC Ed.: remove this note
   // Note: extracted from
   // draft-ietf-netconf-system-notifications-01.txt

   revision 2010-10-21 {
     description
       "Initial version.";
     reference
      "RFC XXXX: NETCONF System Notifications";
   }
   // RFC Ed.: replace XXXX with actual
   // RFC number and remove this note

  grouping sys-common-session-parms {

    leaf user-name {
      description
        "Name of the user for the session.";
      type string;
    }

    leaf session-id {
      description "Identifier of the session.";
      type nc:session-id-or-zero-type;
    }

    leaf remote-host {
      description
        "Address of the remote host for the session.";
      type inet:ip-address;
    }
  }

  grouping changed-by-parms {
    container changed-by {
      description
        "Indicates who caused this change.
        If caused by internal action, then the
        empty leaf 'server' will be present.
        If caused by a management session, then
        the name, remote host address, and session ID
        of the session that made the change will be reported.";
      choice server-or-user {
        leaf server {
          type empty;
          description
            "If present, the change was caused
             by the server.";
        }

        case by-user {
          uses sys-common-session-parms {
            refine session-id {
              mandatory true;
            }
          }
        }
      } // choice server-or-user
    } // container changed-by-parms;
  }

  notification sys-config-change {
    description
      "Generated when the <running> or <startup> configuration
       database is changed.";

    uses changed-by-parms;

    list edit {
      description
        "An edit record will be present for each distinct
        edit operation on the target database.";

      leaf target-database {
        type enumeration {
          enum running {
            description "The running database has changed.";
          }
          enum startup {
            description "The startup database has changed";
          }
        }
        description
          "Indicates which configuration database has changed.";
        default "running";
      }

      leaf target {
        type instance-identifier;
        description
          "Topmost node associated with the configuration change.
           A server SHOULD set this object to the node within
           the database which is being altered.  A server MAY
           set this object to one of the ancestors of the actual
           node that was changed, or omit this object, if the
           exact node is not known.";
      }

      leaf operation {
        type nc:edit-operation-type;
        description
           "Type of edit operation performed.
            A server SHOULD set this object to the NETCONF edit
            operation performed on the target database.";
      }
    } // list edit
  } // notification sys-config-change

  notification sys-capability-change {
    description
      "Generated when a <capability> is added, deleted,
       or modified.";

    uses changed-by-parms;

    leaf-list added-capability {
      type inet:uri;
      description
        "List of capabilities that have just been added.";
    }

    leaf-list deleted-capability {
      type inet:uri;
      description
        "List of capabilities that have just been deleted.";
    }

    leaf-list modified-capability {
      type inet:uri;
      description
        "List of capabilities that have just been modified.
         A capability is considered to be modified if the
         base URI for the capability has not changed, but
         one or more of the parameters encoded at the end of
         the capability URI has changed.";
    }
  } // notification sys-capability-change

  notification sys-session-start {
    description
      "Generated when a new NETCONF session is started.";
    uses sys-common-session-parms {
      refine session-id {
        mandatory true;
      }
    }
  } // notification sys-session-start

  notification sys-session-end {
    description
      "Generated when a NETCONF session is terminated.";

    uses sys-common-session-parms {
      refine session-id {
        mandatory true;
      }
    }

    leaf killed-by {
      when "../termination-reason = 'killed'";
      type nc:session-id-type;
      description
        "Session ID that issued the <kill-session>
        if the session was terminated by this operation.";
    }

    leaf termination-reason {
      type enumeration {
        enum "closed" {
          value 0;
          description
            "The session was terminated with
            the <close-session> operation.";
        }
        enum "killed" {
          value 1;
          description
            "The session was terminated with
            the NETCONF <kill-session> operation.";
        }
        enum "dropped" {
          value 2;
          description
            "The session was terminated because
            the SSH session or TCP connection was
            unexpectedly closed.";
        }
        enum "timeout" {
          value 3;
          description
            "The session was terminated because
            of inactivity, either waiting for
            the <hello> or <rpc> messages.";
        }
        enum "bad-hello" {
          value 4;
          description
            "The client's <hello> message was
            bad or never arrived.";
        }
        enum "other" {
          value 5;
          description
            "The session was terminated for
            some other reason.";
        }
      }
      mandatory "true";
      description "Reason the session was terminated.";
    }
  } // notification sys-session-end

  notification sys-confirmed-commit {
    description
      "Generated when a confirmed-commit event occurs.";
    uses sys-common-session-parms;

    leaf confirm-event {
      description
        "Indicates the event that caused the notification.";
      type enumeration {
        enum "start" {
          value 0;
          description
            "The confirm-commit procedure has started.";
        }
        enum "cancel" {
          value 1;
          description
            "The confirm-commit procedure has been canceled,
            due to the session being terminated.";
        }
        enum "timeout" {
          value 2;
          description
            "The confirm-commit procedure has been canceled,
            due to the confirm-timeout interval expiring.
            The common session parameters will not be present
            in this sub-mode.";
        }
        enum "extend" {
          value 3;
          description
            "The confirm-commit timeout has been extended.";
        }
        enum "complete" {
          value 4;
          description
            "The confirm-commit procedure has been completed.";
        }
      }
      mandatory "true";
    }

    leaf timeout {
      when
       "../confirm-event = 'start' or ../confirm-event = 'extend'";
      description
       "The configured timeout value if the event type
        is 'start' or 'extend'.  This value represents the
        the approximate number of seconds from the event
        time when the 'timeout' event might occur.";
      units "seconds";
      type uint32;
    }
  } // notification sys-confirmed-commit
}
