module yumaworks-sil-sa {
  yang-version 1.1;
  namespace "http://yumaworks.com/ns/yumaworks-sil-sa";

  prefix "ysil";

  import ietf-yang-structure-ext { prefix sx; }
  import ietf-yang-types { prefix yang; }
  import yuma-types { prefix yt; }
  import yumaworks-types { prefix ywt; }
  import yumaworks-ycontrol { prefix yctl; }
  import yumaworks-agt-profile { prefix yprof; }
  import yumaworks-schema-mount { prefix ysm; }

  organization "YumaWorks, Inc.";

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

  description
    "YumaPro SIL Sub-Agent message definitions.

     Copyright (c) 2014 - 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 2024-09-13 {
    description
      "Introduced in 22.10-25, 23.10-13, YPW-2273:
       - Add a pre-process bit to the get-request flags";
  }

  revision 2024-07-31 {
    description
      "Add push-path registration support.
       Add push-request message.";
  }

  revision 2024-07-28 {
    description
      "23.10T-10: Add SIL-SA Global callbacks support:
        - Add grouping for all the callbacks";
  }

  revision 2024-02-23 {
    description
      "Add SIL-SA EDIT3 callbacks support:
        - Add leaf-list edit3-path to register-request message
        - Add update value to edit list in <start-transaction> message";
  }

  revision 2023-08-04 {
    description
      "22.10T-11: Change CLI container to sx:structure";
  }

  revision 2023-06-16 {
    description
       "Add edit-phase-complete boolean leaf";
  }

  revision 2023-02-19 {
    description
       "Add revision leaf to register container in <register-request>
        message.";
  }

  revision 2022-08-23 {
    description
       "Add MPID support for schema mount.
        Change all anyxml to anydata to match usage.";
  }

  revision 2022-04-05 {
    description
      "YPW-1916:
       - Add modpath, datapath, and runpath leafs to
         config-response message";
  }

  revision 2022-03-29 {
    description
      "Add event-path and event-key fields to the notification
       message to support nested YANG 1.1 event types.";
  }

  revision 2021-11-28 {
    description
      "Fix pyang compiler errors for this module.
      'list needs at lest one key' messages";
  }

  revision 2021-10-28 {
    description
      "YPW-1857: SIL-SA EDIT2 callback on leaf-list node malfunction.
        Add remove to the enum list of operation;

       YPW-1864: Commit Completeness callbacks support for SIL-SA:
        - Add validate-complete boolean leaf
        - Add apply-complete boolean leaf
        - Add commit-complete boolean leaf
        - Add rollback-complete boolean leaf
        - Add commit-completeness-hook message

       YPW-1870: SIL-SA editvars support
        - Add editvars container to edit list
        - Add editvars container to child-edit list";
  }

  revision 2020-08-27 {
    description
      "Add SIL-SA EDIT2 callbacks support:
        - Add leaf-list edit2-path to register-request message
        - Add child-edit list to edit list in <start-transaction> message";
  }

  revision 2020-06-05 {
    description
      "Add SIL-SA Hook callbacks support:
        - Add leaf-list sethook-path to register-request message
        - Add leaf-list post-sethook-path to register-request message
        - Add leaf-list transaction-path to register-request message
        - Add hook-request message
        - Add hook-response message
        - Add hook-get-request message
        - Add hook-get-response message";
  }

    revision 2019-10-11 {
        description
          "Add with-origin flag for NMDA support";
    }

    revision 2019-08-18 {
        description
          "Add stream-name to notification message.
           Add client-addr to transaction messages to support
           sil_sa_get_client_addr function";
    }

    revision 2019-07-02 {
      description
        "Added HOOKS support:
          * Add following leafs to register-request message:
            - Add transaction-start boolean leaf
            - Add transaction-complete boolean leaf
          * Add trans-start-hook message
          * Add trans-complete-hook message";
    }

    revision 2019-04-20 {
      description
        "Added ACTION support:
          * Add action-path to register-request message
          * Add action-request message
          * Add action-response message";
    }

    revision 2019-01-31 {
        description
          "Added user-id-obj grouping used by start-transaction,
           get-request and rpc-request messages";
    }

    revision 2019-01-20 {
        description
          "Add deviation parm to config-response message.";
    }

    revision 2018-12-05 {
        description
          "Add load-config parameter to start-transaction message";
    }

    revision 2018-10-03 {
        description
          "Add bundle parameter to register-request message";
    }

    revision 2018-06-03 {
        description
          "Add rpc-request and rpc-response messages";
    }

    revision 2017-09-19 {
        description
          "Fix broken augment statement for payload";
    }

    revision 2015-11-01 {
        description
          "Added support for GETBULK to get-response message.";
    }
    revision 2015-08-17 {
        description
          "Added 'select' node support to get2 SIL-SA get-request
           message";
    }
    revision 2015-04-17 {
        description
          "Updated notification container for release";
    }

    revision 2015-01-15 {
        description
          "Add get and notification support";
    }

