module yumaworks-opsmgr {
    yang-version 1.1;
    namespace "http://yumaworks.com/ns/yumaworks-opsmgr";
    prefix "yomgr";

    import ietf-yang-types { prefix yang; }
    import yuma-types { prefix nt; }
    import yumaworks-mgr-common { prefix ymcmn; }

    organization "YumaWorks, Inc.";
    contact
        "Support <support at yumaworks.com>";
    description
       "yp-controller operation manager

     Copyright (c) 2018 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 2018-07-10 {
        description
          "Initial version";
    }


    rpc get-capabilities {
      description
        "Retrieve the NETCONF or RESTCONF capabilities for
         the specified sessions.

         The session-name leaf-list is considered to be
         a logical OR expression. A 'session-output' list entry
         will be returned for each matching session name
         that corresponds to a session for which the capabilities
         are available.";

      input {
        uses ymcmn:session-name-config;
      }

      output {
        uses ymcmn:output-cmn {
          description
            "The 'data' node in the output contains the
             capabilities element and all descendant nodes.";

          augment "output-choice/session-output/session-output/" +
                  "cmd-result/data/data" {
            container capabilities {
              leaf-list capability  {
                type string;   // inet:uri;
                description
                  "The NETCONF or RESTCONF URI string for
                   the capability";
              }
            }
          }
        }
      }
    }


    rpc get-event-log {
      description
        "Retrieve raw events from the event log for 1 or more
         sessions. The input filters are combined to form
         a logical AND expression. All filters that are present
         must pass for an event to be included in the response.

         The session-name leaf-list is considered to be
         a logical OR expression. A 'session-output' list entry
         will be returned for each matching session name
         that corresponds to the event log that search results
         were found.

         All invalid values are considered to be
         false matches and not errors.";

      input {
        uses ymcmn:session-name-config;

        leaf start-index {
          type uint32;
          default 1;
          description
            "The start index number in the event log to use.
             The first event is event 1.";
        }

        leaf max-entries {
          type uint32;
          default 0;
          description
            "The maximum number of entries to return.
             The value zero indicates there is no maximum.";
        }

        leaf start-time {
          type yang:date-and-time;
          description
            "The timestamp to compare to the subscription
              eventTime value. Events timestamped at or after
              this value will be included in the response.";

        }

        leaf finish-time {
          type yang:date-and-time;
          description
            "The timestamp to compare to the subscription
              eventTime value. Events timestamped at or before
              this value will be included in the response.";
        }

        leaf module-name {
          type nt:NcxName;
          description
            "The name of the module that contains the
             notification statement associated with the event type.
             Events matching this module name will be included
             in the response.";

        }

        leaf event-name {
          type nt:NcxName;
          description
            "The local name of the notification statement
             associated with the event type. Events matching
             this notification name will be included n the response.";
        }

        leaf xpath-filter {
          type yang:xpath1.0;
          description
            "An XPath expression to test against the notification.
             The document root and the context node will be the
             notification element. The result will be converted
             using the boolean() function if required.  If the
             boolean result is 'true' then the event will be
             included in the response;";
        }
      }

      output {
        uses ymcmn:output-cmn {
          description
            "The 'data' node in the output contains the
             notification element and all descendant nodes
             for an event that matched the search criteria.";

          augment "output-choice/session-output/session-output/" +
                  "cmd-result/data/data" {
            list event-data {
              key index;
              leaf index {
                type uint32;
                description
                  "The event index in the eventlog of this event.";
              }
              anydata notification {
                description "The complete notification message";
              }
            }
          }
        }
      }
    }

    grouping cmdmode-cmn {
      description
        "Command mode common parameters";

      leaf message-id {
        type string;
        description
          "If present, send the request in async mode.
           The message-id string to use in the cmd-response event
           sent for this command. The cmd-response event is sent
           when there is a real response ready. The rpc-reply for
           this operation indicates that the command was started.";
      }

      leaf timeout {
        type int32 {
          range "0..max";
        }
        units "seconds";
        default 30;
        description
          "The number of seconds to wait for a reply from
           each session. The value zero indicates wait forever.";
      }
    }

    rpc invoke-rpc {
      description
        "Invoke an RPC operation for 1 or more sessions.

         The session-name leaf-list is considered to be
         a logical OR expression. A 'session-output' list entry
         will be returned for each matching session name
         that corresponds to a session for which the RPC operation
         was attempted.
       ";

      input {
        uses ymcmn:session-name-config;

        leaf module-name {
          type nt:NcxName;
          mandatory true;
          description
            "The name of the module that contains the
             RPC statement that should be invoked.";
        }

        leaf rpc-name {
          type nt:NcxName;
          mandatory true;
          description
            "The local name of the RPC operation statement
             that should be invoked.";
        }

        uses cmdmode-cmn;

        anydata input {
          description
            "The input parameters for this RPC operation.
              The child nodes of this node are expected to be
              the child nodes of the 'input' statement for the
              associated RPC operation.";
        }
      }

      output {
        uses ymcmn:output-cmn {
          description
            "The 'data' node in the output contains the
             child node(s) of the rpc-reply element
             and all their descendant nodes.";
        }
      }
    }


    rpc invoke-action {
      description
        "Invoke a YANG action for 1 or more sessions.

         The session-name leaf-list is considered to be
         a logical OR expression. A 'session-output' list entry
         will be returned for each matching session name
         that corresponds to a session for which the action
         was attempted.
        ";

      input {
        uses ymcmn:session-name-config;

        leaf action-path {
          type string;  // RESTCONF URL format
          mandatory true;
          description
            "The RESTCONF URL for the action object.
             All ancestor key values must be provided
             so that the target node represents one
             conceptual instance of the YANG action node.";
        }

        uses cmdmode-cmn;

        anydata input {
          description
            "The input parameters for this YANG action.
              The child nodes of this node are expected to be
              the child nodes of the 'input' statement for the
              associated YANG action.";
        }
      }

      output {
        uses ymcmn:output-cmn {
          description
            "The 'data' node in the output contains the
             rpc-reply element and all descendant nodes.";
        }
      }
    }

    notification cmd-response {
      description
        "This event is generated by yp-controller when the
         invoke-rpc or invoke-action operation is used
         in 'async' mode. It contains the response to the
         requested operation or action.";

      leaf message-id {
        type string;
        mandatory true;
        description
          "The message-id string matching the value used in
           the request operation.";
      }

      uses ymcmn:output-cmn {
        description
          "The 'data' node in the output contains the
           child nodes of the rpc-reply element and all
           their descendant nodes.";
      }
    }


}
