Add records. *replace* is the replacement mode. If ``False``, RRs are added to an existing RRset; if ``True``, the RRset is replaced with the specified contents. The second argument is the section to add to. The third argument is always a name. The other
(self, replace, section, name, *args)
| 131 | rrset.add(rd, ttl) |
| 132 | |
| 133 | def _add(self, replace, section, name, *args): |
| 134 | """Add records. |
| 135 | |
| 136 | *replace* is the replacement mode. If ``False``, |
| 137 | RRs are added to an existing RRset; if ``True``, the RRset |
| 138 | is replaced with the specified contents. The second |
| 139 | argument is the section to add to. The third argument |
| 140 | is always a name. The other arguments can be: |
| 141 | |
| 142 | - rdataset... |
| 143 | |
| 144 | - ttl, rdata... |
| 145 | |
| 146 | - ttl, rdtype, string... |
| 147 | """ |
| 148 | |
| 149 | if isinstance(name, str): |
| 150 | name = dns.name.from_text(name, None) |
| 151 | if isinstance(args[0], dns.rdataset.Rdataset): |
| 152 | for rds in args: |
| 153 | if replace: |
| 154 | self.delete(name, rds.rdtype) |
| 155 | for rd in rds: |
| 156 | self._add_rr(name, rds.ttl, rd, section=section) |
| 157 | else: |
| 158 | args = list(args) |
| 159 | ttl = int(args.pop(0)) |
| 160 | if isinstance(args[0], dns.rdata.Rdata): |
| 161 | if replace: |
| 162 | self.delete(name, args[0].rdtype) |
| 163 | for rd in args: |
| 164 | self._add_rr(name, ttl, rd, section=section) |
| 165 | else: |
| 166 | rdtype = dns.rdatatype.RdataType.make(args.pop(0)) |
| 167 | if replace: |
| 168 | self.delete(name, rdtype) |
| 169 | for s in args: |
| 170 | rd = dns.rdata.from_text(self.zone_rdclass, rdtype, s, self.origin) |
| 171 | self._add_rr(name, ttl, rd, section=section) |
| 172 | |
| 173 | def add(self, name: dns.name.Name | str, *args: Any) -> None: |
| 174 | """Add records. |