    revision 2014-11-18 {
        description
          "Fix module type, supposed to be NcModuleNameSpec
           to allow foo@2000-01-01, not just foo.
           Add bundle-module leaf-list to register msg
           Add bundle-load-event to inform server of any modules
           loaded from a SIL-SA bundle; Remove shutdown-event.";
    }

    revision 2014-09-06 {
        description
          "Add agt-profile container to config-parms grouping
           used in the <config-response> from server to subsystem.";
    }

    revision 2014-08-01 {
        description
          "Initial version.";
    }

    grouping bundle-module-parm {
      leaf-list bundle-module {
        type yt:NcModuleSpec;
        description
          "Module parameters that were loaded as a result of
           any bundle parameters. They will be returned in the
           form modname@revision-date.";
      }
    }

    grouping bundle-parm {
      leaf-list bundle {
        type yt:NcxName;
        description
          "Bundle names that were loaded as a result of
           any bundle parameters.";
      }
    }

    grouping path-parm {
      leaf path {
        mandatory true;
        type string;
        description
          "Object identifier string:

            * matches 'path' in the register-request message
              for an EDIT callback
            * matches 'get-path' in the register-request message
              for a GET2 callback
            * matches 'action-path' in the register-request message
              for an ACTION callback

           The path string is generated with YANG prefixes using
           the obj_gen_object_id_prefix function in ncx/obj.h
          ";
      }
    }

    grouping system-callbacks-parm {
      description
        "Specifies what system callbacks are enabled.";

      leaf transaction-start {
        type empty;
        description
          "The leaf specifies if there is a Transaction
           Start Callback to register";
      }
      leaf transaction-complete {
        type empty;
        description
          "The leaf specifies if there is a Transaction
           Complete Callback to register";
      }
      leaf validate-complete {
        type empty;
        description
          "The leaf specifies if there is a Validate
           Complete Callback to register";
      }
      leaf apply-complete {
        type empty;
        description
          "The leaf specifies if there is an Apply
           Complete Callback to register";
      }
      leaf commit-complete {
        type empty;
        description
          "The leaf specifies if there is a Commit
           Complete Callback to register";
      }
      leaf rollback-complete {
        type empty;
        description
          "The leaf specifies if there is a Rollback
           Complete Callback to register";
      }
      leaf edit-phase-complete {
        type empty;
        description
          "The leaf specifies if there is an Edit Phase
           Complete Callback to register";
      }
    }

    grouping glob-callbacks-parm {
      description
        "Specifies what global callbacks are enabled.";

      leaf glob-action {
        type empty;
        description
          "The leaf specifies if there is a Global
           ACTION Callback to register";
      }
      leaf glob-edit2 {
        type empty;
        description
          "The leaf specifies if there is a Global
           EDIT2 Callback to register";
      }
      leaf glob-edit3 {
        type empty;
        description
          "The leaf specifies if there is a Global
           EDIT3 Callback to register";
      }
      leaf glob-get {
        type empty;
        description
          "The leaf specifies if there is a Global
           GET2 Callback to register";
      }
      leaf glob-rpc {
        type empty;
        description
          "The leaf specifies if there is a Global
           RPC Callback to register";
      }
    }

    grouping operation-parms {
      leaf operation {
        mandatory true;
        type enumeration {
          enum merge;
          enum replace;
          enum create;
          enum delete;
          enum load;
          enum commit;
          enum remove;
        }
        description
          "Operation matching op_editop_t enumeration list.";
      }
    }

    grouping hook-edit-parms {
      leaf operation {
        type string;
        description
          "Operation matching yang_patch_op_t enumeration list.
           Specific for Set Hook add_edit() API";
      }
      leaf where {
        type string;
        description
          "Specifies how a node should be inserted within a
           user-ordered list";
      }
      leaf point {
        type string;
        description
          "Specifies an insertion point for a data resource that
           is being created or moved within a user ordered list
           or leaf-list.";
      }
      leaf skip-callback {
        type boolean;
        description
          "Specifies whether the server should invoke callbacks
           for an added edit";

        default "false";
      }
    }

    grouping hooks-param {
      leaf hook-path {
        type string;
        description
          "Path string for object for Hook callbacks";
      }
      leaf hook-format {
        type enumeration {
          enum node;
          enum subtree;
        }
        default "node";
        description
          "Hook format; dictates specific hook functionality";
      }
      leaf hook-type {
        type enumeration {
          enum none;
          enum set-hook;
          enum post-set-hook;
          enum transaction-hook;
        }
        description
          "Specifies Hook callback type";
      }
      leaf added-edit {
        type boolean;
        description
          "Specifies whether the edit was added by Set Hook
           of Post Set Hook callbacks. Flag to prevent Set Hook
           looping; will not allow to call Set Hook family callbacks";
      }
    }

    grouping transaction-id-obj {
      leaf transaction-id {
        mandatory true;
        type string;
        description
          "Server specific transaction identifier.";
      }
    }

    grouping user-id-obj {
      leaf user-id {
        type string;
        description
          "Identifies the user that initiated this transaction.";
      }
    }

