submodule openconfig-isis-routing {

  belongs-to openconfig-isis {
    prefix "oc-isis";
  }

  // import some basic types
  import openconfig-isis-types { prefix oc-isis-types; }
  import openconfig-extensions { prefix oc-ext; }
  import openconfig-mpls-types { prefix oc-mplst; }
  import openconfig-segment-routing { prefix oc-sr; }

  // meta
  organization "OpenConfig working group";

  contact
    "OpenConfig working group
    www.openconfig.net";

  description
    "This module describes YANG model for ISIS Routing";

  oc-ext:openconfig-version "0.3.2";

  revision "2017-07-26" {
    description
      "Update LSDB and fix bugs.";
    reference "0.3.2";
  }

  revision "2017-05-15" {
    description
      "Refactor LSDB.";
    reference "0.3.0";
  }

  revision "2017-01-13" {
    description
      "Remove top-level /isis container";
    reference "0.2.1";
  }

  revision "2016-12-15" {
    description
      "Add segment routing to IS-IS module";
    reference "0.2.0";
  }

  revision "2016-10-18" {
    description
      "Initial revision of IS-IS models.";
    reference "0.1.0";
  }

  // extension statements

  // feature statements

  // identity statements

  // typedef statements

  // grouping statements

  grouping rt-admin-config {
    description
      "Re-usable grouping to enable or disable a particular IS-IS feature.";

    leaf enabled {
      type boolean;
      description
        "When set to true, the functionality within which this leaf is
        defined is enabled, when set to false it is explicitly disabled.";
    }
  }

  grouping isis-afi-safi-config {
    description
      "This grouping defines Address-Family configuration parameters";

    leaf afi-name {
      type identityref {
        base oc-isis-types:AFI_TYPE;
      }
      description
        "Address-family type.";
    }

    leaf safi-name {
      type identityref {
        base oc-isis-types:SAFI_TYPE;
      }
      description
        "Subsequent address-family type.";
    }
  }

  grouping isis-shortcuts-afi-config {
    description
      "This grouping defines ISIS Shortcuts configuration parameters";

    leaf afi-name {
      type identityref {
        base oc-isis-types:AFI_TYPE;
      }
      description "Address-family type.";
    }

    leaf-list nh-type {
      type identityref {
        base oc-mplst:PATH_SETUP_PROTOCOL;
      }
      description "Tunnel NH Type(RSVP,SR). When present it implies
      	that nh-type shortcut is enabled for a specified AFI.";
    }
  }

  grouping isis-shortcuts-config {
    description
      "This grouping defines ISIS Shortcuts consfiguration parameters";

    container config {
      description "This container defines ISIS shortcuts configuration.";
      uses rt-admin-config;
    }

    container state {
      config false;
      description "This container defines state for ISIS shortcuts.";
      uses rt-admin-config;
    }
  }

  grouping isis-mt-config {
    description
      "This grouping defines ISIS multi-topology configuration parameters";

    leaf afi-name {
      type identityref {
        base oc-isis-types:AFI_TYPE;
      }
      description
        "Address-family type.";
    }
    leaf safi-name {
      type identityref {
        base oc-isis-types:SAFI_TYPE;
      }
      description
        "Subsequent address-family type.";
    }
    //prefer single topology
  }



  // *********** STRUCTURE GROUPINGS **********************

  grouping isis-metric-config {
    description
      "This grouping defines ISIS metric configuration";

    leaf metric {
      type uint32;
      default 10;
      description "ISIS metric value(default=10).";
    }
  }

  grouping isis-afi-safi-list {
    description
      "This grouping defines address-family configuration and state
      information";

    list af {
      key "afi-name safi-name";

      description
            "Address-family/Subsequent Address-family list.";

      leaf afi-name {
        type leafref {
          path "../config/afi-name";
        }
        description
           "Reference to address-family type";
      }

      leaf safi-name {
        type leafref {
          path "../config/safi-name";
        }
        description
           "Reference to subsequent address-family type";
      }

      container config {
        description
          "This container defines AFI-SAFI configuration parameters";

        uses isis-afi-safi-config;
        uses isis-metric-config;
        uses rt-admin-config;
      }

      container state {
        config false;
        description
          "This container defines AFI-SAFI State information";

        uses isis-afi-safi-config;
        uses isis-metric-config;
        uses rt-admin-config;
      }

      uses isis-mt-list;
    }
  }

  grouping isis-if-afi-safi-list {
    description
      "This grouping defines address-family configuration and state
      information";

    list af {
      key "afi-name safi-name";

      description
            "Address-family/Subsequent Address-family list.";

      leaf afi-name {
        type leafref {
          path "../config/afi-name";
        }
        description
           "Reference to address-family type";
      }

      leaf safi-name {
        type leafref {
          path "../config/safi-name";
        }
        description
           "Reference to subsequent address-family type";
      }

      container config {
        description
           "This container defines AFI-SAFI configuration parameters. Single
            topology is the default setting.";
        uses isis-afi-safi-config;
        uses isis-metric-config;
        uses rt-admin-config;
      }

      container state {
        config false;
        description
           "This container defines AFI-SAFI State information";
        uses isis-afi-safi-config;
        uses isis-metric-config;
        uses rt-admin-config;
      }

      uses oc-sr:sr-igp-interface-top;
    }
  }
  
  grouping isis-if-global-afi-safi-list {
    description
      "This grouping defines address-family configuration and state
      information";

    list af {
      key "afi-name safi-name";

      description
            "Address-family/Subsequent Address-family list.";

      leaf afi-name {
        type leafref {
          path "../config/afi-name";
        }
        description
           "Reference to address-family type";
      }

      leaf safi-name {
        type leafref {
          path "../config/safi-name";
        }
        description
           "Reference to subsequent address-family type";
      }

      container config {
        description
           "This container defines AFI-SAFI configuration parameters. Single
            topology is the default setting.";
        uses isis-afi-safi-config;
        uses rt-admin-config;
      }

      container state {
        config false;
        description
           "This container defines AFI-SAFI State information";
        uses isis-afi-safi-config;
        uses rt-admin-config;
      }
    }
  }

  grouping isis-shortcuts-afi-list {
    description
      "This grouping defines ISIS Shorcuts configuration and
      state information";

    list afi {
      key "afi-name";

      description
        "Address-family list.";

      leaf afi-name {
        type leafref {
          path "../config/afi-name";
        }
        description
          "Reference to address-family type.";
      }

      container config {
        description
          "This container defines ISIS Shortcuts configuration parameters";
        uses isis-shortcuts-afi-config;
      }

      container state {
        config false;
        description
          "This container defines ISIS Shortcuts state information";
        uses isis-shortcuts-afi-config;
      }
    }
  }

  grouping isis-mt-list {
    description
      "This grouping defines multi-topology address-family configuration and
      state information. MT0 - IPv4 Unicast, MT2 - IPv6 Unicast, MT3 -
      IPv4 Multicast, MT4 - IPv6 Multicast";

    container multi-topology {
      description
        "This container defines multi-topology address-family configuration
        and state information. ISIS TLV 235, 237.";

      container config {
      description
        "This container defines AFI-SAFI multi-topology configuration
        parameters";
      uses isis-mt-config;
      }

      container state {
      config false;
      description
        "This container defines AFI-SAFI multi-topology state information";
      uses isis-mt-config;
      uses rt-admin-config;
      }
    }
  }
}
