module yumaworks-types {

    yang-version 1;
    namespace "http://yumaworks.com/ns/yumaworks-types";
    prefix "ywt";

    organization "YumaWorks, Inc.";

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

    description
       "Common CLI parameter types used in multiple YumaPro
        applications.

     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-02-14 {
       description
         "24.10T-6:
            - Change yang-sid-mode and lsid-mode to match current
              design";
    }

    revision 2024-04-14 {
       description
         "21.10T-8:
            - Add admin-string typedef.";
    }

    revision 2022-05-01 {
       description
         "21.10T only:
            - Add yang-sid-mode typedef and lsid-mode.";
    }

    revision 2021-05-15 {
       description
         "Add NcxNumName typedef.";
    }

    revision 2020-03-06 {
       description
         "Add NcxFileName typedef.";
    }

    revision 2018-05-03 {
       description
         "Add transport-type typedef.";
    }

    revision 2015-10-04 {
       description
         "Add encoding-type typedef.";
    }

    revision 2014-09-06 {
       description
         "Add server-target typedef.
          Add access-control-mode typedef.";
    }

    revision 2013-02-11 {
       description
         "Move some typedefs from yangcli-pro.yang to this module.";
    }

    revision 2012-12-05 {
       description
         "Initial version.";
    }

    typedef show-mode {
      description
        "The mode that a command or prompt should be displayed.
         Selects the verbosity level of the output.";
      type enumeration {
        enum brief;
        enum normal;
        enum full;
      }
    }

    typedef NameMatchMode {
      description
        "Defines the search mode that should be used
         when resolving YANG node names in leafs and
         leaf-lists using the UrlPath data type.";
      type enumeration {
        enum exact {
          description
            "The name must exactly match the node name
             for all characters in both name strings.";
        }
        enum exact-nocase {
          description
            "The name must match the node name
             for all characters in both name strings.
             Strings are not case-sensitive.";
        }
        enum one {
          description
            "The name must exactly match the first N
             characters of just one node name, which
             must be the only partial name match found.";
        }
        enum one-nocase {
          description
            "The name must exactly match the first N
             characters of just one node name, which
             must be the only partial name match found.
             Strings are not case-sensitive.";
        }
        enum first {
          description
            "The name must exactly match the first N
             characters of any node name. The first one
             found will be used.";
        }
        enum first-nocase {
          description
            "The name must exactly match the first N
             characters of any node name. The first one
             found will be used. Strings are not
             case-sensitive.";
        }
      }
    }

    typedef AltNameMode {
      description
        "Defines the alternate name search mode that
         should be used when resolving YANG node names
         in leafs or leaflists using the UrlPath data type.

         If 'true' then nodes with an 'alt-name' defined
         will be considered a match if the YANG name or the
         alternative name matches the search string.

         If 'false' then only the YANG node name will
         be used in node name searches.";
      type boolean;
    }

