module ietf-ipfix-bulk-data-export {
  yang-version 1.1;

  namespace
    "urn:ietf:params:xml:ns:yang:ietf-ipfix-bulk-data-export";

  prefix ietf-ibde;

  import ietf-ipfix {
    prefix ietf-ipfix;
  }

  import ietf-yang-types {
    prefix yang;
  }
  organization
    "IETF";

  contact
    "Web:      TBD
     List:     TBD

     Editor:   Joey Boyd
               <mailto:joey.boyd@adtran.com>

     Editor:   Marta Seda
               <mailto:marta.seda@calix.com>";

  // RFC Ed.: replace XXXX with actual RFC numbers and
  // remove this note.

  description
    "This module contains a collection of YANG definitions for the
     management exporting bulk data over IPFIX.

     This data model is designed for the Network Management Datastore
     Architecture defined in RFC 8342.

     The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL
     NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED',
     'MAY', and 'OPTIONAL' in this document are to be interpreted as
     described in BCP 14 (RFC 2119) (RFC 8174) when, and only when,
     they appear in all capitals, as shown here.

     Copyright (c) 2019 IETF Trust and the persons identified as
     authors of the code.  All rights reserved.

     Redistribution and use in source and binary forms, with or
     without modification, is permitted pursuant to, and subject to
     the license terms contained in, the Simplified BSD License set
     forth in Section 4.c of the IETF Trust's Legal Provisions
     Relating to IETF Documents
     (https://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC XXXX
     (https://www.rfc-editor.org/info/rfcXXXX); see the RFC itself
     for full legal notices.";

  revision 2019-10-28 {
    description
      "Initial revision.";
    reference
      "RFC XXXX: YANG Data Models for the IP Flow Information Export
                 (IPFIX) Protocol, Packet Sampling (PSAMP) Protocol,
                 and Bulk Data Export";
  }

  feature bulk-data {
    description
      "If supported, bulk data templates can be configured.";
  }

  typedef resource {
    type instance-identifier {
      require-instance false;
    }
    description
      "A resource from which bulk data will be exported.";
  }

  grouping bulk-data-template-parameters {
    description
      "Field Layout parameters.";

    leaf observation-domain-id {
      type uint32;
      default 0;
      description
        "An identifier of an Observation Domain that is locally
         unique to an Exporting Process (see RFC 7011 Section 3.1).

         Typically, this Information Element is for limiting the
         scope of other Information Elements.

         A value of 0 indicates that no specific Observation Domain
         is identified by this Information Element.";
    }

    container field-layout {
      description
        "Field Layout parameters.";

      list field {
        key name;
        min-elements 1;
        description
          "Superset of statistics field names or special
           field-names (e.g., timestamps, etc) for interpreting
           statistics that are included in the
           Packet Reports or Flow Records generated by the device.";

        leaf name {
          type ietf-ipfix:name-type;
          description
            "Name of the field.";
        }

        choice identifier {
          mandatory true;
          description
            "The Information Element to be added to the template.";

          leaf ie-name {
            type ietf-ipfix:ie-name-type;
            description
              "Name of the Information Element.";
          }

          leaf ie-id {
            type ietf-ipfix:ie-id-type;
            description
              "ID of the Information Element.";
          }
        }

        leaf ie-length {
          type uint16;
          units octets;
          description
            "Length of the field in which the Information
             Element is encoded.  A value of 65535 specifies a
             variable-length Information Element.  For Information
             Elements of integer and float type, the field length MAY
             be set to a smaller value than the standard length of
             the abstract data type if the rules of reduced size
             encoding are fulfilled.

             If not configured by the user, this parameter is set by
             the Monitoring Device.";
          reference
            "RFC 5101, Section 6.2.";
        }

        leaf ie-enterprise-number {
          type uint32;
          default 0;
          description
            "If this parameter is zero, the Information
             Element is registered in the IANA registry of IPFIX
             Information Elements or unspecified (if the
             Informational Element is not IANA registered).

             If this parameter is configured with a non-zero private
             enterprise number, the Information Element is
             enterprise-specific.";
          reference
            "RFC 5101; RFC 5103;
             IANA registry for Private Enterprise Numbers,
             http://www.iana.org/assignments/enterprise-numbers;
             IANA registry for IPFIX Entities,
             http://www.iana.org/assignments/ipfix.";
        }
      }
    }
  }

  augment "/ietf-ipfix:ipfix" {
    description
      "Augment IPFIX to add bulk data.";

    container bulk-data-export {
      description
        "Container for bulk data export nodes.";

      list template {
        key name;
        description
          "List of bulk data templates of the Monitoring Device.";

        leaf name {
          type ietf-ipfix:name-type;
          description
            "Name of the bulk data template.";
        }

        leaf enabled {
          type boolean;
          default "true";
          description
            "If true, this template is enabled and the specified
             data is able to be exported.";
        }

        leaf export-interval {
          type uint32;
          units "seconds";
          description
            "This parameter configures the interval (in
             seconds) for periodical export of Flow Records.

             If not configured by the user, the Monitoring Device
             sets this parameter.";
        }

        uses bulk-data-template-parameters;

        leaf-list exporting-process {
          if-feature ietf-ipfix:exporter;
          type leafref {
            path "/ietf-ipfix:ipfix"
               + "/ietf-ipfix:exporting-process"
               + "/ietf-ipfix:name";
          }
          description
            "Records are exported by all Exporting Processes in the
             list.";
        }

        choice resource-identifier {
          description
            "Method to select the resources from which the records
             are to be exported.";

          case resource-instance {
            leaf-list resource-instance {
              type resource;
              description
                "Records are sourced from all the resources in
                 this list.";
            }
          }
        }

        leaf data-records {
          type yang:counter64;
          units "Data Records";
          config false;
          description
            "The number of Data Records generated for this
             sampling template.  Discontinuities in the value of
             this counter can occur at re-initialization of the
             management system, and at other times as indicated by
             the value of Discontinuity Time.";
        }

        leaf discontinuity-time {
          type yang:date-and-time;
          config false;
          description
            "Timestamp of the most recent occasion at which
             the counter data records suffered a discontinuity.";
        }
      }
    }
  }
}
