mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 20:48:40 +02:00
Merge branch 'main' into za/850-epp-contact-get
This commit is contained in:
commit
6c7ca8bb97
8 changed files with 413 additions and 20 deletions
|
@ -10,6 +10,7 @@ from epplibwrapper import (
|
|||
CLIENT as registry,
|
||||
commands,
|
||||
common as epp,
|
||||
extensions,
|
||||
info as eppInfo,
|
||||
RegistryError,
|
||||
ErrorCode,
|
||||
|
@ -281,6 +282,27 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
logger.error("Error _create_host, code was %s error was %s" % (e.code, e))
|
||||
return e.code
|
||||
|
||||
@Cache
|
||||
def dnssecdata(self) -> extensions.DNSSECExtension:
|
||||
return self._get_property("dnssecdata")
|
||||
|
||||
@dnssecdata.setter # type: ignore
|
||||
def dnssecdata(self, _dnssecdata: extensions.DNSSECExtension):
|
||||
updateParams = {
|
||||
"maxSigLife": _dnssecdata.get("maxSigLife", None),
|
||||
"dsData": _dnssecdata.get("dsData", None),
|
||||
"keyData": _dnssecdata.get("keyData", None),
|
||||
"remAllDsKeyData": True,
|
||||
}
|
||||
request = commands.UpdateDomain(name=self.name)
|
||||
extension = commands.UpdateDomainDNSSECExtension(**updateParams)
|
||||
request.add_extension(extension)
|
||||
try:
|
||||
registry.send(request, cleaned=True)
|
||||
except RegistryError as e:
|
||||
logger.error("Error adding DNSSEC, code was %s error was %s" % (e.code, e))
|
||||
raise e
|
||||
|
||||
@nameservers.setter # type: ignore
|
||||
def nameservers(self, hosts: list[tuple[str]]):
|
||||
"""host should be a tuple of type str, str,... where the elements are
|
||||
|
@ -928,9 +950,9 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
try:
|
||||
logger.info("Getting domain info from epp")
|
||||
req = commands.InfoDomain(name=self.name)
|
||||
domainInfo = registry.send(req, cleaned=True).res_data[0]
|
||||
domainInfoResponse = registry.send(req, cleaned=True)
|
||||
exitEarly = True
|
||||
return domainInfo
|
||||
return domainInfoResponse
|
||||
except RegistryError as e:
|
||||
count += 1
|
||||
|
||||
|
@ -1204,7 +1226,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
"""Contact registry for info about a domain."""
|
||||
try:
|
||||
# get info from registry
|
||||
data = self._get_or_create_domain()
|
||||
dataResponse = self._get_or_create_domain()
|
||||
data = dataResponse.res_data[0]
|
||||
# extract properties from response
|
||||
# (Ellipsis is used to mean "null")
|
||||
cache = {
|
||||
|
@ -1226,6 +1249,14 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
if "statuses" in cleaned:
|
||||
cleaned["statuses"] = [status.state for status in cleaned["statuses"]]
|
||||
|
||||
# get extensions info, if there is any
|
||||
# DNSSECExtension is one possible extension, make sure to handle
|
||||
# only DNSSECExtension and not other type extensions
|
||||
returned_extensions = dataResponse.extensions
|
||||
cleaned["dnssecdata"] = None
|
||||
for extension in returned_extensions:
|
||||
if isinstance(extension, extensions.DNSSECExtension):
|
||||
cleaned["dnssecdata"] = extension
|
||||
# Capture and store old hosts and contacts from cache if they exist
|
||||
old_cache_hosts = self._cache.get("hosts")
|
||||
old_cache_contacts = self._cache.get("contacts")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue