// SPDX-FileCopyrightText: 2021 Open Networking Foundation
//
// SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0

module onf-device-group {
  namespace "http://opennetworking.org/aether/device-group";
  prefix dg;

  import ietf-yang-types{ prefix yg; }
  import onf-aether-types { prefix at; }
  import onf-ip-domain{ prefix ipd; }
  import onf-site{ prefix st; }

  organization "Open Networking Foundation.";
  contact "Scott Baker";
  description 
    "An aether device group represents a list of device IMSIS.
     This list is expressed as a set of ranges,
         [(from_imsi, to_imsi),
          (from_imsi, to_imsi),
          ...].
     Each device group belongs to a site and has associated
     with it an ip-profile that determines the IP address
     and DNS settings that apply to devices within the
     group";

  revision "2021-06-02" {
    description "An Aether Device Group";
    reference "RFC 6087";
  }

  typedef device-group-id {
        type yg:yang-identifier {
            length 1..32;
        }
  }  

  container device-group {
    description "The top level container";

    list device-group {
      key "id";
      description
        "List of device groups";

      leaf id {
        type device-group-id;
        description "ID for this device group.";
      }

      leaf description {
        type at:description;
        description "description of this device group";
      }

      leaf display-name {
        type string {
            length 1..80;
        }
        description "display name to use in GUI or CLI";
      }      
      
      list imsis {
        // TODO: imsi-range-from cannot be used as a list index
        key "name";
        leaf name {
          type string;
        }
        leaf imsi-range-from {
          type uint64;
        }
        leaf imsi-range-to {
          type uint64;
        }
        description
          "List of imsi ranges that comprise this group. It's acceptable for
           a range to degenerate to being a singleton";
      }

      leaf ip-domain {
        type leafref {
          path "/ipd:ip-domain/ipd:ip-domain/ipd:id";
        }          
        description
          "Link to ip-domain settings that determine the pool of IP addresses,
           as well as the domain resolver settings to use";
      }

      leaf site {
        type leafref {
          path "/st:site/st:site/st:id";
        }
        mandatory true;
        description
          "Link to site";
      }
    }
  } 
}