    grouping client-addr-obj {
      leaf client-addr {
        type string;
        description
          "Identifies the address of the client that initiated
           this transaction.";
      }
    }

    grouping config-parms {
      uses yprof:agt-profile;
      leaf-list bundle {
        type yt:NcxName;
        description "Bundle SIL SA libraries to load";
      }
      leaf-list module {
        type yt:NcModuleSpec;
        description "Module SIL SA libraries to load";
      }
      leaf-list deviation {
        type yt:NcModuleSpec;
        description "Deviations and annotations to load";
      }
      leaf modpath {
        type string;
        description "Server module search path setting";
      }

      leaf datapath {
        type string;
        description "Server data search path setting";
      }

      leaf runpath {
        type string;
        description "Server library search path setting";
      }

    }

    grouping event-stream-parm {
      leaf event-stream {
        type ywt:NcxNumName;
        description
          "Event stream name to use for the operation.";
      }
    }

    grouping stream-subevent-parm {
      leaf stream-subevent {
        type enumeration {
          enum active {
            description "Event stream is active";
          }
          enum inactive {
            description "Event stream is inactive";
          }
        }
        description
          "Event stream callback subevent types.";
      }
    }

    grouping commit-phase-parm {
      leaf commit-phase {
        type enumeration {
          enum validate {
            description "Invoke Validate Complete callback";
          }
          enum apply {
            description "Invoke Apply Complete callback";
          }
          enum commit {
            description "Invoke Commit Complete callback";
          }
          enum rollback {
            description "Invoke Rollback Complete callback";
          }
        }
        description
          "Specifies the Commit Completeness callback phase.";
      }
    }

    grouping commit-type-parm {
      leaf commit-type {
        type enumeration {
          enum normal {
            description "Commit operation was completed";
          }
          enum reply {
            description "Replay-commit operation was completed";
          }
          enum none {
            description "Type is not set";
          }
        }
        description
          "Specifies the type of commit that was just completed.
           Used only for Commit Complete Callback.";
      }
    }

    grouping return-val {
      anydata return-keys {
        description
          "List of all ancestor or self key values for the
           object being retrieved, identified by the 'path'
           value. There will be one child leaf for each key
           in each list.";
      }

      anydata values {
        description
          "Represents the retrieved values, if any.
           There will be one child node for each returned
           value.";
      }
    }

    grouping editvars-parm {
      container editvars {
        leaf insert-op {
          type enumeration {
            enum none;
            enum first;
            enum last;
            enum before;
            enum after;
          }
          description
            "Specifies the YANG insert operation.";
        }
        leaf insert-str {
          type string;
          description
            "Identifies the saved string for value or key attr.";
        }
        leaf insert-mode {
          type enumeration {
            enum none;
            enum key;
            enum value;
            enum point;
          }
          description
            "Specifies the insert mode requested.";
        }
        anydata insert-val {
          description
            "Represents the insert value, if any.
             Should be present if the insert operation is 'before'
             or 'after'.";
        }
        leaf sil-priority {
          type uint8;
          description
            "Identifies the 2nd SIL priority for server.";
        }
        leaf operset {
          type empty;
          description
            "Specifies whether operation is set or not.";
        }
        leaf move {
          type empty;
          description
            "Specifies whether the insert is for MOVE operation or not.";
        }
        leaf skip-sil-partial {
          type empty;
          description
            "Specifies whether skip_sil_partial is needed or not.";
        }
      }
    }

    grouping schema-mount-parm {
      leaf mounted {
        type empty;
        description
          "Specifies whether this callback is for a mounted node or a
           top level node.";
      }
    }

    grouping sm-mpid-parm {
      container mpid {
        uses ysm:sm-config-keys;

        leaf objpath {
          type string;
          description "Mount point root object path.";
        }

        anydata keys {
          description
            "List of all ancestor key values for the
             Mount Point Instance, identified in the 'objpath'
             object.

             There will be one child leaf for each key in each list,
             starting from the mount point root object.";
        }
      }
      description
        "Specifies the Mount Point Instance for the request";
    }

