The dns.update.UpdateMessage Class

The dns.update.UpdateMessage class is used for DNS Dynamic Update messages. It provides section access using the DNS Dynamic Update section names, and a variety of convenience methods for constructing dynamic updates.

class dns.update.UpdateMessage(zone: Name | str | None = None, rdclass: RdataClass = RdataClass.IN, keyring: Any | None = None, keyname: Name | None = None, keyalgorithm: Name | str = <DNS name hmac-sha256.>, id: int | None = None)[source]

Initialize a new DNS Update object.

See the documentation of the Message class for a complete description of the keyring dictionary.

Parameters:
  • zone (dns.name.Name, str, or None) – The zone which is being updated. None should only be used by dnspython’s message constructors, as a zone is required for the convenience methods like add(), replace(), etc.

  • rdclass (int or str) – The class of the zone.

The keyring, keyname, and keyalgorithm parameters are passed to use_tsig(); see its documentation for details.

absent(name: Name | str, rdtype: RdataType | str | None = None) None[source]

Require that an owner name (and optionally an rdata type) does not exist as a prerequisite to the execution of the update.

add(name: Name | str, *args: Any) None[source]

Add records.

The first argument is always a name. The other arguments can be:

  • rdataset…

  • ttl, rdata…

  • ttl, rdtype, string…

delete(name: Name | str, *args: Any) None[source]

Delete records.

The first argument is always a name. The other arguments can be:

  • empty

  • rdataset…

  • rdata…

  • rdtype, [string…]

property prerequisite: list[RRset]

The prerequisite section.

present(name: Name | str, *args: Any) None[source]

Require that an owner name (and optionally an rdata type, or specific rdataset) exists as a prerequisite to the execution of the update.

The first argument is always a name. The other arguments can be:

  • rdataset…

  • rdata…

  • rdtype, string…

replace(name: Name | str, *args: Any) None[source]

Replace records.

The first argument is always a name. The other arguments can be:

  • rdataset…

  • ttl, rdata…

  • ttl, rdtype, string…

Note that if you want to replace the entire node, you should do a delete of the name followed by one or more calls to add.

property update: list[RRset]

The update section.

property zone: list[RRset]

The zone section.

The following constants may be used to specify sections in the find_rrset() and get_rrset() methods:

dns.update.ZONE = UpdateSection.ZONE

Update sections

dns.update.PREREQ = UpdateSection.PREREQ

Update sections

dns.update.UPDATE = UpdateSection.UPDATE

Update sections

dns.update.ADDITIONAL = UpdateSection.ADDITIONAL

Update sections