module yumaworks-extensions {

  namespace "http://yumaworks.com/ns/yumaworks-extensions";

  prefix "ywx";

  organization "YumaWorks, Inc.";

  contact
    "Support <support@yumaworks.com>";

  description
    "This module contains definitions for YumaWorks YANG extensions.

     Copyright (c) 2012 - 2024 YumaWorks, Inc. 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";

  revision 2025-05-19 {
    description
       "24.10T-9:
         - Add cli-enforce-table extension.
         - Add cli-suppress-table extension.";
  }

  revision 2024-04-04 {
    description
       "23.10-8:
         - Add confirm-data extension.";
  }

  revision 2024-03-16 {
    description
       "23.10-7:
         - Add hidden-from-cli extension.";
  }

  revision 2024-03-04 {
    description
       "23.10-6:
         - Add sort-type extension.";
  }

  revision 2023-04-19 {
    description
       "Add sil-xpath-function extension.";
  }

  revision 2021-12-14 {
    description
       "Update sil-aio-get2 extension. Remove reference to default values.";
  }

  revision 2020-03-31 {
    description
       "Update sil-aio-get2 extension. Add argument parameter to it";
  }

  revision 2019-12-06 {
    description
       "Add xpath-operational-ok extension.
        Add sil-aio-get2 extension.";
  }

  revision 2019-01-04 {
    description
       "Add sil-test-get-when extension.";
  }

  revision 2018-03-24 {
    description
       "Add errmsg and sub-statement extensions.";
  }

  revision 2018-01-08 {
    description
       "Add no-sil-delete-children-first extension.";
  }

  revision 2017-12-26 {
    description
       "Add no-nvstore extension.";
  }

  revision 2015-05-08 {
    description
       "Add sil-priority extension.";
  }

  revision 2014-08-10 {
    description
       "Add sil-force-replace-replay extension.";
  }

  revision 2014-06-05 {
    description
       "Add sil-force-replay extension.";
  }

  revision 2014-04-08 {
    description
       "Add datapath extension.";
  }

  revision 2013-11-23 {
    description
       "Add exclusive-rpc extension.";
  }

  revision 2013-05-30 {
    description
       "Fix some missing argument clauses in the documentation.
        Comment out notif-root and rpc-hook extensions for now because
        they are not used in YANG-API.";
  }

  revision 2013-01-27 {
    description
       "Add help string extension.";
  }

  revision 2012-06-28 {
    description
       "Initial version";
  }

  extension alt-name {
    argument name {
      yin-element false;
    }

    description
      "Used within a data node definition to specify an alternate
       name for the node.  The --alt-names parameter must
       be enabled for these names to be used.  The argument is the
       alternate name to use.  It must be a valid YANG identifier.";
  }

  extension rpc-root {
    description
      "Used within a container definition to indicate it is
       really a root container for a conceptual NETCONF
       operations, instead of just a container. The container
       is expected to be empty.  Any top-level rpc-stmt can
       be specified using a QName value with the same module
       and local name as the RPC operation definition.
       This extension is reserved and only used by the server.";
  }

  extension urlpath {
    description
      "Used within a leaf or leaf-list definition to indicate it is
       really a REST URI path string, not a plain string.";
  }

  extension cli-text-block {
    description
      "If this extension is present in an empty container
       or list, it will be treated in unit-test parsing as a
       container or list of ordered text commands, 1 per line.
       Line extension is needed to wrap a command into
       many lines.

       Example YANG:

        container setup {
           ywx:cli-text-block;
        }

       Example test script or conf file usage:

        setup {
          run test1-script
          get-config source=running
          lock target=candidate
        }
      ";
  }

  extension cli-enforce-table {
    description
      "Used within a list data definition statement
       to indicate that the 'show' command should
       print the server repsonse as a table, even
       if it would be skipped for some reason.

       There is no parameter for this extension.
       Ignored unless the --show-table parameter is
       set to 'true'.

       This extension will override the
       --show-table-force parameter setting
       for the specified list object.
      ";
  }

