module ietf-https-notif {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-https-notif";
  prefix "hn";
  import ietf-inet-types {
    prefix inet;
    reference
      "RFC 6991: Common YANG Data Types.";
  }

  import ietf-subscribed-notifications {
    prefix sn;
    reference
      "I-D.ietf-netconf-subscribed-notifications";
  }

  import ietf-x509-cert-to-name {
    prefix x509c2n;
    reference
      "RFC 7407: A YANG Data Model for SNMP Configuration";
  }

  import ietf-tcp-client {
    prefix tcpc;
  }

  import ietf-tls-client {
    prefix tlsc;
  }

  import ietf-http-client {
    prefix httpc;
  }

  organization
    "IETF NETCONF Working Group";

  contact
    "WG Web:   <http://tools.ietf.org/wg/netconf>
     WG List:  <netconf@ietf.org>

     Authors: Mahesh Jethanandani (mjethanandani at gmail dot com)
              Kent Watsen (kent plus ietf at watsen dot net)";
  description
    "YANG module for configuring HTTPS base configuration.

     Copyright (c) 2018 IETF Trust and the persons identified as
     the document authors.  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
     (http://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC XXXX; 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.";

  revision "2020-03-09" {
    description
      "Initial Version.";
    reference
      "RFC XXXX, YANG Data Module for HTTPS Notifications.";
  }

  identity https {
    base sn:transport;
    description
      "HTTPS transport for notifications.";
  }

  grouping https-receivers {
    description
      "Grouping for HTTPS based receivers such that it can be
       implemented outside the constructs of a Subscription to YANG
       Notification [RFC8639] module.";
    container https-receivers {
      description
        "HTTPS based notifications.";

      list https-receiver {
        key "name";

        leaf name {
          type string;
          description
            "A name that uniquely identifies this receiver.";
        }

        container tcp-params {
          uses tcpc:tcp-client-grouping;
          description
            "TCP client parameters.";
        }
        container tls-params {
          uses tlsc:tls-client-grouping;
          description
            "TLS client parameters.";
        }

        container http-params {
          description
            "HTTP client parameters.";

          uses httpc:http-client-grouping;

          leaf path {
            type inet:uri;
            description
              "The absolute path for the resource on the remote
               HTTPS server. The absolute path as specified in
               RFC 3986 as 'path-absolute'.";
            reference
              "RFC 3986: URI Generic Syntax.";
          }
        }

        container receiver-identity {
          description
            "Specifies mechanism for identifying the receiver. The
             publisher MUST NOT include any content in a notification
             that the user is not authorized to view.";

          container cert-maps {
            uses x509c2n:cert-to-name;
            description
              "The cert-maps container is used by a TLS-based HTTP
               server to map the HTTPS client's presented X.509
               certificate to a 'local' username. If no matching and
               valid cert-to-name list entry is found, the publisher
               MUST close the connection, and MUST NOT
               not send any notifications over it.";
            reference
              "RFC 7407: A YANG Data Model for SNMP Configuration.";
          }
        }
        description
          "All receivers interested in this notification.";
      }
    }
  }

  augment "/sn:subscriptions" {
    description
      "Augment the subscirbed notification module to add in the
       receivers container.";
    uses https-receivers;
  }

  augment "/sn:subscriptions/sn:subscription/sn:receivers/sn:receiver" {
    leaf receiver-ref {
      type leafref {
        path "/sn:subscriptions/hn:https-receivers/hn:https-receiver/" +
             "hn:name";
      }
      description
        "Reference to a receiver.";
    }
    description
      "Augment the subscriptions container to define the receiver.";
  }
}
