module ietf-oam-unitary-test {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-oam-unitary-test";
  prefix "oamut";

  // reference ietf-netmod-schedule-yang
  import ietf-schedule {
    prefix schedule;
    reference
      "RFC 9922: A Common YANG Data Model for Scheduling";
  }

  import ietf-yang-schema-mount {
     prefix yangmnt;
     reference
       "RFC 8528: YANG Schema Mount";
  }

  import ietf-inet-types {
     prefix inet;
     reference
       "RFC 9911: Common YANG Data Types";
  }

  organization
    "IETF OPSAWG (Operations and Management Area Working Group)";

  contact
    "WG Web:   <https://datatracker.ietf.org/wg/opsawg/>
     WG List:  <mailto:opsawg@ietf.org>
     Author:   Luis Miguel Contreras Murillo
               <luismiguel.contrerasmurillo@telefonica.com>
     Author:   Victor Lopez
               <victor.lopez@nokia.com>
     Author:   Qin Wu
               <bill.wu@huawei.com>";
  description
    "This module defines the 'ietf-oam-unitary-test' YANG model for
     activation of network diagnosis procedures.

    Copyright (c) 2026 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 Revised 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.

        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.";

    // RFC Ed.: update the date below with the date of RFC
    // publication and remove this note.
    // RFC Ed.: replace XXXX with actual RFC number and remove
    // this note.
  revision "2026-09-14" {
    description
      "Initial version";
    reference
      "RFCXXXX: A YANG Data Model for Network Diagnosis by Scheduling
       Sequences of OAM Tests";
       // Update with the correct RFC number when assigned
  }

  /* Identities */
  identity unitary-test-status {
           description
             "Base identity for unitary-test-status.";
  }
         identity planned {
           base unitary-test-status;
           description
             "Identity for planned.";
  }
  identity configured {
           base unitary-test-status;
           description
             "Identity for configured.";
  }
  identity ready {
           base unitary-test-status;
           description
             "Identity for ready.";
  }
  identity on-going {
           base unitary-test-status;
           description
             "Identity for on-going.";
  }
  identity stop {
           base unitary-test-status;
           description
             "Identity for stop.";
  }
  identity success {
           base unitary-test-status;
           description
             "Identity for success.";
  }

  identity error {
           base unitary-test-status;
           description
             "Identity for error.";
  }

  identity resource-contention {
           base error;
           description
             "Identity for resource contention.";
  }

  identity priority {
           base error;
           description
             "Identity for priority.";
  }

  identity basic-test-type {
       description
         "Base identity of basic test type.";
  }
  identity connection-oriented-oam {
       base basic-test-type;
       description
         "Base identity of connection oriented oam test type.";
       reference
         "RFC 8531: Connection-Oriented OAM YANG Data Model";
  }
  identity connectionless-oam {
       base basic-test-type;
       description
         "Base identity of connectionless oam test type.";
       reference
         "RFC 8532: Generic YANG Data Model for Connectionless OAM";
  }
  identity in-situ-oam {
       base basic-test-type;
       description
         "Base identity of In Situ OAM test type.";
       reference
        "RFC 9617: In Situ OAM (IOAM) YANG Data Model";
  }
  identity twamp {
       base basic-test-type;
       description
         "Base identity of TWAMP test type.";
       reference
         "RFC 8913: Two-Way Active Measurement Protocol (TWAMP) YANG Data Model";
  }
  identity lsp-ping {
       base basic-test-type;
       description
         "Base identity of MPLS LSP Ping test type.";
       reference
        "RFC 9228: MPLS LSP Ping YANG Data Model";
  }
  identity bfd {
       base basic-test-type;
       description
         "Base identity of BFD test type.";
       reference
        "RFC 9107: BFD (Bidirectional Forwarding Detection) YANG Model";
  }
  grouping oam-unitary-test {
    description
       "Specifies a grouping for OAM unitary test for network
        diagnosis procedures.";

    leaf name {
      type string;
      description
        "Defines the name of the test.";
    }
    list ne-config {
      key ne-id;
      description "List of node configurations required to enable the
        unitary tests.";

      leaf ne-id {
        type inet:host;
        description
          "This is identification of a network node within an autonomous system
           such as router, switch, firewalls, etc. It should be as fine-grained
           as possible to both guide the operator and guarantee uniqueness of the
           network element.";
      }

       leaf managed {
         type boolean;
         default "true";
         description
           "True if the host can access oam unitary test
            using the root mount point.  This value
            may not be modifiable in all implementations.";
       }
      leaf test-type {
           type identityref {
             base basic-test-type;
           }
           description
             "Choose the type of test.";
         }
       container root {
         description
           "Container for mount point.";
         yangmnt:mount-point "root" {
           description
             "Root for models supported per oam unitary test.
                      This mount point may or may not be inline based on
              the server implementation.

              When the associated 'managed' leaf is 'false', any
              operation that attempts to access information below
              the root SHALL fail with an error-tag of
              'access-denied' and an error-app-tag of
              'oamut-not-managed'.";
         }
       }
    }
  }

  container oam-unitary-tests {
    description
      "Container for OAM unitary tests activation for network
      diagnosis procedures.";
    list oam-unitary-test {
      key name;
      description
        "List of OAM unitary tests activation for network diagnosis
        procedures.";
      uses oam-unitary-test;
      uses schedule:schedule-status;
      leaf unitary-test-status {
            type identityref {
                  base unitary-test-status;
            }
                config false;
        description
          "Status of the test.";
      }
  choice schedule-class {
     description
           "Choice based on the type of the time range.";
   container period {
         description
           "The OAM Test takes effect based on a precise period of
                time.";
           uses schedule:period-of-time;
   }
   container recurrence {
         description
           "The OAM test takes effect based on a recurrence rule.";
         uses schedule:recurrence-utc;
    }
   }
  }
 }
}
