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

module onf-application {
  namespace "http://opennetworking.org/enterprise/application";
  prefix app;

  import ietf-inet-types{ prefix ietf; }
  import ietf-yang-types{ prefix yg; }
  import onf-aether-types{ prefix at; }
  import onf-enterprise{ prefix ent; }

  organization "Open Networking Foundation.";
  contact "Scott Baker";
  description 
    "An Aether Application is an application that devices may
     connect to. Includes a set of endpoints where services are
     provided.";

  revision "2021-09-10" {
    description "Aether Application.";
    reference "RFC 6087";
  }

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

  container application {
    description "The top level container";

    list application {
      key "id";
      description
        "List of applications";

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

      leaf display-name {
        type string {
            length 1..80;
        }
        description "display name to use in GUI or CLI";
      }

      leaf description {
        type at:description;
        description "description of this application";
      }

      leaf address {
        type ietf:host;
        mandatory true;
        description
            "Address of this application. Either a hostname, an IP, or a subnet.";
      }

      list endpoint {
        key "name";
        leaf name {
          type string;
          description
              "Name of this endpoint";
        }
        leaf port-start {
          type ietf:port-number;
          mandatory true;
          description
              "First port in range";
        }
        leaf port-end {
          type ietf:port-number;
          description
              "Last port in range";
        }
        leaf protocol {
          type at:protocol;
          description
              "Protocol of this endpoint";
        }
        container mbr {
          description "Maximum bitrate";
          leaf uplink {
            type at:bitrate;
            units mbr;
            description "Per-Device per-Application mbr uplink data rate in mbps";
          }

          leaf downlink {
            type at:bitrate;
            units mbr;
            description "Per-Device per application mbr downlink data rate in mbps";
          }
        }
      }

      leaf enterprise {
        type leafref {
          path "/ent:enterprise/ent:enterprise/ent:id";
        }
        mandatory true;
        description
          "Link to enterprise that owns this Application. May be set to None if the application is global to all Enterprises.";
      }
    }
  }
}
