module ietf-lmap-common {

  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-lmap-common";
  prefix "lmap";

  import ietf-inet-types {
    prefix inet;
  }

  organization
    "IETF Large-Scale Measurement of Broadband Performance
     Working Group";

  contact
    "WG Web:   <https://datatracker.ietf.org/wg/lmap>
     WG List:  <mailto:lmap@ietf.org>

     Editor:   Juergen Schoenwaelder
               <j.schoenwaelder@jacobs-university.de>

     Editor:   Vaibhav Bajpai
               <bajpaiv@in.tum.de>";

  description
    "This module provides common definitions used by the data
     models written for Large-Scale Measurement Platforms (LMAPs).
     This module defines typedefs and groupings but no schema
     tree elements.";

  revision "2017-08-08" {
    description
      "Initial version";
    reference
      "RFC 8194: A YANG Data Model for LMAP Measurement Agents";
  }

  /*
   * Typedefs
   */

  typedef identifier {
    type string {
      length "1..max";
    }
    description
      "A string value used to name something.";
  }

  typedef tag {
    type string {
      length "1..max";
    }
    description
      "A tag consists of at least one character.";
  }

  typedef glob-pattern {
    type string {
      length "1..max";
    }
    description
      'A glob style pattern (following POSIX.2 fnmatch() without
       special treatment of file paths):

         *         matches a sequence of characters
         ?         matches a single character
         [seq]     matches any character in seq
         [!seq]    matches any character not in seq

       A backslash followed by a character matches the following
       character.  In particular:

         \*        matches *
         \?        matches ?
         \\        matches \

       A sequence seq may be a sequence of characters (e.g., [abc]
       or a range of characters (e.g., [a-c]).';
  }

  typedef wildcard {
    type string {
      pattern '\*';
    }
    description
      "A wildcard for calendar scheduling entries.";
  }

  typedef cycle-number {
    type string {
      pattern '[0-9]{8}\.[0-9]{6}';
    }
    description
      "A cycle number represented in the format YYYYMMDD.HHMMSS
       where YYYY represents the year, MM the month (1..12), DD
       the day of the months (01..31), HH the hour (00..23), MM
       the minute (00..59), and SS the second (00..59).  The cycle
       number is using Coordinated Universal Time (UTC).";
  }

  typedef month {
    type enumeration {
      enum january {
        value 1;
        description
          "January of the Gregorian calendar.";
      }
      enum february {
        value 2;
        description
          "February of the Gregorian calendar.";
      }
      enum march {
        value 3;
        description
          "March of the Gregorian calendar.";
      }
      enum april {
        value 4;
        description
          "April of the Gregorian calendar.";
      }

      enum may {
        value 5;
        description
          "May of the Gregorian calendar.";
      }
      enum june {
        value 6;
        description
          "June of the Gregorian calendar.";
      }
      enum july {
        value 7;
        description
          "July of the Gregorian calendar.";
      }
      enum august {
        value 8;
        description
          "August of the Gregorian calendar.";
      }
      enum september {
        value 9;
        description
          "September of the Gregorian calendar.";
      }
      enum october {
        value 10;
        description
          "October of the Gregorian calendar.";
      }
      enum november {
        value 11;
        description
          "November of the Gregorian calendar.";
      }
      enum december {
        value 12;
        description
          "December of the Gregorian calendar.";
      }
    }
    description
      "A type modeling the month in the Gregorian calendar.";
  }

  typedef month-or-all {
    type union {
      type month;
      type wildcard;
    }
    description
      "A month or a wildcard indicating all twelve months.";
  }

  typedef day-of-month {
    type uint8 { range "1..31"; }
    description
      "A day of a month of the Gregorian calendar.";
  }

  typedef day-of-months-or-all {
    type union {
      type day-of-month;
      type wildcard;
    }
    description
      "A day of a month or a wildcard indicating all days
       of a month.";
  }