  extension cli-suppress-table {
    description
      "Used within a list data definition statement
       to indicate that the 'show' command should
       not print the server repsonse as a table.

       There is no parameter for this extension.
       Ignored unless the --show-table parameter is
       set to 'true'.

       This extension will override the
       --show-table-force parameter setting
       for the specified list object.
      ";
  }

  extension help {
    description
      "Used within a rpc or data definition statement to
       provide a short help text string for CLI
       and other applications to use in addition to
       the description statement.

       The 'helptext' argument is the help text string,
       which should be 60 characters or less in length.";
    argument helptext {
      yin-element true;
    }
  }

  extension exclusive-rpc {
    description
      "Used within an rpc definition statement to
       indicate that the RPC is not allowed to be called
       concurrently by different sessions.  The server will
       return an in-use error if another session is currently
       invoking the RPC operation and this extension is present
       in the rpc-stmt.";
  }

  extension datapath {
    description
      "Used within a container or anyxml definition to indicate
       that the object path for the data node should be sent
       in the value as an attribute.  The SIL-SA parser will use
       the datapath attribute to select the object template
       to use for parsing, instead of generic anyxml.

          anyxml newval {
            ywx:datapath;
          }
          anyxml curval {
            ywx:datapath;
          }

          If /foo/bar/leaf2 is edited, the <edit> message
          will be generated with the datapath attribute
          from the yumaworks-attrs module.

           <newval ywattrs:datapath='/foo/bar/leaf2'>42</newval>
           <curval ywattrs:datapath='/foo/bar/leaf2'>67</curval>
      ";
  }

  extension sil-force-replay {
    description
      "Used within a configuration data node definition statement
       to indicate that the SIL (or SIL-SA) callback should be
       invoked even for nodes that are not changing.  At least
       one descendant-or-self node must be changing in order
       for any of the SIL callbacks for unchanged sibling nodes
       to be invoked.";
  }

  extension sil-force-replace-replay {
    description
      "Used within a configuration data node definition statement
       to indicate that the SIL (or SIL-SA) callback should be
       invoked even for nodes that are not changing, during a
       replace operation.  All SIL callbacks for child nodes
       in the replace request (where the parent node contains
       this extension) will be invoked during edit processing.

       If this extension is used within a list statement, then
       SIL callbacks for all instances of the list that are
       provided in the replace operation will be invoked.";
  }

  extension sil-priority {
    description
      "Used to control the order that SIL or SIL-SA callbacks
       are invoked for specific objects.

       If this extension is used within a configuration database
       object then the SIL priority for the object will be assigned
       the value of the 'prio' argument.

       Only the order of the 'apply', 'commit' and 'rollback'
       callback phases will be affected by this parameter.
       The 'validate' phase callbacks are invoked in the
       order they appear in the edit request.

       The 'prio' argument must be a number between 1 and 255.
       If two objects are edited in the same edit request, the
       the one with the lowest SIL priority number will be
       executed first.

       If no sil-priority is set for an object, then the value
       of its nearest ancestor with the sil-priority extension
       set will be used. If there is none, the default
       value of '255' will be used.

       If the SIL priority is the same for two objects in the
       same edit request, then the server will pick an order
       in an implementation-specific manner.";
    argument prio;
  }

  extension no-nvstore {
    description
      "Used within a configuration data node definition statement
       to indicate that configuration changes made to the object
       will not be stored in non-volatile storage. The configuration
       node will be handled in an implementation-specific manner.
       There is no argument defined for this extension.
       The extension applies to the specified node and all
       its descendants.";
  }

  extension no-sil-delete-children-first {
    description
      "Used within a configuration data node definition statement
       to indicate that the --sil-delete-children-first parameter
       should be ignored for this subtree, if it is set to 'true'.

       Faster server performance can be achieved by deleting
       an entire subtree at once, and this extension allows
       the developer to force this behavior for the selected
       SIL libraries that can support such deletion.

       This is the opposite of the sil-delete-children-first
       extension. Note that this extension applies to the
       entire subtree, not just the node that contains this
       extension. There are no parameters defined.";
  }

