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

module service-rule {
  namespace "http://opennetworking.org/aether/service-rule";
  prefix sr;

  organization "Open Networking Foundation.";
  contact "Scott Baker";
  description "To generate JSON from this use command
    pyang -f jtoxx test1.yang | python3 -m json.tool > test1.json
    Copied from YangUIComponents project";

  revision "2021-03-04" {
    description "An Aether Service Rule";
    reference "RFC 6087";
  }

  typedef service-rule-id {
        type string {
            length 1..32;
        }
    description "The typedef for service-rule-id";
  }

  container service-rule {
    description "The top level container";

    list service-rule {
      key "id";
      description
        "List of service rules";

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

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

      leaf charging-rule-name {
        type string {
            length 1..80;
        }
        description "name of charging rule";
      }

      container qos {
        leaf qci {
          type uint32 {
            range 0..85;
          }
          default 9;
          description
            "QoS Class Identifier";
        }

        container arp {
          leaf priority {
            type uint32 {
              range 0..15;
            }
            default 0;
            description
              "Priority";
          }
          leaf preemption-capability {
            type boolean;
            default true;
            description
              "True if a bearer with lower priority should be dropped";
          }
          leaf preemption-vulnerability {
            type boolean;
            default true;
            description
              "This bearer may be dropped for a bearer with higher priority";
          }
          description "Evolved-ARP";
        }

        container maximum-requested-bandwidth {
          leaf uplink {
            type uint32 {
              range 0..4294967295;
            }
	    units bps;
            default 0;
            description
              "Upstream maximum requested bandwidth";
          }
          leaf downlink {
            type uint32 {
              range 0..4294967295;
            }
            units bps;
            default 0;
            description
              "Downstream maximum requested bandwidth";
          }
          description "The container for maximum-requested-bandwidth";
        }

        container guaranteed-bitrate {
          leaf uplink {
            type uint32 {
              range 0..4294967295;
            }
            units bps;
            default 0;
            description
              "Upstream guaranteed bitrate";
          }
          leaf downlink {
            type uint32 {
              range 0..4294967295;
            }
            units bps;
            default 0;
            description
              "Downstream guaranteed bitrate";
          }
          description "The container for guaranteed-bitrate";
        }

        container aggregate-maximum-bitrate {
          leaf uplink {
            type uint32 {
              range 0..4294967295;
            }
	    units bps;
            default 0;
            description
              "Upstream aggregate maximum bitrate";
          }
          leaf downlink {
            type uint32 {
              range 0..4294967295;
            }
            units bps;
            default 0;
            description
              "Downstream aggregate maximum bitrate";
          }
	  description "The container for aggregate-maximum-bitrate";
        }
        description "The container for qos";
      }

      container flow {
        leaf specification {
          type string {
            length 1..1024;
          }
          description "specification of this flow";
        }
        description "The container for flow";
      }

      leaf description {
        type string {
          length 1..100;
        }
        description "description of this rule";
      }
    }
  }
}