    grouping sa-push-parms {
      leaf observer-id {
        type uint32;
        description
          "assigned observer ID for the subsystem.";
      }
      leaf subscription-id {
        type uint32;
        mandatory true;
        description
          "The subscription ID that is requesting this
           object. Only one object per subscription is
           supported but unlimited subscriptions are allowed.
           This parameter must be saved by the SIL-SA
           callback function to identify the subscription
           in followup operations after the initial 'start'";
      }
      leaf push-op {
        type enumeration {
          enum start {
            description
              "Start generating push-data events using the
               subscription parameters provided. Only a
               'suspend' or 'finish' operation can be done
               after this operation completes.";
          }
          enum suspend {
            description
              "Suspend the current subscription.
               Remember the settings in case the 'resume'
               operation is received.  Only a 'resume' or
               'finish' operation can be done after this
               operation completes.";
          }
          enum resume {
            description
              "Resume the current subscription, using the
               saved settings from the 'start' operation.
               Only a 'suspend' of 'finish' operation can
               be done afer this operation completes.";
          }
          enum finish {
            description
              "Stop generating push-data events and clear
               the current subscription. Only a 'start'
               operation can be done after this operation
               completes.";
          }
        }
        mandatory true;
        description
          "The PUSH operation being requested by the server.";
      }
      leaf push-target {
        type string;
        description
          "Contains a path string representing the object that
           is the subject of this push management request.";
      }
      leaf push-type {
        type enumeration {
          enum on-change;
          enum periodic;
        }
        default on-change;
        description
          "The PUSH operation being requested by the server.";
      }
      leaf push-filter {
        type yang:xpath1.0;
        description
          "The YANG Push filter provided by the client.
           A subtree filter will be converted to its XPath
           equivalent expression.  This leaf will only be
           present for the 'start' operation.";
      }
      leaf push-period {
        type uint32;    // yp:centiseconds;
        units "centiseconds";
        mandatory true;
        description
          "If the push-type is periodic then this represents
           the requested update interval. If the push-type
           is on-change then this represents the requested
           dampening period. This leaf will only be present
           for the 'start' operation.";
      }
      leaf sync-on-start {
        type boolean;
        default true;
        description
          "The sync-on-start parameter. Only applies to on-change
           subscriptions. This leaf will only be present
           for the 'start' operation.";
      }
      leaf send-protocol {
        type enumeration {
          enum ycontrol {
            description
              "Push updates are sent to the main server
               using YControl protocol messages.  Updates
               are not limited in size at all.";
          }
          enum udp-notif {
            description
              "Push updates are sent to list of receivers
               using UDP-Notif protocol.  Updates will
               be generated with max 64K payloads.";
          }
        }
      }
      leaf-list receiver {
        type string;
              description
                "Used only for udp-notif protocol.
                 Contains the host or IP address plus colon
                 char plus the port number

                 192.168.0.20:8300
                 push-server.mydomain.com:8033
                ";
       }
    }

