module yuma-time-filter {

    namespace "http://netconfcentral.org/ns/yuma-time-filter";

    prefix "timefilter";

    import ietf-yang-types { prefix yang; }

    import ietf-netconf-monitoring { prefix mon; }

    import ietf-netconf { prefix nc; }

    organization  "Netconf Central";

    contact "Andy Bierman <andy@netconfcentral.org>.";

    description 
      "Yuma <datastore> extension for optimizing datastore
       polling mechanisms by allowing the client to
       request datastore content only if it has been modified since
       a specified date and time.

       If the netconfd server advertises this module then
       the 'last-modified' XML attribute will be added
       to the <rpc-reply> element if there was no 'last-modified'
       attribute in the <rpc> element.  This is only done
       for the NETCONF <get> and <get-config> protocol operations.

       Example:

       <rpc message-id='2' 
           xmlns='urn:ietf:params:xml:ns:netconf:base:1.0'>
         <get />
       </rpc>

       <rpc-reply message-id='2' 
          last-modified='2011-08-14T00:16:49Z'
          xmlns='urn:ietf:params:xml:ns:netconf:base:1.0'>
         <data> ... </data>
       </rpc-reply>

     Copyright (c) 2011 - 2012 Andy Bierman 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 BSD 3-Clause License
     http://opensource.org/licenses/BSD-3-Clause";

    reference
      "RFC 2616: Last-Modified and If-Modified-Since headers";

    revision 2012-11-15 {
        description  
          "Use import of ietf-netconf instead of yuma-netconf
           so the ietf-netconf module can be advertised in the
           hello and clients will know which version is used
           for imported data types.";
    }

    revision 2011-08-13 {
        description  
	  "Initial version.";
    }

    augment /mon:netconf-state/mon:datastores/mon:datastore {
      leaf last-modified {
        description
          "The date and time when the server last detected
           that the datastore was changed, or last initialized
           if no changes have been made.  Note that state data
           is not included in a datastore, and modifications
           to state data do not affect this timestamp.";
        type yang:date-and-time;
      }
    }

    grouping if-modified-since-parm {
      leaf if-modified-since {
        description
          "If this parameter is present, then the server will
           only process the retrieval request if the
           corresponding 'last-modified' timestamp is
           more recent than this timestamp. If so, then the
           retrieval request is processed as normal.
           If not, an empty <data> element will be returned.";
        type yang:date-and-time;
      }
    }

    augment /nc:get-config/nc:input {
      uses if-modified-since-parm;
    }

    augment /nc:get/nc:input {
      uses if-modified-since-parm;
    }

}