  extension errmsg {
    description
      "Used within a data node statement to define
       a custom error-message filed within an 'rpc-error'
       or 'error' structure for some or all error conditions.

       The string format is restricted to plain text with
       the exception of the 2 character sequence '%s'.
       This special sequence will be replaced in the
       dynamic error message generation if an errmsg-parm
       statement is found to match the escape sequence.

       If this extension statement has no sub-statements,
       then it matches all errors for the object.
       If 'errmsg-tag' sub-statements are found, then
       this entry will match only those error-tag values.
       If 'errmsg-apptag' sub-statements are found, then
       this entry will match only those error-app-tag values.

       The 'basestr' argument must be a formatted string.
       If any parameters are specified, then the corresponding
       'errmsg-parm' extension statements must be encoded within
       this errmsg statement.

       Multiple errmsg statements can be present in the same
       data node statement. They will be processed in order
       and the first matching statement will be used to
       generate the error-message value.

       Example:

          leaf my-network-id {
            type int32;
            ywx:errmsg 'Not a valid network ID for interface %s' {
              ywx:errmsg-parm '../../if:name';
              ywx:errmsg-apptag 'network-error';
            }
          }
      ";
    argument basestr;
  }

  extension errmsg-parm {
    description
      "Used within an errmsg statement to define
       a parameter for expansion within the errmsg basestr.
       There should be the correct number of expected parameters
       for the corresponding 'basestr' format string.

       The 'parmstr' argument must be an XPath path expression.
       The context node will be the data node containing the
       errmsg statement.
      ";
     argument parmstr;
   }

  extension errmsg-tag {
    description
      "Used within an errmsg statement to define an
       error-tag value that will filter this errmsg.
       Multiple errmsg-tag and/or errmsg-apptag values
       form a conceptual OR expression.

       The 'tagstr' argument must be the error-tag value
       that will be matched.
      ";
    argument tagstr;
  }

  extension errmsg-apptag {
    description
      "Used within an errmsg statement to define an
       error-app-tag value that will filter this errmsg.
       Multiple errmsg-tag and/or errmsg-apptag values
       form a conceptual OR expression.

       The 'apptagstr' argument must be the error-app-tag
       value that will be matched.
      ";
    argument apptagstr;
  }

  extension errmsg-lang {
    description
      "Used within an errmsg statement to define the
       language code value that will filter this errmsg.
       Only one errmsg-lang statement may appear within
       an errmsg statement. The 'langstr' value will
       be compared to the 'errmsg-lang' CLI variable setting.
       If the strings are the same, the entry is used.

       If this statement is not present, then the errmsg entry
       will be used regardless of the 'errmsg-lang' CLI variable
       setting.

       The 'langstr' argument must be the language code
       value that will be matched.
      ";
    argument langstr;
  }

  extension sil-test-get-when {
    description
      "Used within a data definition statement to define
       the --sil-get-test-when CLI parameter behavior for
       a single object. This extension does not affect the
       descendant data nodes.

       The 'boolval' argument must be the string 'true'
       or 'false'; If 'true' the object will be tested
       for when-stmts if any need to be evaluated during
       retrieval operations. If 'false' then any when-stmts
       will be ignored during retrieval operations.

       This extension will override the --sil-test-get-when
       global CLI parameter. This extension will have no affect
       unless the value is different than this CLI parameter.
      ";
    argument boolval;
  }

  extension sil-aio-get2 {
    description
      "Used within a data definition statement to define
       the GET2 retrieval mechanism.
       This extension affects the descendant data nodes.

       This extension can be used in a container or list
       to force the server to treat that data subtree as
       a terminal node for GET2.

       The entire subtree would be expected in one retrieval
       in one callback invocation.

       The entire subtree can be specified in the JSON
       or XML buffer that will be used for return values.
       The server will parse and handle the buffer and process
       retrieval based on the provide JSON or XML encoded buffer.