  typedef weekday {
    type enumeration {
      enum monday {
        value 1;
        description
          "Monday of the Gregorian calendar.";
      }
      enum tuesday {
        value 2;
        description
          "Tuesday of the Gregorian calendar.";
      }
      enum wednesday {
        value 3;
        description
          "Wednesday of the Gregorian calendar.";
      }
      enum thursday {
        value 4;
        description
          "Thursday of the Gregorian calendar.";
      }

      enum friday {
        value 5;
        description
          "Friday of the Gregorian calendar.";
      }
      enum saturday {
        value 6;
        description
          "Saturday of the Gregorian calendar.";
      }
      enum sunday {
        value 7;
        description
          "Sunday of the Gregorian calendar.";
      }
    }
    description
     "A type modeling the weekdays in the Gregorian calendar.
      The numbering follows the ISO 8601 scheme.";
    reference
     "ISO 8601:2004: Data elements and interchange formats --
                     Information interchange -- Representation
                     of dates and times";
  }

  typedef weekday-or-all {
    type union {
      type weekday;
      type wildcard;
    }
    description
      "A weekday or a wildcard indicating all seven weekdays.";
  }

  typedef hour {
    type uint8 { range "0..23"; }
    description
      "An hour of a day.";
  }

  typedef hour-or-all {
    type union {
      type hour;
      type wildcard;
    }
    description
      "An hour of a day or a wildcard indicating all hours
       of a day.";
  }

  typedef minute {
    type uint8 { range "0..59"; }
    description
      "A minute of an hour.";
  }

  typedef minute-or-all {
    type union {
      type minute;
      type wildcard;
    }
    description
      "A minute of an hour or a wildcard indicating all
       minutes of an hour.";
  }

  typedef second {
    type uint8 { range "0..59"; }
    description
      "A second of a minute.";
  }

  typedef second-or-all {
    type union {
      type second;
      type wildcard;
    }
    description
      "A second of a minute or a wildcard indicating all
       seconds of a minute.";
  }

  typedef status-code {
    type int32;
    description
      "A status code returned by the execution of a Task.  Note
       that the actual range is implementation dependent, but it
       should be portable to use values in the range 0..127 for
       regular exit codes.  By convention, 0 indicates successful
       termination.  Negative values may be used to indicate
       abnormal termination due to a signal; the absolute value
       may identify the signal number in this case.";
  }

  typedef timezone-offset {
    type string {
      pattern 'Z|[\+\-]\d{2}:\d{2}';
    }
    description
      "A time zone offset as it is used by the date-and-time type
       defined in the ietf-yang-types module.  The value Z is
       equivalent to +00:00.  The value -00:00 indicates an
       unknown time-offset.";
    reference
      "RFC 6991: Common YANG Data Types";
  }

  /*
   * Groupings
   */

  grouping registry-grouping {
    description
      "This grouping models a list of entries in a registry
       that identify functions of a Task.";

    list function {
      key uri;
      description
        "A list of entries in a registry identifying functions.";

      leaf uri {
        type inet:uri;
        description
          "A URI identifying an entry in a registry.";
      }

      leaf-list role {
        type string;
        description
          "A set of roles for the identified registry entry.";
      }
    }
  }

  grouping options-grouping {
    description
      "A list of options of a Task.  Each option is a name/value
       pair (where the value may be absent).";

    list option {
      key "id";
      ordered-by user;
      description
        "A list of options passed to the Task.  It is a list of
         key/value pairs and may be used to model options.
         Options may be used to identify the role of a Task
         or to pass a Channel name to a Task.";

      leaf id {
        type lmap:identifier;
        description
          "An identifier uniquely identifying an option.  This
           identifier is required by YANG to uniquely identify
           a name/value pair, but it otherwise has no semantic
           value";
      }

      leaf name {
        type string;
        description
          "The name of the option.";
      }

      leaf value {
        type string;
        description
          "The value of the option.";
      }
    }
  }
}
