module yumaworks-virtual-server {
  yang-version 1.1;
  namespace "urn:yumaworks:params:xml:ns:yang:yumaworks-virtual-server";
  prefix "yvs";

  import ietf-inet-types { prefix inet; }
  import netconfd-pro { prefix ndpro; }
  import yumaworks-types { prefix ywt; }
  import yumaworks-schema-mount { prefix ysm; }


  organization "YumaWorks, Inc.";
  contact "Support <support@yumaworks.com>";
  description
    "This module contains configuration and monitoring information
     for Virtual Servers within the netconfd-pro Host Server.

     The YANG Schema Mount feature in RFC 8528 is supported as the
     framework for virtual servers. The yumaworks-schema-mount
     module defines the configuration parameters.

     Copyright (c) 2022, 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 2022-01-19 {
    description
       "Initial version";
  }

  typedef vs-protocol {
    type enumeration {
      enum netconf {
        description "Identifies the NETCONF Protocol";
        reference "RFC 6241";
      }
      enum restconf {
        description "Identifies the RESTCONF Protocol";
        reference "RFC 8040";
      }
      enum yp-gnmi {
        description "Identifies the yp-gNMI Protocol";
      }
      enum yp-grpc {
        description "Identifies the yp-gRPC Protocol";
      }
      enum yp-shell {
        description "Identifies the yp-shell Protocol";
      }
    }
    description
      "The protocol used in an endpoint in the Virtual Server";
  }



  grouping vs-instance-parms {
      description
        "Parameters for configuring a VS Instance.
         This does not include the key (name)";

      uses ysm:sm-config-keys;

      leaf vs-root {
        type instance-identifier;
        mandatory true;
        description
          "Specifies the data node that will be the mount point.
           This path must identify a YANG container or list
           that contains a mount-point label that matches
           the 'mount-point-module' and 'mount-point-label'
           fields in the vs-template entry used in this
           VS Instance.";
      }

      list vs-bind {
        key "vs-protocol";

        leaf vs-protocol {
          type vs-protocol;
          description
            "The protocol to use for this endpoint.";
        }
        choice vs-transport {
          mandatory true;
          case vs-gen {
            leaf vs-address {
              type inet:ip-address;
              description
                "The IP address to use for this endpoint.";
            }
            leaf vs-port {
              type inet:port-number;
              description
                "The TCP or UDP port number to use for this endpoint.";
            }
          }
          case vs-tls {
            uses ndpro:netconfd-tls-parms;
          }
        }
      }
  }


  container virtual-servers {

    list virtual-server {
       key name;
       leaf name {
          type ywt:NcxNumName;
          description "An administrative name for this entry.";
       }

       uses vs-instance-parms;
    }
  }

}