       The 'parmstr' argument can specify the encoding that will
       be used in the callback. Available options are:

         - xml: XML element in a buffer is expected in return value
         - json: JSON object in a buffer is expected in return value
         - val: val_value_t tree is expected in return value
      ";
    argument parmstr;
  }

  extension xpath-operational-ok {
    description
      "Used within a data-definition statement for a configuration
       data node to alter the must-stmt and when-stmt found within
       the data node. This allows an XPath expression in such a node
       to reference config=false data nodes.

       This property does not apply to any child nodes, just the data
       node containing this external statement.

       This violates the standard in RFC 7950, sec 6.4.1 so use with
       caution since the YANG module will not be valid according to
       YANG 1.1 rules.

       There is no parameter for this extension.
      ";
  }

  extension sil-xpath-function {
    description
      "Used within a configuration data node definition
       statement to define the YANG XPath Callback function
       for the object.

       It can also be added to a node using an annotation.
       This extension affects only the node containing the
       extension. The following data nodes are supported:

         - container
         - list
         - leaf
         - leaf-list
         - anydata
         - anyxml

       Other data definition statements are allowed to have
       must or when statements but the context node will
       be one of the types listed above.  The callback function
       is invoked any time the data node containing this extension
       is used as the context node for a must/when XPath evaluation.

       This callback can be used to replace real must/when
       XPath expression evaluation, in case the constraint
       is enforced by the SIL code or can be checked internally
       by the SIL code.  It is intended to speed up or prune XPath
       evaluation for a data node object.

       The 'parmstr' argument must be present, and contain the
       callback function name to be used in the SIL code generation
       by yangdump-pro.  This function is expected to exist
       and be present in the H files included by the SIL code module.

       If the 'parmstr' argument contains the special value 'default',
       then an XPath callback function will be generated using the
       identifier assigned to that data node.  This stub function will
       return 'ERR_NCX_SKIPPED' by default.  It must be completed
       by a programmer in order to have any affect.

       The callback function must conform to the
       'xpath_bool_eval_fn_t' typedef defined in ncx/xpath.h.

       Example:

           leaf foo {
             ywx:sil-xpath-function 'foo_xpath_callback';
             type string;
             must 'some expr';
           }
      ";
    argument parmstr;
  }

  extension sort-type {
    description
      "Used within a configuration data node definition
       statement to define the System Ordered Sort Type
       for the object.

       It can also be added to a node using an annotation.
       This extension affects only the node containing the
       extension. The following data nodes are supported:

         - list
         - leaf-list

       This extension only applies to ordered-by 'system'
       data nodes.

       This extension is ignored if the 'system-sorted'
       CLI parameter is set to 'false'. Otherwise this extension
       will override the 'system-sort-type' CLI parameter
       value.

       The 'parmstr' argument is a string with the same values
       as the 'system-sort-type' parameter:

         - off
         - ascending
         - descending

       Example:

           list foo {
             ywx:sort-type 'descending';
             // ...
           }

      ";
    argument parmstr;
  }

  extension hidden-from-cli {
    description
      "Used within a configuration data node definition
       statement to indicate that the data node and all its
       descendants should be hidden from the yp-shell
       and yangcli-pro clients.

       This is similar to the 'ncx:hidden' extension except
       only the CLI clients are effected. If the 'ncx:hidden'
       extension is present then this extension is ignored.";
  }

  extension confirm-data {
    description
      "Used within a configuration leaf data node or input
       node definition statement to indicate that the
       data node should be confirmed by the user.

       The user must enter the same string as the first string
       to confirm the parameter.

       -  Supported by yangcli-pro and yp-shell, starting 23.10-8.
       -  This parameter only applies to interactive mode.
       -  The parameters must be entered one at a time instead of
          all at once.
       -  This parameter does not apply to config mode.

       The CLI parameter 'confirm-data-retries' specifies the
       number of retries the user will get before giving up
       and canceling the command in progress.

       The user can use escape sequences to skip the
       parameter instead of confirming or waiting for
       the maximum number of retries.
      ";
  }





}
