module yumaworks-yp-grpc {
  yang-version 1.1;
  namespace "http://yumaworks.com/ns/yumaworks-yp-grpc";
  prefix "ypgrpc";

  import ietf-yang-structure-ext { prefix sx; }
  import yumaworks-ycontrol { prefix yctl; }
  import ietf-yang-types { prefix yang; }
  import ietf-inet-types { prefix inet; }

  organization "YumaWorks, Inc.";

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

  description
    "YumaPro gRPC Application message definitions.

     Copyright (c) 2014 - 2023 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 2023-08-04 {
    description
      "22.10T-11: Change CLI container to sx:structure";
  }

  revision 2021-08-23 {
    description
      "Initial version";
  }


  sx:augment-structure
    "/yctl:ycontrol/yctl:message-payload/yctl:payload/yctl:payload" {
    container yp-grpc {

      choice message-type {
        mandatory true;

        case register-request-case {
          leaf register-request {
            type empty;
            description
              "Message type: subsys-request;
               Purpose: register the YP-gRPC subsystem
               Expected Response Message: ok or error";
          }
        }

        container capability-ad-event {
          description
            "Subsystem event to advertise all the gRPC
             available and active capabilities during
             the registration time.
             Type: subsys-event
             Expected Response Message: none";

          leaf name {
            mandatory true;
            type yang:yang-identifier;
            description
              "Name of the gRCP server.";
          }

          leaf address {
            type inet:host;
            mandatory true;
            description
              "IP Address or host name for the gRPC server.
               The value returned is implementation specific
               (e.g., hostname, IPv4 address, IPv6 address)";
          }

          leaf port {
            type inet:port-number;
            description
              "TCP port number for the gRPC server.
               If not present then the default port for
               the protocol will be used.";
          }

          leaf-list proto {
            type string;
            description
              "The list of proto files that gRPC server supports.";
          }

          list service {
            key name;
            description
              "List of gRPC Services supported by the gRPC server and
               related information.";

            leaf name {
              type string;
              description
                "Name of the gRCP Service associated with this list entry.";
            }

            list method {
              key name;
              description
                "The list of methods supported by the gRPC server and
                 related information.";

              leaf name {
                type string;
                description
                  "Name of the Service Method associated with this list entry.";
              }
              leaf client-streaming {
                type boolean;
                description
                  "True if the client supports streaming for this method
                   FALSE otherwise.";
              }
              leaf server-streaming {
                type boolean;
                description
                  "True if the server supports streaming for this method.
                   FALSE otherwise.";
              }
            }
          }
        }

        container open-stream-event {
          description
            "Subsystem event to advertise a new gRPC
             server or client stream(s).
             Type: subsys-event
             Expected Response Message: none";

          list server-stream {
            key name;
            description
              "Contains a list of open server gRPC streams.";

            leaf name {
              type string;
              description
                "Name of a gRCP server stream.";
            }

            leaf location {
              type inet:uri;
              mandatory true;
              description
                "Contains a URL that represents the RPC that uses
                 this client stream.";
            }
          }

          list client-stream {
            key name;
            description
              "Contains a list of open client gRPC streams.";

            leaf name {
              type string;
              description
                "Name of a gRCP client stream.";
            }

            leaf location {
              type inet:uri;
              mandatory true;
              description
                "Contains a URL that represents the RPC that uses
                 this server stream.";
            }
          }
        }

        container close-stream-event {
          description
            "Subsystem event to advertise that the gRPC server or
             client stream was closed.
             Type: subsys-event
             Expected Response Message: none";

          leaf-list server-stream {
            type string;
            description
              "The list of closed server gRPC streams.";
          }

          leaf-list client-stream {
            type string;
            description
              "The list of closed client gRPC streams.";
          }
        }
      }
    }
  }
}