module netconf-node-topology {
    namespace "urn:opendaylight:netconf-node-topology";
    prefix "nettop";
    yang-version 1.1;

    import network-topology { prefix nt; revision-date 2013-10-21; }
    import yang-ext { prefix ext; revision-date "2013-07-09";}
    import netconf-node-optional { prefix nno; }
    import odl-netconf-device { prefix ond; }

    revision 2024-06-11 {
        description "Update the YANG model to version 1.1 and modify the rpc-credentials
          choice within the rpc-credentials grouping to be mandatory";
    }

    revision 2023-11-21 {
        description "Separated RPC create-device input credentials from odl-netconf-device";
    }

    revision 2022-12-25 {
        description "Refactored into odl-netconf-device";
    }

    revision "2015-01-14" {
        description "Initial revision of Topology model";
    }

    grouping netconf-node-fields {
      uses ond:connection-parameters;
      uses ond:netconf-schema-storage;
      uses ond:datastore-access;
    }

    grouping rpc-username-password {
        leaf username {
            type string;
        }

        leaf password {
            type string;
        }
    }

    grouping rpc-credentials {
        choice rpc-credentials {
            mandatory true;
            case login-pw {
                description "login-password credentials, encrypted.";

                container login-password {
                    uses rpc-username-password;
                }
            }
            case login-pw-unencrypted {
                description "login-password credentials, not encrypted.";

                container login-password-unencrypted {
                    uses rpc-username-password;
                }
            }
            case key-auth {
                description "key-based authentication, use the id for the pair thats stored in the keystore.";

                container key-based {
                    leaf key-id {
                        type string;
                    }

                    leaf username {
                        type string;
                    }
                }
            }
        }
    }

    rpc create-device {
        status deprecated;
        input {
            uses rpc-credentials;
            uses netconf-node-fields;
            uses nno:netconf-node-augmented-optional-fields;
            leaf node-id {
                type string;
            }
        }
    }

    rpc delete-device {
        status deprecated;
        input {
            leaf node-id {
                type string;
            }
        }
    }

    augment "/nt:network-topology/nt:topology/nt:topology-types" {
        container topology-netconf {
            presence "The presence of the container node indicates a network
                      of NETCONF devices";
        }
    }

    augment "/nt:network-topology/nt:topology/nt:node" {
        when "../../nt:topology-types/topology-netconf";
        ext:augment-identifier "netconf-node";

        uses ond:credentials;
        uses netconf-node-fields;
        uses ond:connection-oper;
        ext:mount;
    }
}