    sx:augment-structure
       "/yctl:ycontrol/yctl:message-payload/yctl:payload/yctl:payload" {
      container sil-sa {

        description
          "Server Instrumentation Library Sub-Agent API Messages

           SIL-SA Protocol Initialization:

           1) subsys sends a <config-request> subsys-request msg
           2) server replies with <config-response> server-response
              msg with the agt_profile data
           3) subsys sends a <register-request> subsys-request msg
              with modules and object path-expressions to register.
              Any bundle and bundle-module info is also sent
           4) server sends <ok> server-response
           5) subsys sends a <trigger-replay> subsys-event;
              if any config for this subsystem, server will send
              a <start-transaction> server-request with a config-replay
              transaction

           SIL-SA Protocol Edit Operation:

           1) the server sends a <start-transaction> server-request msg
              with the edit list
           2) the subsys validates the request and sends an
              <ok> subsys-response (or error)
           3) the server sends a <continue-transaction> for the apply
              phase
           4) the subsys applies the request and sends an
              <ok> subsys-response (or error)
           5) the server sends a <continue-transaction> for the commit
              phase
           6) the subsys commits the request and sends an
              <ok> subsys-response (or error).

           If the server does not get to step (5) because of an error,
           a <continue-transaction> server-request msg will be sent
           for the rollback phase.

           If the server does not get to step (3) because of an error,
           it will send a <cancel-transaction> server-event msg so
           the subsystem can release any saved state.

           RPC Operation:

           1) the server sends an <rpc-request> with the input parameters
           2) the subsystem performs VALIDATE and INVOKE phases
           3) the subsystem returns <rpc-ok> or <rpc-data>.
              YControl error is used for any errors

           ACTION Operation:

           1) the server sends an <action-request> with the input parameters
           2) the subsystem performs VALIDATE and INVOKE phases
           3) the subsystem returns <action-ok> or <action-data>.
              YControl error is used for any errors

           HOOKS Support:

            Transaction Start Hooks:
               1) the server send trans-start-hook request
               2) the subsys validates the request, invoke callbacks, and
                  sends an <ok> subsys-response (or error)

            Transaction Complete Hooks:
               1) the server send trans-complete-hook event msg so subsystem
                  can invoke Transaction Complete Callbacks
          ";

        choice message-type {
          mandatory true;

          leaf config-request {
            type empty;
            description
             "Message type: subsys-request;
              Purpose: register the service with the server
              and request the service configuration from server.
              Expected Response Message: config-response";
          }

          container config-response {
            description
             "Message type: server-reply;
              Purpose: server will send this element containing the
              requested sub-system configuration.
              Expected Response Message: none";

            uses config-parms;

            container schema-mount {
              uses ysm:sm-config-contents;
            }

          }

          container register-request {
            description
             "Message type: subsys-request;
              Purpose: register the SIL-SA callback functions
              for this sub-system.
              Expected Response Message: ok";

            uses bundle-parm;
            uses bundle-module-parm;

            list register {
              description
                "Specifies the path strings of all the objects
                 in each module that is supported by the subsystem.";

              key "module";
              leaf module {
                type yt:NcxName;
                description
                  "Module name for the target object.";
              }
              leaf revision {
                type string;  // not revision-identifier
                description
                  "Module revision identifier.
                   Currently just a revision date.";
              }
              leaf-list path {
                type string;
                description
                  "Path string for object for an EDIT callback";
              }
              leaf-list edit2-path {
                type string;
                description
                  "Path string for object for an EDIT2 callback";
              }
              leaf-list edit3-path {
                type string;
                description
                  "Path string for object for an EDIT3 callback";
              }
              leaf-list get-path {
                type string;
                description
                  "Path string for object for a GET callback";
              }
              leaf-list push-path {
                type string;
                description
                  "Path string for object for a PUSH callback.
                   This path identifies a container or list that
                   can support a YANG Push subscription.";
              }
              leaf-list rpc-name {
                type yt:NcxName;
                description
                  "Name of the RPC operation callback";
              }
              leaf-list action-path {
                type string;
                description
                  "Path string for object for an ACTION callback";
              }

              leaf-list post-sethook-path {
                type string;
                description
                  "Path string for object for a Post Set Hook callback";
              }
              list sethook-list {
                description
                  "List for a Set Hook callbacks";

                key "hook-path";
                uses hooks-param;
              }
              list transaction-hook-list {
                description
                  "List for a Transaction Hook callbacks";

                key "hook-path";
                uses hooks-param;
              }

              container stream-callback {
                presence
                 "Indicates a stream-callback is registered for
                  the 'module' in the 'register' list entry with
                  the 'register-request' message. If no child nodes
                  then the registration is for the module name.
                  Otherwise it is for one stream or all streams.";

                choice callback-type {
                  case event-stream {
                    uses event-stream-parm;
                  }

                  leaf all-streams {
                    type empty;
                    description
                      "Flag to register for all event-stream events";
                  }
                }
              }

            }

            uses system-callbacks-parm;
            uses glob-callbacks-parm;
          }

          container start-transaction {
            description
             "Message type: server-request;
              Purpose: Start an edit transaction which may require the
              SIL-SA callback functions on the subsystem to be invoked.

              This message requests that a new edit transaction be
              started on the subsystem.  Only 1 transaction can be in
              progress at a time.

              If this transaction is for a validate operation then
              there will not be any followup messages.  Otherwise,
              the subsystem will retain this message until a
              cancel-transaction message has been received with the
              same transaction-id value, or a continue-transaction
              message has been received with the same transaction-id
              value for the 'rollback' or 'commit' phase.

              Expected Response Message: transaction-response or error";

            uses transaction-id-obj;

            uses user-id-obj {
              refine "user-id" {
                mandatory true;
              }
            }
            uses client-addr-obj;

            leaf target {
              mandatory true;
              type string;
              description
                "Identifies the target datastore being edited.
                 The values 'candidate' and 'running' are supported.";
            }

            leaf validate {
              type boolean;
              default false;
              description
                "If 'true' then this start-transaction is for a validate
                 operation or edit that is not on the running
                 configuration datastore, so there will not be
                 any followup messages at all for this message.
                 The subsystem will release this info instead of caching it,
                 and not expect any more messages for the same value of
                 'transaction-id'.

                 If 'false' then this is a normal edit operation and
                 the apply and commit/rollback followup messages
                 will be sent. The subsystem will cache this data
                 until the transaction is cancelled or completed.";
            }

            leaf reverse-edit {
              type boolean;
              default false;
              description
                "If 'true' then this start-transaction is for a
                 reverse-edit operation.  All the phases should
                 be invoked in sequence for the provided edit-list.
                 The transaction can be discarded after sending
                 a response, like the 'validate=true' flag.
                 If 'false' then this is a normal edit operation.";
            }

            leaf load-config {
              type boolean;
              default false;
              description
                "If 'true' then this start-transaction is for a
                 <trigger-replay> operation. If 'false' then this is
                 a normal edit operation, probably caused by
                 a client <edit-config> operation.";
            }

            leaf is-hook-load {
              description
               "Specifies whether this is a LOAD operation or not";

              type boolean;
            }

            leaf is-hook-validate {
              description
               "Specifies whether this is a Validate operation or not";

              type boolean;
            }

            list edit {
              key "id";

              leaf id {
                type uint32;
                description "Arbitrary edit identifier.";
              }

              uses operation-parms;
              uses path-parm;
              uses hooks-param;
              uses editvars-parm;

              anydata newval {
                description
                  "Represents the new value, if any.
                   Should be present if operation is 'merge'
                   'replace', 'create', or 'load'.";
              }

              anydata curval {
                description
                  "Represents the current value, if any.
                   Should be present if operation is 'replace',
                   'delete', or 'commit'";
              }

              anydata update {
                description
                  "Represents the combination of a new value
                   and a current value, if any.
                   Used in EDIT3 callbacks.
                   Should be present if operation is 'merge'
                   'replace', 'create', or 'load'.";
              }

              anydata keys {
                description
                  "List of all ancestor or self key values for the
                   object being edited, identified by the 'path' value.
                   There will be one child leaf for each key in each list.";
              }

              // used if schema mount edit on mounted data node
              // the MPID applies to the edit node and all child nodes
              uses sm-mpid-parm;

              list child-edit {
                description
                 "List of EDIT2 children edits, only when the operation
                  is MERGE";

                uses operation-parms;
                uses editvars-parm;

                anydata newval {
                  description
                    "Represents the new child value, if any.
                     Should be present if operation is 'merge'
                     'replace', 'create', or 'load'.";
                }

                anydata curval {
                  description
                    "Represents the current child value, if any.
                     Should be present if operation is 'replace',
                     'delete', or 'commit'";
                }
              }  // list child edit
            }  // list edit
          }  // container start-transaction


          container continue-transaction {
            description
             "Message type: server-request;
              Purpose: Invoke a callback phase for an edit transaction
              in progress.


              Expected Response Message: transaction-response or error";

            uses transaction-id-obj;

            leaf phase {
              mandatory true;
              type enumeration {
                enum apply {
                  description
                    "Apply the curent transaction.
                     Resources can be reserved that will be
                     used in the commit phase.";
                }
                enum commit {
                  description
                    "Commit the current transaction.";
                }
                enum rollback {
                  description
                    "Rollback the current transaction.";
                }
              }
              description
                "The SIL-SA callback phase in progress.";
            }
          }  // container continue-transaction


          container transaction-response {
            description
             "Message type: subsys-response
              Purpose:
                - Set Hook: return added edits data or status
                - Post Set Hook: return added edits data or status
                - Transaction Hook: Expected Response Message: ok or error
                - If no Hook invoked: Expected Response Message: ok or error";

            uses transaction-id-obj;

            list added-edit {
              // no key!! The paths for added edits may be the same

              uses path-parm;
              uses hook-edit-parms;

              anydata edit {
                description
                  "Represents the added edits values, if any.
                   There will be one child node for each added edit
                   value.";
              }
            }
          }


          container cancel-transaction {
            description
             "Message type: server-event;
              Purpose: Cancel an edit transaction in progress.
              Expected Response Message: none";

            uses transaction-id-obj;

          }  // container cancel-transaction


          leaf trigger-replay {
            type empty;
            description
             "Message type: subsys-event;
              Purpose: Trigger a configueration replay to load
                 the running config data into the SIL-SA
                 instrumentation.
              Expected Response Message: none; server will send
                 a <start-transaction> if there is any
                 config for the SIL-SA functions registered
                 by the subsystem.";
          }  // leaf trigger-replay


          container load-event {
            description
             "Message type: server-event;
              Purpose: A module or bundle has been loaded or
                 unloaded at run-time. Subsys wil load SIL-SA code.
                 and trigger a register event for any SIL calls
                 registered.
              Expected Response Message: none";

            leaf load {
              type boolean;
              default true;
              description
                "Set to 'true' if this is a load event.
                 Set to 'false' if this is an unload event.";
            }

            uses config-parms;
          }  // container load-event


          container bundle-load-event {
            description
             "Message type: subsys-event;
              Purpose: A SIL-SA bundle has been loaded with
               a load-event sent from the server.  This has
               caused some modules to be loaded on the subsystem,
               that need to be reported back to the main server
               so the datastore validation, agt_state, and other
               system book-keeping can be done.
              Expected Response Message: none";

            uses bundle-parm;
            uses bundle-module-parm;

          }  // container bundle-load-event


          container get-request {
            description
              "Composite retrieval request to support NETCONF
               and RESTCONF get operations.
               Type: server-request
               Expected Response Message: subsys-response
                                   (get-response or error)";

            uses transaction-id-obj;
            uses user-id-obj;
            uses client-addr-obj;

            leaf flags {
              type bits {
                bit keys {
                  description
                    "Return only the key values";
                }
                bit config {
                  description
                    "Return config=true data nodes";
                }
                bit oper {
                  description
                    "Return config=false data nodes";
                }
                bit getnext {
                  description
                    "This is a get-next request instead of a
                    get request";
                }
                bit withdef {
                  description
                    "Return default values for missing nodes";
                }
                bit select {
                  description
                    "Return only the select nodes and any key leafs.
                     Ignore the config, oper, withdef flags if this
                     bit is set.";
                }
                bit with-origin {
                  description
                    "This is a <get-data> operation and the
                     with-origin parameter is selected.";
                }
                bit pre-process {
                  description
                    "Indicate that Subtree filter is doing
                     Pre process Selection nodes to see if the server
                     should start to write the parent node or not.";
                }
              }
              default "";
              description
                "Set of get request modifier flags";
            }

            leaf max-entries {
              type uint32;
              description
                "Max number of entries requested.
                 The default is '0' == all for leaf-list and
                 '1' for all other node types.";
            }

            uses path-parm;

            anydata keys {
              description
                "List of all ancestor or self key values for the
                 object being retrieved, identified by the 'path'
                 value. There will be one child leaf for each key
                 in each list.";
            }

            anydata matches {
              description
                "Represents any content-match child leafs for the
                 request. All leafs in this container must match the
                 corresponding child nodes in an instance of the
                 requested list or container, for that instance to
                 be returned.

                 Any content-match nodes must match in addition
                 to any key leafs specified in the 'keys' container.";
            }

            container select-nodes {
              list select-node {
                description
                  "Only requesting these nodes be returned. If no
                   entries and the 'select' bit is set in the flags
                   leaf, then no objects except list keys are
                   returned.";

                key objname;
                leaf objname {
                  type string;
                  description
                    "Object name of the select node";
                }
                leaf modname {
                  type string;
                  description
                    "Module name of the select node; If missing then
                     use the module-name of the path target object.";
                }
              }
            }

            // used if schema mount edit on mounted data node
            // the MPID applies to the GET2 node and all child nodes
            uses sm-mpid-parm;
          }

          container get-response {
            description
              "Composite retrieval response to support NETCONF
               and RESTCONF get operations.
               Type: subsys-response
               Expected Response Message: none";

            uses transaction-id-obj;

            leaf more-data {
              type boolean;
              default false;
              description
                "Indicates if the GET callback has more data to send";
            }

            leaf match-test-done {
              type boolean;
              default false;
              description
                "Indicates if the requested content-match tests have
                 be performed. Ignored if the 'matches' parameter
                 is missing or empty.";
            }

            leaf active-case-modname {
              type string;
              description
                "Module name of the active case if there is one.
                 Only applies if the GET2 object callback is for
                 a YANG choice-stmt.";
            }

            leaf active-case {
              type string;
              description
                "Name of the active case if there is one.
                 Only applies if the GET2 object callback is for
                 a YANG choice-stmt.";

            }

            leaf origin {
              type string;
              description
                "The NMDA origin value for this object.
                 Only applies for config=true list and
                 presence containers.";
            }

            choice return-choice {
              case return-one {
                description
                  "For all objects except YANG list, one entry
                   will be returned.  This can also be used
                   for YANG list, except in GETBULK mode.";
                uses return-val;
              }
              case return-getbulk {
                description
                  "For YANG list GETBULK mode.  There will be one entry
                   for each list instance that met the search criteria.
                   If the max_entries parameter was greater than zero,
                   there the number of instances of 'entry' should not
                   exceed this value.";
                list entry {
                  // no key!!
                  uses return-val;
                }
              }
            }
          }

          container notification {
            description
              "Subsystem generated YANG notification event
               for NETCONF and RESTCONF streams.
               Type: subsys-event
               Expected Response Message: none";

            leaf module-name {
              mandatory true;
              type string;
              description
                "Module name containing the notification definition";
            }

            leaf event-name {
              mandatory true;
              type string;
              description
                "Notification statement name";
            }

            leaf event-path {
              type string;
              description
                "Path string for a nested notification object.
                 Not present for top-level event types.";
            }

            leaf-list event-key {
              type string;
              ordered-by user;
              description
                "Value of an ancestor key for a nested notification.
                 The keys must be in the proper order. Top-to-bottom
                 and left to right. Not present for top-level event
                 types, or if a nested event type has no ancestor keys.";
            }

            leaf event-time {
              mandatory true;
              type string;
              description
                "Notification creation timestamp";
            }

            leaf stream-name {
              type yt:NcxName;
              default "NETCONF";
              description
                "Stream name for this notification";
            }

            // used if schema mount aware SEND function for
            // mounted notification is sending the event
            uses sm-mpid-parm;

            anydata parms {
              description
                "List of all parameters that this notification
                 is sending in the payload.";
            }
          }

          container rpc-request {
            description
             "Message type: server-request;
              Purpose: Start an RPC transaction which may require the
              SIL-SA callback functions on the subsystem to be invoked.

              This message requests that a new remote procedure
              call be validated and invoked on the subsystem.

              If there are input parameters the subsystem
              must validate them.

              If not valid or if the operation cannot be performed,
              the subsystem must return an error.

              Expected Response Message: rpc-response";

            uses transaction-id-obj;
            uses user-id-obj;
            uses client-addr-obj;

            leaf rpc-module {
              type yt:NcxName;
              mandatory true;
              description
                "Identifies the module name of the RPC definition.";
            }

            leaf rpc-name {
              type yt:NcxName;
              mandatory true;
              description
                "Identifies the name of the RPC definition.";
            }

            // used if schema mount ACTION on mounted RPC operation
            uses sm-mpid-parm;

            anydata rpc-input {
              description
                "Contains the RPC input data (if any).";
            }
          }

          container rpc-response {
            description
             "Message type: subsys-response
              Purpose: Return RPC data or status
              Expected Response Message: none";

            uses transaction-id-obj;

            choice response-type {
              leaf rpc-ok {
                type empty;
                description
                  "RPC successfully invoked";
              }
              anydata rpc-output {
                description
                  "Contains the RPC output data (if any).";
              }
            }
          }

          container action-request {
            description
             "Message type: server-request;
              Purpose: Start an ACTION transaction which may require the
              SIL-SA callback functions on the subsystem to be invoked.

              This message requests that a new action call be validated
              and invoked on the subsystem.

              If there are input parameters the subsystem
              must validate them.

              If not valid or if the operation cannot be performed,
              the subsystem must return an error.

              Expected Response Message: action-response";

            uses transaction-id-obj;
            uses user-id-obj;
            uses client-addr-obj;
            uses path-parm;

            anydata keys {
              description
                "List of all ancestor key values for the
                 action being invoked, identified by the 'path' value.
                 There will be one child leaf for each key in each list.";
            }

            // used if schema mount ACTION on mounted RPC operation
            uses sm-mpid-parm;

            anydata action-input {
              description
                "Contains the ACTION input data (if any).";
            }


          }

          container action-response {
            description
             "Message type: subsys-response
              Purpose: Return ACTION data or status
              Expected Response Message: none";

            uses transaction-id-obj;

            choice response-type {
              leaf action-ok {
                type empty;
                description
                  "ACTION successfully invoked";
              }
              anydata action-output {
                description
                  "Contains the ACTION output data (if any).";
              }
            }
          }

          container trans-start-hook {
            description
             "Message type: server-request;
              Purpose: Send a request which may require the
              SIL-SA callback functions on the subsystem to be invoked;
              Expected Response Message: <ok> or <error>.

              This message requests that Transaction Start Hook callbacks
              should be invoked on the subsystem.";

            uses transaction-id-obj;
            uses user-id-obj;
            uses client-addr-obj;

            leaf isvalidate {
              description
               "Specifies whether this is a <validate> operation or not.
                TRUE if this is a validate operation transaction";

              type boolean;
            }

            leaf isrollback {
              description
               "Specifies whether this is a confirmed commit timeout
                or a cancel-confirmed-commit operation.
                FALSE if this is some other type of transaction";

              type boolean;
            }

            leaf isrunning {
              description
               "Specifies whether this is transaction for running datastore.
                TRUE if this is a running datastore transaction";

              type boolean;
            }
          }

          container trans-complete-hook {
            description
             "Message type: server-event;
              Purpose: Send an event which may require the
                SIL-SA callback functions on the subsystem to be invoked;
              Expected Response Message: none";

            uses transaction-id-obj;
          }

          container hook-get-request {
            description
             "Message type: subsys-request;
              Purpose: Start a transaction which may require the
              server to run agt_val_get_data() API and return result.

              Get the val_value based on XPath of object instance
              This function will return value only if there is existing node
              in the datastore or there is defaults for the node.

              Expected Response Message: hook-get-response";

            uses path-parm;

            leaf isrunning {
              description
               "Specifies whether to retrieve a value from the running
                datastore or candidate";

              type boolean;
            }
          }

          container hook-get-response {
            description
             "Message type: server-reply;
              Purpose: server will send this element containing the
                requested val_value based on XPath of object instance.
              Expected Response Message: none";

            anydata value {
              description
                "Represents the val_value based on XPath of
                 object instance";
            }
          }

          container stream-callback-event {
            description
             "Message type: server-event;
              Purpose: An event-stream callback on a SIL-SA platform
                 needs to be invoked.  One event will be generated
                 for each remote subsystem entry found that needs
                 to be invoked. E.g., if 3 modules register but all are
                 mapped to the same stream, then 3 events would be
                 sent to the subsystem.
              Expected Response Message: none";

            uses event-stream-parm;

            uses stream-subevent-parm;

            // info to identify the SIL-SA callback to invoke
            leaf module-name {
              type yt:NcxName;
                description
                  "Module name to use to identify callback.";
            }

            leaf all-streams {
              type empty;
               description
                 "All streams flag to identify callback.";
            }
          }  // container stream-callback-event


          container commit-completeness-hook {
            description
             "Message type: server-request;
              Purpose: Send a request which may require the
                SIL-SA callback functions on the subsystem to be invoked;

                This message requests that Commit Completeness callbacks
                should be invoked on the subsystem.

              Expected Response Message: <ok> or <error>.";

            uses transaction-id-obj;
            uses user-id-obj;
            uses client-addr-obj;

            uses commit-phase-parm;
            uses commit-type-parm;
          } // container commit-completeness-hook

          container push-request {
            description
             "Message type: server-request;
              Purpose: Send a request to manage YANG Push subscriptions.
              A PUSH callback will be invoked to control the generation
              of push-data event messages.  Only the <operational>
              datastore is supported for PUSH callback support.
              Expected Response Message: <ok> or <error>.";

            uses user-id-obj;
            uses client-addr-obj;
            uses sa-push-parms;

          } // container push-request

        } // choice message-type
      } // container sil-sa
    } // augment
}
