<?xml version="1.0"?>
<interfaceDefinition>
  <node name="service">
    <children>
      <node name="dns">
        <properties>
          <help>Domain Name System (DNS) related services</help>
        </properties>
        <children>
          <node name="dynamic" owner="${vyos_conf_scripts_dir}/dns_dynamic.py">
            <properties>
              <help>Dynamic DNS</help>
            </properties>
            <children>
              <tagNode name="address">
                <properties>
                  <help>Obtain IP address to send Dynamic DNS update for</help>
                  <valueHelp>
                    <format>txt</format>
                    <description>Use interface to obtain the IP address</description>
                  </valueHelp>
                  <valueHelp>
                    <format>web</format>
                    <description>Use HTTP(S) web request to obtain the IP address</description>
                  </valueHelp>
                  <completionHelp>
                    <script>${vyos_completion_dir}/list_interfaces</script>
                    <list>web</list>
                  </completionHelp>
                  <constraint>
                    #include <include/constraint/interface-name.xml.i>
                    <regex>web</regex>
                  </constraint>
                </properties>
                <children>
                  <node name="web-options">
                    <properties>
                      <help>Options when using HTTP(S) web request to obtain the IP address</help>
                    </properties>
                    <children>
                      #include <include/url.xml.i>
                      <leafNode name="skip">
                        <properties>
                          <help>Pattern to skip from the HTTP(S) respose</help>
                          <valueHelp>
                            <format>txt</format>
                            <description>Pattern to skip from the HTTP(S) respose to extract the external IP address</description>
                          </valueHelp>
                        </properties>
                      </leafNode>
                    </children>
                  </node>
                  <tagNode name="rfc2136">
                    <properties>
                      <help>RFC2136 nsupdate configuration</help>
                      <valueHelp>
                        <format>txt</format>
                        <description>RFC2136 nsupdate service name</description>
                      </valueHelp>
                    </properties>
                    <children>
                      #include <include/generic-description.xml.i>
                      #include <include/dns/dynamic-service-host-name-server.xml.i>
                      <leafNode name="key">
                        <properties>
                          <help>File containing the TSIG secret key shared with remote DNS server</help>
                          <valueHelp>
                            <format>filename</format>
                            <description>File in /config/auth directory</description>
                          </valueHelp>
                          <constraint>
                            <validator name="file-path" argument="--strict --parent-dir /config/auth"/>
                          </constraint>
                        </properties>
                      </leafNode>
                      #include <include/dns/time-to-live.xml.i>
                      <leafNode name="zone">
                        <properties>
                          <help>Forwarding zone to be updated</help>
                          <valueHelp>
                            <format>txt</format>
                            <description>RFC2136 Zone to be updated</description>
                          </valueHelp>
                          <constraint>
                            <validator name="fqdn"/>
                          </constraint>
                        </properties>
                      </leafNode>
                    </children>
                  </tagNode>
                  <tagNode name="service">
                    <properties>
                      <help>Dynamic DNS configuration</help>
                      <valueHelp>
                        <format>txt</format>
                        <description>Dynamic DNS service name</description>
                      </valueHelp>
                    </properties>
                    <children>
                      #include <include/generic-description.xml.i>
                      #include <include/dns/dynamic-service-host-name-server.xml.i>
                      #include <include/generic-username.xml.i>
                      #include <include/generic-password.xml.i>
                      <leafNode name="protocol">
                        <properties>
                          <help>ddclient protocol used for Dynamic DNS service</help>
                          <completionHelp>
                            <script>${vyos_completion_dir}/list_ddclient_protocols.sh</script>
                          </completionHelp>
                          <constraint>
                            <validator name="ddclient-protocol"/>
                          </constraint>
                        </properties>
                      </leafNode>
                      <leafNode name="zone">
                        <properties>
                          <help>DNS zone to update (not used by all protocols)</help>
                          <valueHelp>
                            <format>txt</format>
                            <description>Name of DNS zone</description>
                          </valueHelp>
                        </properties>
                      </leafNode>
                      <leafNode name="ip-version">
                        <properties>
                          <help>IP address version to use</help>
                          <valueHelp>
                            <format>_ipv4</format>
                            <description>Use only IPv4 address</description>
                          </valueHelp>
                          <valueHelp>
                            <format>_ipv6</format>
                            <description>Use only IPv6 address</description>
                          </valueHelp>
                          <valueHelp>
                            <format>both</format>
                            <description>Use both IPv4 and IPv6 address</description>
                          </valueHelp>
                          <completionHelp>
                            <list>ipv4 ipv6 both</list>
                          </completionHelp>
                          <constraint>
                            <regex>(ipv[46]|both)</regex>
                          </constraint>
                          <constraintErrorMessage>IP Version must be literal 'ipv4', 'ipv6' or 'both'</constraintErrorMessage>
                        </properties>
                        <defaultValue>ipv4</defaultValue>
                      </leafNode>
                    </children>
                  </tagNode>
                </children>
              </tagNode>
              <leafNode name="timeout">
                <properties>
                  <help>Time in seconds to wait between DNS updates</help>
                  <valueHelp>
                    <format>u32:60-3600</format>
                    <description>Time in seconds</description>
                  </valueHelp>
                  <constraint>
                    <validator name="numeric" argument="--range 60-3600"/>
                  </constraint>
                  <constraintErrorMessage>Timeout must be between 60 and 3600 seconds</constraintErrorMessage>
                </properties>
                <defaultValue>300</defaultValue>
              </leafNode>
            </children>
          </node>
        </children>
      </node>
    </children>
  </node>
</interfaceDefinition>