module openconfig-transport-line-connectivity {

  yang-version "1";

  // namespace
  namespace "http://openconfig.net/yang/openconfig-transport-line-connectivity";

  prefix "oc-line-connect";

  // import some basic types
  import openconfig-extensions { prefix oc-ext; }
  import openconfig-transport-types { prefix oc-opt-types; }

  // meta
  organization "OpenConfig working group";

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

  description
    "This model describes the device-level connectivity
    (e.g., internal port-to-port) for optical transport line
    system elements such as wavelength routers (ROADMs) and
    amplifiers. All connections are uni-directional. Note that
    this model explicitly does not intend to model or provide
    a path to any higher layer topology modeling and is only
    for modeling internal links";

  oc-ext:openconfig-version "0.1.0";

  revision "2019-06-27" {
    description
      "Initial revision";
    reference "0.1.0";
  }

  // OpenConfig specific extensions for module metadata.
  oc-ext:regexp-posix;
  oc-ext:catalog-organization "openconfig";
  oc-ext:origin "openconfig";

  // identity statements
  identity PORT_CONNECTION_TYPE {
    description
      "The definition for different types of port connections
      when a specific port is not known";
  }

  identity EXTERNAL {
    base PORT_CONNECTION_TYPE;
    description
      "The port connection is external to the device";
  }

  // grouping statements

  grouping connection-state {
    description
      "Operational state data for connections";
  }

  grouping connection-config {
    description
      "Configuration data for line system connections";

    leaf index {
      type uint32;
      description
        "Index for the defined connection";
    }

    leaf source {
      type union {
        type string;
	// TODO(ejbrever): this should be a leafref instead of string,
        // but leafref in union is not supported in YANG 1.0.
        type identityref {
          base PORT_CONNECTION_TYPE;
        }
      }
      description
        "The user supplied name of the source port of the connection
        within the system. If the port is within the device, the
	string should reflect the name of the port as it appears in
	the components model. If the port is not represented in the
	components model (e.g., a port on a passive chassis), the
	string should reflect the system assigned name of the port.
	If the source port is not within the device, then an
	identityref of EXTERNAL should be specified.";
    }

    leaf dest {
      type union {
        type string;
	// TODO(ejbrever): this should be a leafref instead of string,
	// but leafref in union is not supported in YANG 1.0.
        type identityref {
          base PORT_CONNECTION_TYPE;
        }
      }
      description
        "The user supplied name of the destination port of the connection
        within the system. If the port is within the device, the string
	should reflect the name of the port as it appears in the
	components model. If the port is not represented in the components
	model (e.g., a port on a passive chassis), the string should
	reflect the system assigned name of the port. If the destination
	port is not within the device, then an identityref of EXTERNAL
	should be specified.";
    }

    leaf fiber-type {
      description
        "The type of fiber jumper used for the connection.";

      type identityref {
        base oc-opt-types:FIBER_JUMPER_TYPE;
      }
    }
  }

  grouping line-connectivity-top {
    description
      "Top level grouping for transport line connectivity data";

    container connections {
      description
        "Enclosing container for line system connections list";

      list connection {
        key "index";
        description
          "List of line system connections";

        leaf index {
          type leafref {
            path "../config/index";
          }
          description
            "Reference to index number of the connection";
        }

        container config {
          description
            "Configuration data";

          uses connection-config;
        }

        container state {

          config false;

          description
            "Operational state data";

          uses connection-config;
          uses connection-state;
        }
      }
    }
  }

  // data definition statements

  uses line-connectivity-top;


  // augment statements

  // rpc statements

  // notification statements

}