<?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}/service_dns_dynamic.py">
            <properties>
              <help>Dynamic DNS</help>
              <priority>990</priority>
            </properties>
            <children>
              <tagNode name="name">
                <properties>
                  <help>Dynamic DNS configuration</help>
                  <valueHelp>
                    <format>txt</format>
                    <description>Dynamic DNS service name</description>
                  </valueHelp>
                  <constraint>
                    #include <include/constraint/alpha-numeric-hyphen-underscore.xml.i>
                  </constraint>
                  <constraintErrorMessage>Dynamic DNS service name must be alphanumeric and can contain hyphens and underscores</constraintErrorMessage>
                </properties>
                <children>
                  #include <include/generic-description.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>
                  <node name="address">
                    <properties>
                      <help>Obtain IP address to send Dynamic DNS update for</help>
                    </properties>
                    <children>
                      #include <include/generic-interface.xml.i>
                      <node name="web">
                        <properties>
                          <help>HTTP(S) web request to use</help>
                        </properties>
                        <children>
                          #include <include/url-http-https.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>
                    </children>
                  </node>
                  <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>
                  <leafNode name="host-name">
                    <properties>
                      <help>Hostname to register with Dynamic DNS service</help>
                      <constraint>
                          #include <include/constraint/host-name.xml.i>
                          <regex>(\@|\*)[-.A-Za-z0-9]*</regex>
                      </constraint>
                      <constraintErrorMessage>Host-name must be alphanumeric, can contain hyphens and can be prefixed with '@' or '*'</constraintErrorMessage>
                      <multi/>
                    </properties>
                  </leafNode>
                  <leafNode name="server">
                    <properties>
                      <help>Remote Dynamic DNS server to send updates to</help>
                      <valueHelp>
                        <format>ipv4</format>
                        <description>IPv4 address of the remote server</description>
                      </valueHelp>
                      <valueHelp>
                        <format>ipv6</format>
                        <description>IPv6 address of the remote server</description>
                      </valueHelp>
                      <valueHelp>
                        <format>hostname</format>
                        <description>Fully qualified domain name of the remote server</description>
                      </valueHelp>
                      <constraint>
                        <validator name="ip-address"/>
                        <validator name="fqdn"/>
                      </constraint>
                      <constraintErrorMessage>Remote server must be IP address or fully qualified domain name</constraintErrorMessage>
                    </properties>
                  </leafNode>
                  <leafNode name="zone">
                    <properties>
                      <help>DNS zone to be updated</help>
                      <valueHelp>
                        <format>txt</format>
                        <description>Name of DNS zone</description>
                      </valueHelp>
                      <constraint>
                        <validator name="fqdn"/>
                      </constraint>
                    </properties>
                  </leafNode>
                  #include <include/generic-username.xml.i>
                  #include <include/generic-password.xml.i>
                  <leafNode name="key">
                    <properties>
                      <help>File containing TSIG authentication key for RFC2136 nsupdate on 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="wait-time">
                    <properties>
                      <help>Time in seconds to wait between update attempts</help>
                      <valueHelp>
                        <format>u32:60-86400</format>
                        <description>Time in seconds</description>
                      </valueHelp>
                      <constraint>
                        <validator name="numeric" argument="--range 60-86400"/>
                      </constraint>
                      <constraintErrorMessage>Wait time must be between 60 and 86400 seconds</constraintErrorMessage>
                    </properties>
                  </leafNode>
                  <leafNode name="expiry-time">
                    <properties>
                      <help>Time in seconds for the hostname to be marked expired in cache</help>
                      <valueHelp>
                        <format>u32:300-2160000</format>
                        <description>Time in seconds</description>
                      </valueHelp>
                      <constraint>
                        <validator name="numeric" argument="--range 300-2160000"/>
                      </constraint>
                      <constraintErrorMessage>Expiry time must be between 300 and 2160000 seconds</constraintErrorMessage>
                    </properties>
                  </leafNode>
                </children>
              </tagNode>
              <leafNode name="interval">
                <properties>
                  <help>Interval in seconds to wait between Dynamic 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>Interval must be between 60 and 3600 seconds</constraintErrorMessage>
                </properties>
                <defaultValue>300</defaultValue>
              </leafNode>
              #include <include/interface/vrf.xml.i>
            </children>
          </node>
        </children>
      </node>
    </children>
  </node>
</interfaceDefinition>