    typedef UrlPath {
       description
         "Special URL encoded path expression.

          Normal Encoding Rules:

            - Normal content is encoded as an absolute path.
            - Keys are encoded as a path step within the URL,
              instead of a predicate expression like XPath.
            - The first character must be a forward slash '/'.
            - Each identifier or key encoded in the URL string
              is separated by a single forward slash '/' character.
            - Escaped character sequences are allowed, such
              as '%20' for the space ' ' character.
            - If any descendant nodes of a list are included,
              then all key leafs for that list must be encoded
              in the URL (or escaped with the dash '-' character
              to skip that key).
            - Only key leafs can be encoded within the URL string,
              similar to a YANG instance-identifier or
              schema-instance-identifier string.  Other leafs
              are not allowed.

            Example URL and XPath strings:

                XPath:  /foo/bar[id='fred'][id2='barney]/baz

              UrlPath:  /foo/bar/fred/barney/baz

            Example showing the 'id2' key leaf escaped:

                XPath:  /foo/bar[id='fred']/baz

              UrlPath:  /foo/bar/fred/-/baz

         Special Encoding Rules

            Since these escaped characters are usually decoded
            by the time an HTTP gateway program will get them,
            the forward slash '/' character needs to be treated
            differently.  To use this character within key leaf
            content, it must be escaped with another forward
            slash character.

            Example showing escaped forward slash in content:

              XPath: /interfaces/interface[name='1/0/22']/mtu

            URLPath: /interfaces/interface/1//0//22/mtu

         Name Matching

            A parameter using the 'NameMatchMode' data type
            can be used to control how name node searches
            are done for nodes using this data type.

         Alternate Naming

            A parameter using the 'AltNameMode' data type
            can be used to control whether alternative
            node names can be used when name searches
            are done for nodes using this data type.

         Exceptions:

            XML namespaces are not ignored, but if multiple
            sibling nodes have the same local-name, then
            the first node found will be used.

         ";

       type string {
          length "1..max";
       }
    }

    typedef server-target {
      description
        "The database to use as the target of edit-config
         and copy-config operations.";
      type enumeration {
        enum running {
          description
           "Write to the running config and support
            the :writable-running capability.";
        }
        enum candidate {
          description
            "Write to the candidate config and support
             the :candidate and :confirmed-commit
             capabilities.";
        }
      }
    }

    typedef access-control-mode {
      type enumeration {
        enum enforcing {
          description
            "All configured access control rules will be enforced.";
        }
        enum permissive {
          description
            "All configured access control rules will be
             enforced for write and execute requests.
             All read requests will be allowed, unless
             the requested object contains the
             'nacm:very-secure' extension.  In that case,
             all configured access control rules will be enforced.";
         }
         enum disabled {
           description
             "All read, write, and execute requests will be
              allowed, unless the object contains the
              'nacm:secure' or 'nacm:very-secure' extension.
              If the 'nacm:secure' extension is in effect,
              then all configured access control rules
              will be enforced for write and execute requests.
              If the 'nacm:very-secure' extension is in effect,
              then all configured access control rules
              will be enforced for all requests.
              Use this mode with caution.";
         }
         enum off {
           description
             "All access control enforcement is disabled.
              Use this mode with extreme caution.";
         }
       }
     }

    typedef encoding-type {
      type enumeration {
        enum xml {
          description "XML encoding";
        }
        enum json {
          description "JSON encoding";
        }
        /*  TBD: for CoMI support
        enum cbor {
          description "CBOR encoding";
        }
        */
      }
      description "The message encoding format to use";
    }

    typedef transport-type {
      description
        "Identifies the transport protocol that should be used.";
      type enumeration {
        enum ssh {
          description "NETCONF over SSH.";
          reference "RFC 4742;  RFC 6242";
        }
        enum tcp {
          description
            "The transport is TCP. The usage depends on
             the protocol used.

             NETCONF over TCP: (tail-f NETCONF over TCP)
             If this enum is selected, then the default --ncport
             value is set to 2023 and the --protocols value
             is set to netconf1.0.  The --password value will
             be ignored.

             YANG-API or RESTCONF over HTTP/TCP:
             If this enum is selected, then the default --ncport
             value is set to 80, and the --protocols value
             will not be changed.";
          reference
             "NETCONF: tail-f conf-d RESTCONF: HTTP";
        }
        enum tcp-ncx {
          description
            "NETCONF over TCP.
             If this enum is selected, then the default --ncport
             value is set to 2023, and the --protocols value
             is set to netconf1.0 and netconf1.1.  The --password
             value will be ignored.";
           reference "YumaWorks <ncx-connect>";
        }
        enum tls {
          description
           "If the protocol is 'netconf' and this enum is selected,
            a NETCONF over TLS session will be attempted. If the
            protocol is 'RESTCONF' and this enum is selected
            the RESTCONF client will try to communicate with
            the server using the HTTPS protocol.";
          reference "RFC 2818";
        }
        enum coap {
          description
            "RESTCONF over CoAP.
             If this enum is selected, then the default --ncport
             value is set to 5683. The --password value will be
             ignored.";
          reference "YumaWorks <ncx-connect>";
        }
      }
    }

    typedef NcxFileName {
        description
          "General Purpose NCX File Name string.
           The first character can be a letter, digit, or
           underscore character. The rest of the characters can be
           printable characters except the following characters:

              * space ( )             ASCII 32
              * double quote          ASCII 34
              * ampersand (&)         ASCII 38
              * comma (,)             ASCII 44
              * forward slash (/)     ASCII 47
              * less-than sign (<)    ASCII 60
              * question mark (?)     ASCII 63
              * backslash (\\)        ASCII 92
              * left curly brace ({)  ASCII 123
              * vertical bar (|)      ASCII 124

           The allowed characters are not special to the server but many
           of them would be interpreted as special characters by other
           programs. Use such characters with extreme caution.";
        type string {
            length "1..64";
            pattern "[0-9A-Z_a-z][-!#$%'()*+.0-;=>@-Z\\[\\]\\^_-z}~]{0,63}";
        }
    }

    typedef NcxNumName {
        description
          "General Purpose NCX Name string. This is the
           same as an NcxName except the first character
           is also allowed to be a number.";
        type string {
            length "1..64";
            pattern '[a-zA-Z0-9_][a-zA-Z0-9\-_\.]{0,63}';
        }
    }

    typedef yang-sid-mode {
      type enumeration {
        enum sid-file {
          description
            "Use YANG SID files for SID assignments";
        }
        enum lsid {
          description
            "Use LSID SID generation mode for SID assignments.
             Starting in 24.10T-6:
               - SID files will be used if found, for each
                 module loaded.
               - LSIDs will be generated only for the objects
                 in modules where no SID file was found.
               - The starting point for LSID asignment is
                 implementation-specific.";

        }
      }
      description
        "The source of SID assignments for YANG schema items.";
    }

    typedef lsid-size {
      type enumeration {
        enum lsid16 {
          description
            "The SID width is 16 bits.
             The maximum SID value is 15 bits (32K values).
             This value is no longer used.";
        }
        enum lsid32 {
          description
            "The SID width is 32 bits.
             The maximum SID value is 31 bits (2G values).
             This value is no longer used.";
        }
        enum lsid64 {
          description
            "The SID width is 64 bits.
             The maximum SID value is 63 bits (9.2 x 10^^18 values).
             This is the only value used.";
        }
      }
      description
        "If the yang-sid-mode is 'lsid' then the server
         implementation will pick a SID size at build-time.

         Starting in 24.10T-6:
           - This object is not used
           - All LSIDs are 64 bits in length
           - The value 'lsid64' will always be returned.";
    }

    typedef admin-string {
      type string {
        length "1 .. 1024";
      }
      description
        "Administrative string constrained to 1024 characters.";
    }



}
